From b47c49d93b82c7143927fad500dba8b5dd4bea05 Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 7 May 2016 18:03:21 -0500 Subject: [PATCH] Temporarily disable clans ban functionality This can be reverted when clans bans are properly audited/fixed/tested. --- .../src/mineplex/game/clans/Clans.java | 5 +-- .../game/clans/clans/ClansManager.java | 41 +---------------- .../game/clans/clans/ban/ClansBanManager.java | 45 ++++++------------- .../clans/ban/commands/ClansBanCommand.java | 2 +- 4 files changed, 19 insertions(+), 74 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 7a95f29f5..b9c60183a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -41,7 +41,6 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.visibility.VisibilityManager; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.farming.FarmingShop; @@ -113,7 +112,7 @@ public class Clans extends JavaPlugin Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); + //ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); @@ -145,7 +144,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 1150359ab..11264d80b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -81,7 +81,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; @@ -226,20 +225,17 @@ public class ClansManager extends MiniClientPluginimplements IRelati private NautHashMap _unclaimMap = new NautHashMap(); public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; - - private ClansBanManager _clansBans; - + public ClanTips ClanTips; // Spawn area - public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); _instance = this; - _clansBans = clansBans; _punish = punish; _incognitoManager = incognitoManager; @@ -606,33 +602,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati { event.setJoinMessage(null); - if (_clansBans.willBeKicked(event.getPlayer())) - { - return; - } - if (_incognitoManager.Get(event.getPlayer()).Status) { return; } - - _clansBans.runAfterLoad(event.getPlayer().getName(), () -> { - if (_clansBans.Get(event.getPlayer().getName()).isBanned()) - { - return; - } - - for (Player other : UtilServer.getPlayers()) - { - if (_tutorial.inTutorial(other)) - { - // Don't display join message if player in tutorial. - continue; - } - - other.sendMessage(F.sys("Join", event.getPlayer().getName())); - } - }); } @EventHandler(priority = EventPriority.HIGHEST) @@ -645,11 +618,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; } - if (_clansBans.Get(event.getPlayer().getName()) != null && _clansBans.Get(event.getPlayer().getName()).isBanned()) - { - return; - } - for (Player other : UtilServer.getPlayers()) { if (_tutorial.inTutorial(other)) @@ -671,11 +639,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; } - if (_clansBans.willBeKicked(event.getPlayer())) - { - return; - } - if (event.getReason().contains("banned from Clans")) { return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java index 0975ac2d8..2c833d105 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -2,11 +2,9 @@ package mineplex.game.clans.clans.ban; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -38,15 +36,13 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor { private CoreClientManager _clientManager; private ClansBanRepository _repository; - private Map _clients; + private final Map _clients = new ConcurrentHashMap<>(); private Map _cache; private DefaultHashMap> _runAfterLoad; private ClansBanShop _shop; private Map _toKick = new HashMap<>(); - private Object _lock = new Object(); - public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { super("Blacklist", plugin); @@ -55,7 +51,6 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor _repository = new ClansBanRepository(plugin); - _clients = new HashMap<>(); _cache = new HashMap<>(); _runAfterLoad = new DefaultHashMap<>(name -> new ArrayList<>()); _shop = new ClansBanShop(this, clientManager, donationManager); @@ -92,10 +87,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor if (event.getType().equals(UpdateType.MIN_01)) { - synchronized (_lock) - { - UtilStreams.ToList(_clients.keySet().stream().filter(UtilServer::IsOnline)).forEach(this::UnloadClient); - } + _clients.keySet().stream().filter(UtilServer::IsOnline).forEach(this::UnloadClient); } } @@ -158,10 +150,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor public void UnloadClient(String name) { - synchronized (_lock) - { - _clients.remove(name); - } + _clients.remove(name); } public void LoadClient(String name, Callback callback) @@ -173,25 +162,19 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor } GetRepository().loadClient(name, client -> { - synchronized (_lock) - { - _clients.put(name.toLowerCase(), client); - System.out.println("> CLIENTS: " + _clients); - - if (callback != null) - { - callback.run(client); - } - } + _clients.put(name.toLowerCase(), client); + System.out.println("> CLIENTS: " + _clients); + + if (callback != null) + { + callback.run(client); + } }); } public ClansBanClient Get(String name) { - synchronized (_lock) - { - return _clients.get(name.toLowerCase()); - } + return _clients.get(name.toLowerCase()); } public ClansBanShop getShop() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java index dff0d8243..37a08eab1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -17,7 +17,7 @@ public class ClansBanCommand extends CommandBase @Override public void Execute(final Player caller, String[] args) - { + { if (args == null || args.length < 1) { UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans.");