Unbanning all players

Discussion in 'Plugin Development' started by Chaoscrasher, Jun 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    So I have a plugin that successfully deletes the banned-players.json file in the main directory.
    Unfortunately this does not seem to unban all players as I would have hoped.
    I think this is a result of the server essentially reading off a copy in the memory and resaving it to disk.

    So does anyone know how I can unban all banned users otherwise?

    Would be really appreciated :)
  2. Offline


    1. for(OfflinePlayer player : Bukkit.getOfflinePlayers()) {
    2. player.setBanned(false);
    3. }
  3. Offline


    Thanks, that is a good idea. I thought this method did not exist :)
    Edit: Just realized that p.setBanned(boolean) is deprecated.

    1. Why? ):
    2. What is the "better" way? Has it something to do with the recen UUID change?
  4. Offline


    You're correct, banned-players.json is only read once at startup. Instead you could juts use getBannedPlayers() and unban all of them.
    for(OfflinePlayer player: getServer().getBannedPlayers()) {
    Edit: beaten with the exact same code. Actually no, mine is better.
  5. Offline


    You can also use the new ban api. Retrieve a set of BanEntry by calling Server#getBanList(BanList.Type)#getBanEntries(), then just iterare through it, get the name/ip and call BanList#pardon to unban the target.
  6. Offline


    You can also iterate through

    2. Bukkit.getServer().getBannedPlayers();
  7. Offline


    Thanks for the clarification but you both use Player.setBanned() with is deprecated in 1.7.9 :/

    Edit: @ thecrystalflame Or would: BanList.pardon(p.getName()) actually work? It should, shouldn't it?

    Tried WinX64's way currently (thanks!), even though the implementation needs some really confusing mechanics.
    Gonna report what is working :)
Thread Status:
Not open for further replies.

Share This Page