From 49431da509ed637d4d0219f79b7169fe20b9301c Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 10 Apr 2015 10:53:11 -0500 Subject: [PATCH 1/5] Fix for pulling account UUID with multiple. --- .../mineplex/core/account/repository/AccountRepository.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index bb8f58163..5d45845fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -185,10 +185,10 @@ public class AccountRepository extends RepositoryBase } }, new ColumnVarChar("name", 100, name)); - if (uuids.size() > 1) - return null; + if (uuids.size() > 0) + return uuids.get(uuids.size() - 1); else - return uuids.size() == 1 ? uuids.get(0) : null; + return null; } public void saveRank(final Callback callback, final String name, final UUID uuid, final Rank rank, final boolean perm) From e3a328c70d14a8dc318d79c04fa3163a03c7c415 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 14 Apr 2015 01:32:03 -0500 Subject: [PATCH 2/5] Revert "Work on FriendRepository, still not enabled yet." This reverts commit 405d0fec18c1141605ab31f785fa6832e99331be. Re-enabled friends. --- .../mineplex/core/friend/FriendManager.java | 11 ------- .../core/friend/data/FriendRepository.java | 33 ++++++++++++++----- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 7289d672f..13b9e41e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -81,7 +81,6 @@ public class FriendManager extends MiniDbClientPlugin if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0) return; - /* final Player[] onlinePlayers = UtilServer.getPlayers(); Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() @@ -109,13 +108,10 @@ public class FriendManager extends MiniDbClientPlugin }); } }); - */ } public void addFriend(final Player caller, final String name) { - caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled.")); - /* if (caller.getName().equalsIgnoreCase(name)) { caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend")); @@ -218,13 +214,10 @@ public class FriendManager extends MiniDbClientPlugin }); } }); - */ } public void removeFriend(final Player caller, final String name) { - caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled.")); - /* Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { public void run() @@ -254,13 +247,10 @@ public class FriendManager extends MiniDbClientPlugin }); } }); - */ } public void showFriends(Player caller) { - caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled.")); - /* boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER); boolean gotAFriend = false; List friendStatuses = Get(caller).getFriends(); @@ -393,7 +383,6 @@ public class FriendManager extends MiniDbClientPlugin message.add(C.cAqua + C.Strike + "======================"); message.sendToPlayer(caller); - */ } public boolean isFriends(Player player, String friend) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index a06f3e540..359220020 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -16,7 +16,6 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnInt; import mineplex.core.database.column.ColumnVarChar; import mineplex.core.friend.FriendStatusType; import mineplex.serverdata.Region; @@ -27,8 +26,11 @@ import mineplex.serverdata.servers.ServerManager; public class FriendRepository extends RepositoryBase { - private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (sourceId, targetId) VALUES(?, ?);"; - private static String DELETE_FRIEND_RECORD = "DELETE FROM accountFriend WHERE id = ?;"; + private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; + private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource IN "; + private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status, created) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ?, now() FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; + private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;"; + private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;"; // Repository holding active PlayerStatus data. private DataRepository _repository; @@ -52,14 +54,29 @@ public class FriendRepository extends RepositoryBase { } - public boolean addFriend(int sourceAccountId, int targetAccountId) + public boolean addFriend(final Player caller, String name) { - return executeUpdate(ADD_FRIEND_RECORD, new ColumnInt("sourceId", sourceAccountId), new ColumnInt("targetId", targetAccountId)) > 0; + int rowsAffected = executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("status", 100, "Sent"), new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); + + if (rowsAffected > 0) + return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("status", 100, "Pending"), new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0; + + return false; } - public boolean removeFriendRecord(int recordId) + public boolean updateFriend(String caller, String name, String status) + { + return executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("uuid", 100, name), new ColumnVarChar("name", 100, caller)) > 0; + } + + public boolean removeFriend(String caller, String name) { - return executeUpdate(DELETE_FRIEND_RECORD, new ColumnInt("id", recordId)) > 0; + int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller)); + + if (rowsAffected > 0) + return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller), new ColumnVarChar("uuid", 100, name)) > 0; + + return false; } public NautHashMap getFriendsForAll(Player...players) @@ -67,7 +84,7 @@ public class FriendRepository extends RepositoryBase final NautHashMap friends = new NautHashMap(); StringBuilder stringBuilder = new StringBuilder(); - //stringBuilder.append(RETRIEVE_MULTIPLE_FRIEND_RECORDS + "("); + stringBuilder.append(RETRIEVE_MULTIPLE_FRIEND_RECORDS + "("); for (Player player : players) { From eea4b98069501655f0bc33dd1242537cf077e784 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 14 Apr 2015 01:59:09 -0500 Subject: [PATCH 3/5] Removed unused AccountManager.java --- .../bungee/account/AccountManager.java | 71 ---- .../account/AccountManagerRepository.java | 105 ------ .../mineplex/bungee/account/AccountToken.java | 24 -- .../src/mineplex/bungee/account/Callback.java | 6 - .../mineplex/bungee/account/ClientToken.java | 14 - .../mineplex/bungee/account/JsonWebCall.java | 355 ------------------ .../mineplex/bungee/account/LoginToken.java | 9 - .../mineplex/bungee/account/RankToken.java | 8 - 8 files changed, 592 deletions(-) delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManager.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManagerRepository.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountToken.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/Callback.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/ClientToken.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/JsonWebCall.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/LoginToken.java delete mode 100644 Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/RankToken.java diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManager.java deleted file mode 100644 index cfbee9592..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManager.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.bungee.account; - -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import com.google.gson.Gson; - -import mineplex.bungee.playerCount.PlayerCount; -import net.md_5.bungee.api.event.LoginEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.event.EventHandler; - -public class AccountManager implements Listener, Runnable -{ - private Plugin _plugin; - private PlayerCount _playerCount; - private int _playerCap = -1; - private AccountManagerRepository _repository; - - private Gson _gson = new Gson(); - - public AccountManager(Plugin plugin, PlayerCount playerCount) - { - _plugin = plugin; - _playerCount = playerCount; - - _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _plugin.getProxy().getScheduler().schedule(_plugin, this, 10L, 10L, TimeUnit.SECONDS); - - _repository = new AccountManagerRepository(); - _repository.initialize(); - _playerCap = _repository.retrievePlayerCap(); - } - - @EventHandler - public void login(LoginEvent event) - { - if (_playerCap == -1 || _playerCount.getTotalPlayers() <= _playerCap) - return; - - String response = getClient(event.getConnection().getName(), event.getConnection().getUniqueId(), event.getConnection().getAddress().toString()); - - ClientToken token = _gson.fromJson(response, ClientToken.class); - - if (token.Rank.equalsIgnoreCase("ALL")) - { - event.setCancelled(true); - event.setCancelReason("§fDue to server issues, we have added a §cplayer limit§f.\n" - + "§fWe hope to have this resolved soon, §nplease be ptient§r.\n" - + "§fPlayers with Ranks can still join the server!\n\n" - + "§fPurchase Ranks at §awww.mineplex.com/shop"); - } - } - - public String getClient(String name, UUID uuid, String ipAddress) - { - LoginToken token = new LoginToken(); - token.Name = name; - token.Uuid = uuid.toString(); - token.IpAddress = ipAddress; - - return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/Login").ExecuteReturnStream(token); - } - - @Override - public void run() - { - _playerCap = _repository.retrievePlayerCap(); - } -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManagerRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManagerRepository.java deleted file mode 100644 index 536955204..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountManagerRepository.java +++ /dev/null @@ -1,105 +0,0 @@ -package mineplex.bungee.account; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class AccountManagerRepository -{ - private Connection _connection = null; - private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10"; - private String _userName = "root"; - private String _password = "tAbechAk3wR7tuTh"; - - private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS playerCap (id INT NOT NULL AUTO_INCREMENT, playerCap INT, PRIMARY KEY (id));"; - private static String RETRIEVE_PLAYERCAP = "SELECT playerCap FROM playerCap;"; - - public void initialize() - { - PreparedStatement preparedStatement = null; - - try - { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - // Create table - preparedStatement = _connection.prepareStatement(CREATE_TABLE); - preparedStatement.execute(); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - - System.out.println("Initialized AccountManager."); - } - - public int retrievePlayerCap() - { - ResultSet resultSet = null; - PreparedStatement preparedStatement = null; - - try - { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERCAP); - resultSet = preparedStatement.executeQuery(); - - while (resultSet.next()) - { - return resultSet.getInt(1); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - - return -1; - } -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountToken.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountToken.java deleted file mode 100644 index d410ebfc6..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/AccountToken.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.bungee.account; - -import java.util.HashSet; -import java.util.List; - - -public class AccountToken -{ - public int AccountId; - public String Name; - public RankToken Rank; - - public int LoginCount; - public long LastLogin; - public long TotalPlayingTime; - public HashSet IpAdddresses = new HashSet(); - - public boolean Banned; - public String Reason; - - public int BlueGems; - public int GreenGems; - public List SalesPackageIds; -} \ No newline at end of file diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/Callback.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/Callback.java deleted file mode 100644 index a2e520ed9..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/Callback.java +++ /dev/null @@ -1,6 +0,0 @@ -package mineplex.bungee.account; - -public interface Callback -{ - public void run(T data); -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/ClientToken.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/ClientToken.java deleted file mode 100644 index 1d7cdcb45..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/ClientToken.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.bungee.account; - -public class ClientToken -{ - public int AccountId; - public String Name; - public String Rank; - public boolean RankPerm; - public String RankExpire; - public int EconomyBalance; - - public AccountToken AccountToken; - public long LastLogin; -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/JsonWebCall.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/JsonWebCall.java deleted file mode 100644 index 664e16ae5..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/JsonWebCall.java +++ /dev/null @@ -1,355 +0,0 @@ -package mineplex.bungee.account; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Type; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.PoolingClientConnectionManager; -import org.apache.http.message.BasicHeader; -import org.apache.http.protocol.HTTP; - -import com.google.gson.Gson; - -public class JsonWebCall -{ - private String _url; - private PoolingClientConnectionManager _connectionManager; - - public JsonWebCall(String url) - { - _url = url; - - SchemeRegistry schemeRegistry = new SchemeRegistry(); - schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); - - _connectionManager = new PoolingClientConnectionManager(schemeRegistry); - _connectionManager.setMaxTotal(200); - _connectionManager.setDefaultMaxPerRoute(20); - } - - public String ExecuteReturnStream(Object argument) - { - HttpClient httpClient = new DefaultHttpClient(_connectionManager); - InputStream in = null; - String result = null; - - try - { - HttpResponse response; - - Gson gson = new Gson(); - HttpPost request = new HttpPost(_url); - - if (argument != null) - { - StringEntity params = new StringEntity(gson.toJson(argument)); - params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); - request.setEntity(params); - } - - response = httpClient.execute(request); - - if (response != null) - { - in = response.getEntity().getContent(); - result = convertStreamToString(in); - } - } - catch (Exception ex) - { - System.out.println("Error executing JsonWebCall: \n" + ex.getMessage()); - System.out.println("Result: \n" + result); - - for (StackTraceElement trace : ex.getStackTrace()) - { - System.out.println(trace); - } - } - finally - { - httpClient.getConnectionManager().shutdown(); - - if (in != null) - { - try - { - in.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - - return result; - } - - public void Execute() - { - Execute((Object)null); - } - - public void Execute(Object argument) - { - HttpClient httpClient = new DefaultHttpClient(_connectionManager); - InputStream in = null; - - try - { - Gson gson = new Gson(); - HttpPost request = new HttpPost(_url); - - if (argument != null) - { - StringEntity params = new StringEntity(gson.toJson(argument)); - params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); - request.setEntity(params); - } - - httpClient.execute(request); - } - catch (Exception ex) - { - System.out.println("JsonWebCall.Execute() Error:\n" + ex.getMessage()); - - for (StackTraceElement trace : ex.getStackTrace()) - { - System.out.println(trace); - } - } - finally - { - httpClient.getConnectionManager().shutdown(); - - if (in != null) - { - try - { - in.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - } - - public T Execute(Class returnClass) - { - return Execute(returnClass, (Object)null); - } - - public T Execute(Type returnType, Object argument) - { - HttpClient httpClient = new DefaultHttpClient(_connectionManager); - InputStream in = null; - T returnData = null; - String result = null; - - try - { - HttpResponse response; - - Gson gson = new Gson(); - HttpPost request = new HttpPost(_url); - - if (argument != null) - { - StringEntity params = new StringEntity(gson.toJson(argument)); - params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); - request.setEntity(params); - } - - response = httpClient.execute(request); - - if (response != null) - { - in = response.getEntity().getContent(); - - result = convertStreamToString(in); - returnData = new Gson().fromJson(result, returnType); - } - } - catch (Exception ex) - { - System.out.println("Error executing JsonWebCall: \n" + ex.getMessage()); - System.out.println("Result: \n" + result); - - for (StackTraceElement trace : ex.getStackTrace()) - { - System.out.println(trace); - } - } - finally - { - httpClient.getConnectionManager().shutdown(); - - if (in != null) - { - try - { - in.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - - return returnData; - } - - public T Execute(Class returnClass, Object argument) - { - HttpClient httpClient = new DefaultHttpClient(_connectionManager); - InputStream in = null; - T returnData = null; - String result = null; - - try - { - HttpResponse response; - - Gson gson = new Gson(); - HttpPost request = new HttpPost(_url); - - if (argument != null) - { - StringEntity params = new StringEntity(gson.toJson(argument)); - params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); - request.setEntity(params); - } - - response = httpClient.execute(request); - - if (response != null) - { - in = response.getEntity().getContent(); - - result = convertStreamToString(in); - returnData = new Gson().fromJson(result, returnClass); - } - } - catch (Exception ex) - { - System.out.println("Error executing JsonWebCall: \n" + ex.getMessage()); - System.out.println("Result: \n" + result); - - for (StackTraceElement trace : ex.getStackTrace()) - { - System.out.println(trace); - } - } - finally - { - httpClient.getConnectionManager().shutdown(); - - if (in != null) - { - try - { - in.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - - return returnData; - } - - public void Execute(Class callbackClass, Callback callback) - { - Execute(callbackClass, callback, (Object)null); - } - - public void Execute(Class callbackClass, Callback callback, Object argument) - { - HttpClient httpClient = new DefaultHttpClient(_connectionManager); - InputStream in = null; - String result = null; - - try - { - HttpResponse response; - - Gson gson = new Gson(); - HttpPost request = new HttpPost(_url); - - if (argument != null) - { - StringEntity params = new StringEntity(gson.toJson(argument)); - params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); - request.setEntity(params); - } - - response = httpClient.execute(request); - - if (response != null && callback != null) - { - in = response.getEntity().getContent(); - - result = convertStreamToString(in); - callback.run(new Gson().fromJson(result, callbackClass)); - } - } - catch (Exception ex) - { - System.out.println("Error executing JsonWebCall: \n" + ex.getMessage()); - System.out.println("Result: \n" + result); - } - finally - { - httpClient.getConnectionManager().shutdown(); - - if (in != null) - { - try - { - in.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - } - - protected String convertStreamToString(InputStream is) - { - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - StringBuilder sb = new StringBuilder(); - - String line = null; - try { - while ((line = reader.readLine()) != null) { - sb.append(line + "\n"); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return sb.toString(); - } -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/LoginToken.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/LoginToken.java deleted file mode 100644 index 603259383..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/LoginToken.java +++ /dev/null @@ -1,9 +0,0 @@ -package mineplex.bungee.account; - -public class LoginToken -{ - public String Name; - public String IpAddress = "0.0.0.0"; - public String MacAddress = "00-00-00-00-00-00-00-00"; - public String Uuid; -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/RankToken.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/RankToken.java deleted file mode 100644 index 8af4ff6c7..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/account/RankToken.java +++ /dev/null @@ -1,8 +0,0 @@ -package mineplex.bungee.account; - -public class RankToken -{ - public int RankId; - - public String Name; -} From c4549733980112819ce4004078252f165b332e95 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 14 Apr 2015 01:59:29 -0500 Subject: [PATCH 4/5] Changed login deets for new new db cluster. --- .../src/mineplex/bungee/Mineplexer.java | 2 -- .../src/mineplex/core/command/CommandCenter.java | 14 -------------- .../src/mineplex/core/database/DBPool.java | 6 +++--- .../mineplex/core/status/ServerStatusManager.java | 4 ++-- Plugins/Mineplex.Database/src/jOOQConfig.xml | 4 ++-- .../servermonitor/StatusHistoryRepository.java | 6 ++---- 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java index 92fe1a11e..8ac4d3860 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java @@ -1,6 +1,5 @@ package mineplex.bungee; -import mineplex.bungee.account.AccountManager; import mineplex.bungee.lobbyBalancer.LobbyBalancer; import mineplex.bungee.motd.MotdManager; import mineplex.bungee.playerCount.PlayerCount; @@ -21,6 +20,5 @@ public class Mineplexer extends Plugin new PlayerStats(this); //new InternetStatus(this); new PlayerTracker(this); - new AccountManager(this, playerCount); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 4da7927f9..84f1a2616 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -75,20 +75,6 @@ public class CommandCenter implements Listener } } - @EventHandler - public void onTabComplete(TabCompleteEvent event) - { - ICommand command = Commands.get(event.getCommand().toLowerCase()); - - if (command != null) - { - List suggestions = command.onTabComplete(event.getSender(), event.getCommand(), event.getArgs()); - - if (suggestions != null) - event.setSuggestions(suggestions); - } - } - public void AddCommand(ICommand command) { for (String commandRoot : command.Aliases()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java index bb78f0542..f148d31c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java @@ -7,9 +7,9 @@ import org.apache.commons.dbcp2.BasicDataSource; public final class DBPool { - public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "root", "tAbechAk3wR7tuTh"); - public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "root", "tAbechAk3wR7tuTh"); - public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh"); + public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); + public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); + public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); public static final DataSource STATS_MINEPLEX = openDataSource("jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh"); private static DataSource openDataSource(String url, String username, String password) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index d12af2d66..2033584ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -70,10 +70,10 @@ public class ServerStatusManager extends MiniPlugin getPlugin().getConfig().addDefault("serverstatus.connectionurl", "db.mineplex.com:3306"); getPlugin().getConfig().set("serverstatus.connectionurl", getPlugin().getConfig().getString("serverstatus.connectionurl")); - getPlugin().getConfig().addDefault("serverstatus.username", "root"); + getPlugin().getConfig().addDefault("serverstatus.username", "MilitaryPolice"); getPlugin().getConfig().set("serverstatus.username", getPlugin().getConfig().getString("serverstatus.username")); - getPlugin().getConfig().addDefault("serverstatus.password", "tAbechAk3wR7tuTh"); + getPlugin().getConfig().addDefault("serverstatus.password", "CUPr6Wuw2Rus$qap"); getPlugin().getConfig().set("serverstatus.password", getPlugin().getConfig().getString("serverstatus.password")); getPlugin().getConfig().addDefault("serverstatus.us", true); diff --git a/Plugins/Mineplex.Database/src/jOOQConfig.xml b/Plugins/Mineplex.Database/src/jOOQConfig.xml index a690df4e8..f1827b5be 100644 --- a/Plugins/Mineplex.Database/src/jOOQConfig.xml +++ b/Plugins/Mineplex.Database/src/jOOQConfig.xml @@ -4,8 +4,8 @@ com.mysql.jdbc.Driver jdbc:mysql://db.mineplex.com:3306 - root - tAbechAk3wR7tuTh + MilitaryPolice + CUPr6Wuw2Rus$qap diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java index caf70a0ee..e2f94098c 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java @@ -17,7 +17,6 @@ import mineplex.servermonitor.data.BungeeStatusData; public class StatusHistoryRepository { private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/ServerStats"; - private String _bungeeConnectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers"; private String _userName = "root"; private String _password = "tAbechAk3wR7tuTh"; @@ -47,9 +46,6 @@ public class StatusHistoryRepository if (_connection == null || _connection.isClosed()) _connection = DriverManager.getConnection(_connectionString, _userName, _password); - if (_bungeeconnection == null || _bungeeconnection.isClosed()) - _bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password); - // Create table preparedStatement = _connection.prepareStatement(CREATE_GROUP_TABLE); preparedStatement.execute(); @@ -189,6 +185,7 @@ public class StatusHistoryRepository public void saveNetworkStats(double usedCpuPercent, double usedRamPercent, double availableCPU, double availableRAM, Region region) { + /* int totalPlayers = 0; List bungeeStatuses = new ArrayList(); @@ -318,5 +315,6 @@ public class StatusHistoryRepository } } } + */ } } From 99436b4a42d2e5fb72eadeb1b57bab279011eac3 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 14 Apr 2015 02:01:04 -0500 Subject: [PATCH 5/5] Added Tab event back :D --- .../src/mineplex/core/command/CommandCenter.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 84f1a2616..4da7927f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -75,6 +75,20 @@ public class CommandCenter implements Listener } } + @EventHandler + public void onTabComplete(TabCompleteEvent event) + { + ICommand command = Commands.get(event.getCommand().toLowerCase()); + + if (command != null) + { + List suggestions = command.onTabComplete(event.getSender(), event.getCommand(), event.getArgs()); + + if (suggestions != null) + event.setSuggestions(suggestions); + } + } + public void AddCommand(ICommand command) { for (String commandRoot : command.Aliases())