From f88c202e07244acea651138b279bde084e0a3887 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 17 Oct 2013 00:37:57 -0700 Subject: [PATCH 1/2] Added AntiHack to Arcade/Hub Added AntiHack Offense uploading. Fixed memory leaks in PreparedStatments Added Ultra tag in hub chat. --- .../globalServer/GlobalServerRepository.java | 15 +++- .../LobbyBalancerRepository.java | 30 +++++++- .../playerCount/PlayerCountRepository.java | 75 +++++++++++++++++-- .../PlayerTrackerRepository.java | 60 ++++++++++++++- .../src/mineplex/core/antihack/AntiHack.java | 57 +++++++++++--- .../core/status/ServerStatusRepository.java | 75 +++++++++++++++++-- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 + .../src/mineplex/hub/HubManager.java | 8 +- .../servermonitor/DynamicMonitor.java | 6 ++ .../servermonitor/GroupStatusData.java | 13 ++++ .../mineplex/servermonitor/Repository.java | 46 +++++++++++- .../src/nautilus/game/arcade/Arcade.java | 6 +- 12 files changed, 357 insertions(+), 36 deletions(-) create mode 100644 Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java create mode 100644 Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/globalServer/GlobalServerRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/globalServer/GlobalServerRepository.java index 79b6ba790..897aebf48 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/globalServer/GlobalServerRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/globalServer/GlobalServerRepository.java @@ -16,13 +16,14 @@ public class GlobalServerRepository public void initialize() { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); // Create table - PreparedStatement preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_TABLE); preparedStatement.execute(); } catch (Exception exception) @@ -31,6 +32,18 @@ public class GlobalServerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancerRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancerRepository.java index e54e555e4..b6a77c39d 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancerRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancerRepository.java @@ -20,13 +20,14 @@ public class LobbyBalancerRepository public void initialize() { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); // Create table - PreparedStatement preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_TABLE); preparedStatement.execute(); } catch (Exception exception) @@ -35,6 +36,18 @@ public class LobbyBalancerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try @@ -53,13 +66,14 @@ public class LobbyBalancerRepository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; List serverData = new ArrayList(); try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); + preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -84,6 +98,18 @@ public class LobbyBalancerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java index 7fc885bc4..c0b250116 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java @@ -33,18 +33,21 @@ public class PlayerCountRepository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; + PreparedStatement preparedStatementRetrieve = null; + PreparedStatement preparedStatementInsert = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); // Create table - PreparedStatement preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_TABLE); preparedStatement.execute(); // Retrieve id - PreparedStatement preparedStatementRetrieve = connection.prepareStatement(RETRIEVE_ID); + preparedStatementRetrieve = connection.prepareStatement(RETRIEVE_ID); preparedStatementRetrieve.setString(1, _address); resultSet = preparedStatementRetrieve.executeQuery(); @@ -56,7 +59,7 @@ public class PlayerCountRepository // Insert if not there if (_id == -1) { - PreparedStatement preparedStatementInsert = connection.prepareStatement(INSERT_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); + preparedStatementInsert = connection.prepareStatement(INSERT_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); preparedStatementInsert.setString(1, _address); preparedStatementInsert.setInt(2, 0); @@ -86,6 +89,42 @@ public class PlayerCountRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (preparedStatementRetrieve != null) + { + try + { + preparedStatementRetrieve.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (preparedStatementInsert != null) + { + try + { + preparedStatementInsert.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try @@ -115,12 +154,13 @@ public class PlayerCountRepository public boolean updatePlayerCountInDatabase(int players) { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); + preparedStatement = connection.prepareStatement(UPDATE_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); preparedStatement.setInt(1, players); preparedStatement.setInt(2, _maxPlayers); @@ -144,6 +184,18 @@ public class PlayerCountRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try @@ -163,12 +215,13 @@ public class PlayerCountRepository Connection connection = null; PlayerTotalData playerData = new PlayerTotalData(); ResultSet resultSet = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_COUNT); + preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_COUNT); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -184,6 +237,18 @@ public class PlayerCountRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java index 56600bd88..dc70776ef 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTrackerRepository.java @@ -21,13 +21,14 @@ public class PlayerTrackerRepository public void initialize() { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); // Create table - PreparedStatement preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_TABLE); preparedStatement.execute(); } catch (Exception exception) @@ -36,6 +37,18 @@ public class PlayerTrackerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try @@ -53,12 +66,13 @@ public class PlayerTrackerRepository public boolean updatePlayerServer(String name, String server) { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_PLAYER_SERVER); + preparedStatement = connection.prepareStatement(UPDATE_PLAYER_SERVER); preparedStatement.setString(1, server); preparedStatement.setString(2, name); @@ -89,6 +103,18 @@ public class PlayerTrackerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try @@ -107,12 +133,13 @@ public class PlayerTrackerRepository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_SERVER); + preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_SERVER); preparedStatement.setString(1, name); resultSet = preparedStatement.executeQuery(); @@ -127,6 +154,18 @@ public class PlayerTrackerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try @@ -158,12 +197,13 @@ public class PlayerTrackerRepository public boolean removePlayer(String name) { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(DELETE_PLAYER); + preparedStatement = connection.prepareStatement(DELETE_PLAYER); preparedStatement.setString(1, name); @@ -183,6 +223,18 @@ public class PlayerTrackerRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index fcef68103..6adb875fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -30,6 +30,9 @@ import org.bukkit.util.Vector; public class AntiHack extends MiniPlugin { public static AntiHack Instance; + private static Object _offensesSynch = new Object(); + + private AntiHackRepository _repository; //Record Offesnes private HashMap> _offenses = new HashMap>(); @@ -58,6 +61,9 @@ public class AntiHack extends MiniPlugin protected AntiHack(JavaPlugin plugin) { super("AntiHack", plugin); + + _repository = new AntiHackRepository(this, plugin.getConfig().getString("serverstatus.name")); + _repository.initialize(); } public static void Initialize(JavaPlugin plugin) @@ -135,7 +141,8 @@ public class AntiHack extends MiniPlugin if (!UtilTime.elapsed(_lastMove.get(player), _freecamTime)) continue; - player.kickPlayer(C.cGold + "Mineplex " + C.cRed + "Anti-Hack " + C.cWhite + "Kicked for Lagging / Free Cam."); + //player.kickPlayer(C.cGold + "Mineplex " + C.cRed + "Anti-Hack " + C.cWhite + "Kicked for Lagging / Free Cam."); + AddOffense(player, "Free Cam / Lag / Float"); } } @@ -162,6 +169,25 @@ public class AntiHack extends MiniPlugin UpdateSpeed(player, event); } + public HashMap> getOffenses() + { + return _offenses; + } + + public Object getOffensesSynch() + { + return _offensesSynch; + } + + @EventHandler + public void updateDatabase(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOWER) + return; + + _repository.saveOffenses(); + } + private void UpdateFloat(Player player) { int count = 0; @@ -276,6 +302,7 @@ public class AntiHack extends MiniPlugin limit = 0.32; for (PotionEffect effect : player.getActivePotionEffects()) + { if (effect.getType().equals(PotionEffectType.SPEED)) { if (UtilEnt.isGrounded(player)) @@ -283,7 +310,8 @@ public class AntiHack extends MiniPlugin else limit += 0.04 * (effect.getAmplifier() + 1); } - + } + //Check if (offset > limit && !UtilTime.elapsed(_speedTicks.get(player).getValue(), 200))//Counters Lag { @@ -306,14 +334,17 @@ public class AntiHack extends MiniPlugin private void AddOffense(Player player, String type) { - if (!_offenses.containsKey(player)) - _offenses.put(player, new HashMap()); - - int previous = 0; - if (_offenses.get(player).containsKey(type)) - previous = _offenses.get(player).get(type); - - _offenses.get(player).put(type, previous + 1); + synchronized (getOffensesSynch()) + { + if (!_offenses.containsKey(player)) + _offenses.put(player, new HashMap()); + + int previous = 0; + if (_offenses.get(player).containsKey(type)) + previous = _offenses.get(player).get(type); + + _offenses.get(player).put(type, previous + 1); + } //Print (Debug) System.out.println("[Offense] " + player.getName() + " received offense for " + type + "."); @@ -337,6 +368,10 @@ public class AntiHack extends MiniPlugin _ignore.remove(player); _ignoreStart.remove(player); - _offenses.remove(player); + + synchronized (getOffensesSynch()) + { + _offenses.remove(player); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java index a38c3cca7..0d4ebe245 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java @@ -42,18 +42,21 @@ public class ServerStatusRepository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; + PreparedStatement preparedStatementRetrieve = null; + PreparedStatement preparedStatementInsert = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); // Create table - PreparedStatement preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_TABLE); preparedStatement.execute(); // Retrieve id - PreparedStatement preparedStatementRetrieve = connection.prepareStatement(RETRIEVE_ID); + preparedStatementRetrieve = connection.prepareStatement(RETRIEVE_ID); preparedStatementRetrieve.setString(1, _address); resultSet = preparedStatementRetrieve.executeQuery(); @@ -65,7 +68,7 @@ public class ServerStatusRepository // Insert if not there if (_id == -1) { - PreparedStatement preparedStatementInsert = connection.prepareStatement(INSERT_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); + preparedStatementInsert = connection.prepareStatement(INSERT_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); preparedStatementInsert.setString(1, _serverName); preparedStatementInsert.setString(2, _serverGroup); @@ -99,6 +102,42 @@ public class ServerStatusRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (preparedStatementRetrieve != null) + { + try + { + preparedStatementRetrieve.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (preparedStatementInsert != null) + { + try + { + preparedStatementInsert.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try @@ -128,12 +167,13 @@ public class ServerStatusRepository public boolean updatePlayerCountInDatabase(String motd, int players, int maxPlayers, int tps) { Connection connection = null; + PreparedStatement preparedStatement = null; try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); + preparedStatement = connection.prepareStatement(UPDATE_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS); preparedStatement.setString(1, _serverName); preparedStatement.setString(2, _serverGroup); @@ -161,6 +201,18 @@ public class ServerStatusRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try @@ -179,13 +231,14 @@ public class ServerStatusRepository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; List serverData = new ArrayList(); try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); + preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -206,6 +259,18 @@ public class ServerStatusRepository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 108e41594..83f3bf5ca 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -2,6 +2,7 @@ package mineplex.hub; import me.chiss.Core.MemoryFix.MemoryFix; import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; @@ -66,6 +67,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation CommandCenter.Initialize(this, clientManager); ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); + AntiHack.Initialize(this); DonationManager donationManager = new DonationManager(this, GetWebServerAddress()); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 104d34227..a71004118 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -319,9 +319,15 @@ public class HubManager extends MiniClientPlugin Rank rank = GetClients().Get(player).GetRank(); + boolean ownsUltra = _donationManager.Get(player.getName()).OwnsUltraPackage(); + + //Rank Prefix String rankStr = ""; if (rank != Rank.ALL) - rankStr = rank.Color + C.Bold + GetClients().Get(player).GetRank().Name.toUpperCase() + " "; + rankStr = rank.Color + C.Bold + rank.Name.toUpperCase() + " "; + + if (ownsUltra && !rank.Has(Rank.ULTRA)) + rankStr = Rank.ULTRA.Color + C.Bold + Rank.ULTRA.Name.toUpperCase() + " "; //Party Chat if (event.getMessage().charAt(0) == '@') diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java new file mode 100644 index 000000000..1b7ad77da --- /dev/null +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java @@ -0,0 +1,6 @@ +package mineplex.servermonitor; + +public class DynamicMonitor +{ + +} diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java new file mode 100644 index 000000000..c8f4de139 --- /dev/null +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java @@ -0,0 +1,13 @@ +package mineplex.servermonitor; + +import java.util.ArrayList; +import java.util.List; + +public class GroupStatusData +{ + public String Name; + public int Players; + public int MaxPlayers; + + public List Servers = new ArrayList(); +} diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java index addec8bfa..7debf6a20 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java @@ -20,8 +20,8 @@ public class Repository public void initialize() { - Connection connection = null; + PreparedStatement preparedStatement = null; try { @@ -30,7 +30,7 @@ public class Repository connection = DriverManager.getConnection(_connectionString, _userName, _password); // Create table - PreparedStatement preparedStatement = connection.prepareStatement(CREATE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_TABLE); preparedStatement.execute(); } catch (Exception exception) @@ -39,6 +39,18 @@ public class Repository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (connection != null) { try @@ -57,13 +69,14 @@ public class Repository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; List serverData = new ArrayList(); try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(RETRIEVE_OLD_SERVER_STATUSES); + preparedStatement = connection.prepareStatement(RETRIEVE_OLD_SERVER_STATUSES); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -88,6 +101,18 @@ public class Repository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try @@ -120,13 +145,14 @@ public class Repository { Connection connection = null; ResultSet resultSet = null; + PreparedStatement preparedStatement = null; List groupData = new ArrayList(); try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - PreparedStatement preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); + preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -151,6 +177,18 @@ public class Repository } finally { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + if (resultSet != null) { try diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index ad8a7eab9..a94cd9ce1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -75,7 +75,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin private Logger _logger; private LootFactory _lootFactory; private Observer _observer; - private PetManager _petManager; + private PetManager _petManager; private me.chiss.Core.Server.Server _serverModule; private Spawn _spawn; private Teleport _teleport; @@ -279,7 +279,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin } @Override - public JavaPlugin GetPlugin() + public JavaPlugin GetPlugin() { return this; } @@ -429,7 +429,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin } @Override - public Teleport GetTeleport() + public Teleport GetTeleport() { if (_teleport == null) _teleport = new Teleport(this, _clientManager, GetSpawn()); From 7e77f78d2fe29b28e2bbbf720f3ea086ed7b5adb Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 17 Oct 2013 00:54:14 -0700 Subject: [PATCH 2/2] Removed all client list pull. --- .../mineplex/core/account/CoreClientManager.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index dc96bcada..85c50e4c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -1,8 +1,6 @@ package mineplex.core.account; import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; import mineplex.core.account.event.AsyncClientLoadEvent; import mineplex.core.account.event.ClientUnloadEvent; @@ -12,8 +10,6 @@ import mineplex.core.account.repository.token.ClientToken; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.libs.com.google.gson.Gson; @@ -34,7 +30,6 @@ public class CoreClientManager implements Listener private JavaPlugin _plugin; private AccountRepository _repository; - private HashSet _allClients; private NautHashMap _clientList; private HashSet _dontRemoveList; @@ -46,15 +41,9 @@ public class CoreClientManager implements Listener _plugin = plugin; _repository = new AccountRepository(webServer); - _allClients = new HashSet(); _clientList = new NautHashMap(); _dontRemoveList = new HashSet(); - for (String clientName : _repository.GetAllClientNames()) - { - _allClients.add(clientName); - } - _plugin.getServer().getPluginManager().registerEvents(this, _plugin); } @@ -117,11 +106,6 @@ public class CoreClientManager implements Listener return _clientList.get(player.getName()); } } - - public HashSet GetAll() - { - return _allClients; - } @EventHandler(priority = EventPriority.LOWEST) public void AsyncLogin(AsyncPlayerPreLoginEvent event)