Open YourGameSpace opened 5 years ago
And its me again ;) The ’api.addBan()’ is returning the Ban ID. Now you just Need to get the Ban again and change the Ban Message. I would Need to Look that Up Howe to do this with the API, but im currently on my phone ^^
Ok thanks! Have you already figured out how to integrate the Ban-ID into the Ban Text, or subsequently add it?
Hi @TUBEOF , this is atm the only way I could think of doing your thing:
int newBan = api.addBan("","","",12,"");
List<Ban> bans = api.getBans();
Optional<Ban> optionalBan = bans.stream().filter(s->newBan == s.getId()).findFirst();
if (optionalBan.isPresent()){
StringBuilder sb = new StringBuilder();
Ban newlyBan = optionalBan.get();
sb.append(newlyBan.getReason());
sb.append(" " + newlyBan.getId());
api.addBan(newlyBan.getBannedIp(),newlyBan.getBannedName(),newlyBan.getBannedUId(),newlyBan.getDuration(),sb.toString());
api.deleteBan(newlyBan.getId());
}
there is the expensive getBans call but that's because there is no getBan(int ID), maybe this could be an improvement @rogermb
Unfortunately, there is no such query that only allows you to query for a ban with a given ID. You'll have to do with keeping a local cache of all bans, and synchronizing them with the server if needed.
Alright, so far so good. How can I check if a client is already banned? So far I have tried it (see screenshot below), but unfortunately this does not work?
Hey, you are working with an Optional<T>
here. These normally cant be null. Instead your if(...) return true
just use return optional.isPresent()
Did it all now: https://hastebin.com/idikotalut.java However, now I always get "false" .. Although the client is banned.
Hey,
I dont know if getDatabaseClientInfo()
works if the Client is banned. If it does, then i need to investigate further.
Hello, it's me again. :P
I am currently in the process of reprogramming my TS3Bot for my network and I would like to improve some of that. Now it is my concern to banish the Bot clients. For every Ban, there seems to be a Ban ID, which is VERY GOOD FIND! However, my wish would be that if I ban a client, that the Ban ID is in the ban reason.
Unfortunately I have absolutely no idea how I get the Ban-ID of a spell .. Although I could do api#getBanns but that would be too expensive just synonymous with what you resources.
I first thought that you Ban ban = api#addBan(...); Unfortunately this is not possible.
So please help! Thank you!