From 8b747a81e152ae5f46b83d79245360dd22ffbd9f Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 19 Jul 2014 13:53:14 -0700 Subject: [PATCH 1/8] Fixed filter bypass --- Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 2fc50f4a6..4df6604c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -191,10 +191,11 @@ public class Chat extends MiniPlugin { final Player player = event.getPlayer(); final String plyrname = player.toString(); - final String msg = event.getMessage(); + final String msg = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim(); final String filtertype = "chat"; final String dname = player.getPlayerListName(); + JSONObject message = buildJsonChatObject(filtertype, dname, plyrname, msg, _serverName, 1); String response = getResponseFromTwoHat(message, filtertype); @@ -208,7 +209,7 @@ public class Chat extends MiniPlugin if (risk >= 5) { - String filteredMessage = event.getMessage(); + String filteredMessage = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim(); if (parseHashes(response) == null) event.setMessage(ChatColor.RED + msg); From e6818c4c465aec7c524266976a6f8f8319cac92f Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 19 Jul 2014 13:54:03 -0700 Subject: [PATCH 2/8] Added small tweaks to lobby balancer and sorter for better spread on connect. --- .../bungee/lobbyBalancer/LobbyBalancer.java | 14 ++++++++++++-- .../mineplex/bungee/lobbyBalancer/LobbySorter.java | 10 +++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index 9870bf191..de31b23c2 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -45,6 +45,8 @@ public class LobbyBalancer implements Listener, Runnable if (!event.getTarget().getName().equalsIgnoreCase("Lobby")) return; + boolean sort = false; + synchronized (_serverLock) { if (_playersSentToBestServer >= _maxPlayersToSendToBestServer) @@ -64,6 +66,11 @@ public class LobbyBalancer implements Listener, Runnable { _bestServerIndex = 0; _maxPlayersToSendToBestServer = 1; + + // Since we had to enter our dangerzone, update local data so if we have to enter it again we don't pick the same server over and over + _sortedLobbies.get(_bestServerIndex).Players += 5; + sort = true; + } } @@ -71,6 +78,10 @@ public class LobbyBalancer implements Listener, Runnable event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_bestServerIndex).Name)); _playersSentToBestServer++; + + // Only if we had to pick default regardless of the buffer safezone + if (sort) + Collections.sort(_sortedLobbies, new LobbySorter()); } } @@ -81,8 +92,6 @@ public class LobbyBalancer implements Listener, Runnable public void loadLobbyServers() { - _playersSentToBestServer = 0; - List serverStatusDataList = _repository.retrieveServerStatuses(); synchronized (_serverLock) @@ -108,6 +117,7 @@ public class LobbyBalancer implements Listener, Runnable Collections.sort(_sortedLobbies, new LobbySorter()); + _playersSentToBestServer = 0; _bestServerIndex = 0; if (_sortedLobbies.size() > 0) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbySorter.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbySorter.java index 1497c4636..24ce32b0c 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbySorter.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbySorter.java @@ -13,12 +13,6 @@ public class LobbySorter implements Comparator if (first.Players == 999) return 1; - if (first.MaxPlayers - first.Players > 15 && second.MaxPlayers - second.Players <= 15) - return -1; - - if (second.MaxPlayers - second.Players > 15 && first.MaxPlayers - first.Players <= 15) - return 1; - if (first.Players < (first.MaxPlayers / 2) && second.Players >= (second.MaxPlayers / 2)) return -1; @@ -44,7 +38,9 @@ public class LobbySorter implements Comparator if (Integer.parseInt(first.Name.split("-")[1]) < Integer.parseInt(second.Name.split("-")[1])) return -1; + else if (Integer.parseInt(second.Name.split("-")[1]) < Integer.parseInt(first.Name.split("-")[1])) + return 1; - return 1; + return 0; } } From de5c0a77ef29c2ccf318090225e085546a4ca09f Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 19 Jul 2014 13:54:27 -0700 Subject: [PATCH 3/8] Added another requirement for Lobbies in ServerMonitor 1500 available slots --- .../src/mineplex/servermonitor/GroupStatusData.java | 4 ++-- .../src/mineplex/servermonitor/ServerMonitor.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java index 145399fce..acfd4969b 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java @@ -44,7 +44,7 @@ public class GroupStatusData // Lobby joinable checking if (existingServer.Motd.isEmpty() || existingServer.Motd.equals("")) { - if (serverStatusData.MaxPlayers - serverStatusData.Players > 15) + if (serverStatusData.MaxPlayers - serverStatusData.Players > 20) _joinableCount--; } else @@ -66,7 +66,7 @@ public class GroupStatusData // Lobby joinable checking if (serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals("")) { - if (serverStatusData.MaxPlayers - serverStatusData.Players > 15) + if (serverStatusData.MaxPlayers - serverStatusData.Players > 20) { _joinableCount++; } diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 45746e3ef..977e0da1b 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -141,6 +141,13 @@ public class ServerMonitor int serversToAdd = Math.max(serverGroup.RequiredTotalServers - groupStatus.getTotalServers(), serverGroup.RequiredJoinableServers - groupStatus.getJoinableCount()); int serversToKill = (groupStatus.getTotalServers() > serverGroup.RequiredTotalServers && groupStatus.getJoinableCount() > serverGroup.RequiredJoinableServers) ? Math.min(groupStatus.getJoinableCount() - serverGroup.RequiredJoinableServers, groupStatus.EmptyServers.size()) : 0; + // Minimum 1500 slot bufferzone + if (serverGroup.Name.equalsIgnoreCase("Lobby")) + { + if (groupStatus.MaxPlayers - groupStatus.Players < 1500) + serversToAdd = serverGroup.RequiredJoinableServers; + } + while (serversToAdd > 0) { int serverNum = groupStatus.getNextServerNumber(); From 2ae3d89496c1586f8c9b9f1da44aab68ca7c2fe3 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 19 Jul 2014 13:56:03 -0700 Subject: [PATCH 4/8] Fixed issue with RepositoryBase and Friend/MysqlRepo Each db call on login gets its own async after the first two account calls are finished. --- .../core/account/CoreClientManager.java | 33 +++++++---- .../event/RetrieveClientInformationEvent.java | 16 +++++ .../repository/MysqlAccountRepository.java | 11 +++- .../core/database/RepositoryBase.java | 56 +++--------------- .../src/mineplex/core/elo/EloManager.java | 56 ++++++++++++++---- .../core/friend/data/FriendRepository.java | 4 +- .../core/preferences/PreferencesManager.java | 16 ++++- .../src/mineplex/core/stats/StatsManager.java | 11 +++- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- Website/LOCWebsite.suo | Bin 474624 -> 474624 bytes 10 files changed, 125 insertions(+), 80 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 32500667c..7d933b10a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -122,7 +122,6 @@ public class CoreClientManager extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void AsyncLogin(AsyncPlayerPreLoginEvent event) { - TimingManager.start(event.getName() + " logging in ASYNC."); try { LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()); @@ -132,6 +131,8 @@ public class CoreClientManager extends MiniPlugin Logger.Instance.log(exception); event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute."); + + System.out.println(exception.getMessage()); } if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR)) @@ -146,12 +147,12 @@ public class CoreClientManager extends MiniPlugin event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend."); } - - TimingManager.stop(event.getName() + " logging in ASYNC."); } private void LoadClient(CoreClient client, UUID uuid, String ipAddress) { + TimingManager.start(client.GetPlayerName() + " LoadClient Total."); + // Prep for mysql ClientToken token = null; @@ -170,30 +171,38 @@ public class CoreClientManager extends MiniPlugin // Load client in miniplugins Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client)); + + RetrieveClientInformationEvent clientInformationEvent = new RetrieveClientInformationEvent(client.GetPlayerName(), uuid); try { // Mysql - Bukkit.getServer().getPluginManager().callEvent(new RetrieveClientInformationEvent(client.GetPlayerName(), uuid)); + Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent); } catch (Exception exception) { Logger.Instance.log(exception); System.out.println("Error running RetrieveClientInformationEvent" + exception.getMessage()); } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void LoginTiming(PlayerLoginEvent event) - { - TimingManager.stop(event.getPlayer().getName() + " logging in SYNC."); + + while (clientInformationEvent.processing()) + { + try + { + Thread.sleep(1); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + TimingManager.stop(client.GetPlayerName() + " LoadClient Total."); } @EventHandler(priority = EventPriority.LOWEST) public void Login(PlayerLoginEvent event) { - TimingManager.start(event.getPlayer().getName() + " logging in SYNC."); - synchronized(_clientLock) { if (!_clientList.containsKey(event.getPlayer().getName())) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/RetrieveClientInformationEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/RetrieveClientInformationEvent.java index f8d2a1a8b..a07d87528 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/RetrieveClientInformationEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/RetrieveClientInformationEvent.java @@ -11,6 +11,7 @@ public class RetrieveClientInformationEvent extends Event private String _playerName; private UUID _uuid; + private int _processingCount; public RetrieveClientInformationEvent(String playerName, UUID uuid) { @@ -37,4 +38,19 @@ public class RetrieveClientInformationEvent extends Event { return _uuid; } + + public void incrementProcessingCount() + { + _processingCount++; + } + + public boolean processing() + { + return _processingCount > 0; + } + + public void decreaseProcessingCount() + { + _processingCount--; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java index 899fd2228..638c3b8cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java @@ -8,7 +8,8 @@ import mineplex.core.database.column.ColumnVarChar; public class MysqlAccountRepository extends RepositoryBase { private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));"; - private static String ACCOUNT_LOGIN = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);"; + private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);"; + private static String ACCOUNT_LOGIN_UPDATE = "UPDATE accounts SET uuid=?, name=?, lastLogin=now() WHERE uuid = ?;"; public MysqlAccountRepository(JavaPlugin plugin) { @@ -26,6 +27,12 @@ public class MysqlAccountRepository extends RepositoryBase public void login(String uuid, String name) { - executeUpdate(ACCOUNT_LOGIN, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name)); + int affectedRows = executeUpdate(ACCOUNT_LOGIN_UPDATE, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid)); + + if (affectedRows == 0) + { + executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name)); + System.out.println("Executed LOGIN_NEW"); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java index a8f280fd3..e5fb8d38d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java @@ -61,15 +61,16 @@ public abstract class RepositoryBase protected int executeUpdate(String query, Column...columns) { - Connection connection = null; PreparedStatement preparedStatement = null; int affectedRows = 0; try { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - preparedStatement = connection.prepareStatement(query); + if (_connection == null || !_connection.isValid(1)) + _connection = DriverManager.getConnection(_connectionString, _userName, _password); + + preparedStatement = _connection.prepareStatement(query); for (int i=0; i < columns.length; i++) { @@ -95,18 +96,6 @@ public abstract class RepositoryBase e.printStackTrace(); } } - - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } } return affectedRows; @@ -149,13 +138,14 @@ public abstract class RepositoryBase protected void executeQuery(String query, ResultSetCallable callable, Column...columns) { - Connection connection = null; PreparedStatement preparedStatement = null; try { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - preparedStatement = connection.prepareStatement(query); + if (_connection == null || !_connection.isValid(1)) + _connection = DriverManager.getConnection(_connectionString, _userName, _password); + + preparedStatement = _connection.prepareStatement(query); executeQuery(preparedStatement, callable, columns); } @@ -176,31 +166,15 @@ public abstract class RepositoryBase e.printStackTrace(); } } - - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } } } protected int executeUpdate(PreparedStatement preparedStatement, Column...columns) { - Connection connection = null; - int affectedRows = 0; try { - connection = DriverManager.getConnection(_connectionString, _userName, _password); - for (int i=0; i < columns.length; i++) { columns[i].setValue(preparedStatement, i+1); @@ -212,20 +186,6 @@ public abstract class RepositoryBase { exception.printStackTrace(); } - finally - { - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } return affectedRows; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index 10981c224..fc567f9a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -5,12 +5,16 @@ import java.util.UUID; import mineplex.core.MiniPlugin; import mineplex.core.account.event.RetrieveClientInformationEvent; import mineplex.core.common.util.NautHashMap; +import mineplex.core.timing.TimingManager; +import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; public class EloManager extends MiniPlugin { + private static Object _playerEloLock = new Object(); + private EloRepository _repository; private EloRatingSystem _ratingSystem; private NautHashMap> _playerElos; @@ -41,20 +45,39 @@ public class EloManager extends MiniPlugin } @EventHandler - public void retrievePlayersElos(RetrieveClientInformationEvent event) + public void retrievePlayersElos(final RetrieveClientInformationEvent event) { - _playerElos.put(event.getUniqueId().toString(), _repository.loadClientInformation(event.getUniqueId())); + event.incrementProcessingCount(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + TimingManager.start(event.getPlayerName() + " elo Account call."); + NautHashMap eloMap = _repository.loadClientInformation(event.getUniqueId()); + TimingManager.stop(event.getPlayerName() + " elo Account call."); + + synchronized (_playerEloLock) + { + _playerElos.put(event.getUniqueId().toString(), eloMap); + } + + event.decreaseProcessingCount(); + } + }); } public int getElo(UUID uuid, String gameType) { int elo = 1000; - if (_playerElos.containsKey(uuid.toString())) + synchronized (_playerEloLock) { - if (_playerElos.get(uuid.toString()).containsKey(gameType)) + if (_playerElos.containsKey(uuid.toString())) { - elo = _playerElos.get(uuid.toString()).get(gameType); + if (_playerElos.get(uuid.toString()).containsKey(gameType)) + { + elo = _playerElos.get(uuid.toString()).get(gameType); + } } } @@ -94,16 +117,25 @@ public class EloManager extends MiniPlugin saveElo(uuid.toString(), gameType, elo); } - public void saveElo(String uuid, String gameType, int elo) + public void saveElo(final String uuid, final String gameType, final int elo) { - _repository.saveElo(uuid, gameType, elo); - - if (_playerElos.containsKey(uuid)) + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() { - if (_playerElos.get(uuid).containsKey(gameType)) + public void run() { - _playerElos.get(uuid).put(gameType, elo); + _repository.saveElo(uuid, gameType, elo); + + synchronized (_playerEloLock) + { + if (_playerElos.containsKey(uuid)) + { + if (_playerElos.get(uuid).containsKey(gameType)) + { + _playerElos.get(uuid).put(gameType, elo); + } + } + } } - } + }); } } 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 697c971f3..45bbdaf37 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -14,8 +14,8 @@ import mineplex.core.database.column.ColumnVarChar; public class FriendRepository extends RepositoryBase { - private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), mutual BOOL, PRIMARY KEY (id), INDEX uuidTargetIndex (uuidTarget));"; - private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, mutual FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; + private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), mutual BOOL, PRIMARY KEY (id), INDEX uuidIndex (uuidSource, uuidTarget));"; + private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;"; private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.uuid = ?;"; private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts ON accounts.name = ? WHERE uuidSource = ? AND uuidTarget = accounts.uuid;"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index e8a219c49..96d089e18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -2,6 +2,7 @@ package mineplex.core.preferences; import java.util.Map.Entry; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -19,6 +20,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.preferences.command.PreferencesCommand; import mineplex.core.preferences.ui.PreferencesShop; +import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -64,9 +66,19 @@ public class PreferencesManager extends MiniClientPlugin } @Override - protected void loadClientInformation(RetrieveClientInformationEvent event) + protected void loadClientInformation(final RetrieveClientInformationEvent event) { - Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId())); + event.incrementProcessingCount(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + TimingManager.start(event.getPlayerName() + " pref Account call."); + Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId())); + TimingManager.stop(event.getPlayerName() + " pref Account call."); + event.decreaseProcessingCount(); + } + }); } public void savePreferences(Player caller) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 9bae81a48..b4672454c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -8,6 +8,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; @@ -126,8 +127,16 @@ public class StatsManager extends MiniPlugin } @EventHandler - public void loadPlayerStats(RetrieveClientInformationEvent event) + public void loadPlayerStats(final RetrieveClientInformationEvent event) { + event.incrementProcessingCount(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + event.decreaseProcessingCount(); + } + }); /* HA YOU THOUGHT I WAS GOING TO RUN DIDN'T YOU? */ if (true) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index d4e894465..e65d5966a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -91,7 +91,7 @@ public class Hub extends JavaPlugin implements IRelation //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager)); PacketHandler packetHandler = new PacketHandler(this); - new FriendManager(this, packetHandler); + //new FriendManager(this, packetHandler); PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager); Portal portal = new Portal(this, serverStatusManager.getCurrentServerName()); AntiHack.Initialize(this, punish, portal); diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 047b052394fc5ac25c67c05b1d8bf61f7e28ca0c..6f1b215ace93b35e47f04c76d6467fb1162a7030 100644 GIT binary patch delta 12362 zcmaia3sjWl+V(up`@93W~wkdU;Sn9&9}A{i^EZ^*e(2PV=|eDW%6WgW*e`F#wYFYJKeTj zX%iNa^7q*0-_2vV$yAu7{Sh;u6^p{RcQyZ_&1{#i?G-(?U1|4un^vqC-%oG;ZQGSD zmTq+9Wj>ocb6JeG>skVB%@!^#eAz{nFDmicn%9!F`mJ6qkP)YtO!rX7KBApg|C3uA zH+VLsSF2Xdl`gg|FZ}62cK5dD7rdruN3PqnbC;5+C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_f#`Y69(^&Dqo3eL)YsND(W1P2eGD}Tlm^EDR>)oHaGl>k6EA$T>7uJk zjmY4_??tUit1n@RAa0sfkaerFPat@%ZZP3xDoHnKgW1&@>f6lCD)Rmf?EX@~jAjkX z%`xnKwNoqA{=lVMs4}hE1Vbtc0U2GZ%!CA$xz?Yw5aB;1_*?LMS{njCdj9}kukNDI zdNW22#WOOVH+PWB&WlxxTF~EDz}H15w2No^R+vgZc6Dq4=gFFx$Up~<<=GA7q(I>KN1h6DRszpBZ^?LIJV=L)EgE@`D{e&mDs?J<&(6GN? zN9MmNhU-xUU*2Ng!PrK1+heNa2VZJ1%NTYNC&vZ>E88L=VU94LwJ0)UnmnC*bl46e5cJj~Pl$->ICS;p#LA_z+Ik@rP{IE4G>K{b@m~=uZa^ zi#vm!&&_QpwtBDMF;7Ob*|cC8yP3kjMrOz^2uDw?`6yvQBZ3z{H)9y!;bn}n#iG(RNOj-sQTjLg+J}K5kF955SIw8L^;|yfffo!NZ3AEt9W3XhgQTE4hiUvK>?;fzvjUF|Bey)|Iqv*C- z_TfYvbq(U^;zKPtuBPOX(d7?Sre&v4y Do=#z( From 1362deca590a05a5de972318e156dfe2fcc04c95 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 19 Jul 2014 13:56:21 -0700 Subject: [PATCH 5/8] More work on FriendManager --- .../mineplex/core/friend/FriendManager.java | 47 ++++++++++++++++--- .../core/friend/ui/FriendTabList.java | 30 +++++++----- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index fbe373ac9..ee08811a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -4,6 +4,7 @@ import net.minecraft.server.v1_7_R3.Packet; import net.minecraft.server.v1_7_R3.PacketPlayOutPlayerInfo; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -12,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniClientPlugin; import mineplex.core.account.event.RetrieveClientInformationEvent; +import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.friend.command.AddFriend; import mineplex.core.friend.command.DeleteFriend; @@ -21,6 +23,7 @@ import mineplex.core.friend.ui.FriendTabList; import mineplex.core.packethandler.IPacketRunnable; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketVerifier; +import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -55,9 +58,19 @@ public class FriendManager extends MiniClientPlugin implements IPack } @Override - protected void loadClientInformation(RetrieveClientInformationEvent event) + protected void loadClientInformation(final RetrieveClientInformationEvent event) { - Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId())); + event.incrementProcessingCount(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() + { + public void run() + { + TimingManager.start(event.getPlayerName() + " friend Account call."); + Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId())); + TimingManager.stop(event.getPlayerName() + " friend Account call."); + event.decreaseProcessingCount(); + } + }); } @EventHandler @@ -77,9 +90,10 @@ public class FriendManager extends MiniClientPlugin implements IPack _sendingPackets = false; } + @EventHandler public void updateFriends(UpdateEvent event) { - if (event.getType() != UpdateType.SLOW) + if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().length == 0) return; Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() @@ -94,11 +108,16 @@ public class FriendManager extends MiniClientPlugin implements IPack { for (Player player : _playerTabMap.keySet()) { - if (newData.containsKey(player.getName())) + if (newData.containsKey(player.getUniqueId().toString())) { - _playerTabMap.get(player).updateFriends(newData.get(player.getName()).Friends); - Get(player).Friends = newData.get(player.getName()).Friends; + Get(player).Friends = newData.get(player.getUniqueId().toString()).Friends; } + else + { + Get(player).Friends.clear(); + } + + _playerTabMap.get(player).updateFriends(Get(player).Friends); } } }); @@ -137,6 +156,14 @@ public class FriendManager extends MiniClientPlugin implements IPack public void run() { _repository.addFriend(caller.getUniqueId().toString(), name); + + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + caller.sendMessage(F.main(GetName(), "Added " + ChatColor.GREEN + name + " to your friends list!")); + } + }); } }); } @@ -148,6 +175,14 @@ public class FriendManager extends MiniClientPlugin implements IPack public void run() { _repository.removeFriend(caller.getUniqueId().toString(), name); + + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + caller.sendMessage(F.main(GetName(), "Deleted " + ChatColor.GREEN + name + " from your friends list!")); + } + }); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java index 5a9d0e006..a2b0f6a02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java @@ -18,13 +18,11 @@ public class FriendTabList extends TabList { super(); - set(0, 0, ChatColor.GOLD + " Name"); - set(1, 0, ChatColor.GOLD + " Location"); - set(2, 0, ChatColor.GOLD + " Status"); + set(0, 0, ChatColor.GOLD + "" + ChatColor.BOLD + " Name"); + set(1, 0, ChatColor.GOLD + "" + ChatColor.BOLD + " Location"); + set(2, 0, ChatColor.GOLD + "" + ChatColor.BOLD + " Status"); updateFriends(friends); - - System.out.println("created friend tablist with " + friends.size() + " friends"); } public void updateFriends(List friends) @@ -32,14 +30,24 @@ public class FriendTabList extends TabList Collections.sort(friends, _friendSorter); int row = 1; - for (int i = 0; i < 20 && i < friends.size(); i++) + for (int i = 0; i < 19; i++) { - FriendStatus status = friends.get(i); + if (i < friends.size()) + { + FriendStatus status = friends.get(i); + + set(0, row, (status.Mutual ? ChatColor.GREEN : ChatColor.YELLOW) + status.Name); + set(1, row, status.Mutual ? ChatColor.GREEN + status.ServerName : ChatColor.YELLOW + "Unknown"); + set(2, row, (status.Mutual ? ChatColor.GREEN : ChatColor.YELLOW) + (status.Online ? "Online" : UtilTime.convert(status.LastSeenOnline, 2, TimeUnit.MINUTES) + "")); + } + else + { + set(0, row, null); + set(1, row, null); + set(2, row, null); + } - set(0, row, (status.Mutual ? ChatColor.GREEN : ChatColor.YELLOW) + status.Name); - set(1, row, status.Mutual ? ChatColor.GREEN + status.ServerName : ChatColor.YELLOW + "Unknown"); - set(2, row, (status.Mutual ? ChatColor.GREEN : ChatColor.YELLOW) + (status.Online ? "Online" : UtilTime.convert(status.LastSeenOnline, 2, TimeUnit.MINUTES) + "")); - System.out.println("Added friend " + status.Name + " to tablist"); + row++; } } } From 5bc7549b8c3e7efcc6116b1b084d5e02c0a68d1b Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 19 Jul 2014 14:48:05 -0700 Subject: [PATCH 6/8] Disabled news because of console errors. --- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 557316935..ac9eda6ba 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -285,7 +285,7 @@ public class HubManager extends MiniClientPlugin public void AddCommands() { AddCommand(new GadgetToggle(this)); - AddCommand(new NewsCommand(this)); + //AddCommand(new NewsCommand(this)); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index c553598aa..6fac74c51 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -41,7 +41,7 @@ public class NewsManager extends MiniPlugin Manager = manager; - _repository.initialize(manager.GetPlugin().getConfig().getBoolean("serverstatus.us")); + //_repository.initialize(manager.GetPlugin().getConfig().getBoolean("serverstatus.us")); _news = new String[] { @@ -49,7 +49,7 @@ public class NewsManager extends MiniPlugin "Survival: " + C.cGreen + C.Bold + "UHC Alpha", }; - RefreshNews(); + //RefreshNews(); } private void RefreshNews() @@ -187,6 +187,7 @@ public class NewsManager extends MiniPlugin }); } + /* @EventHandler public void NewsUpdate(UpdateEvent event) { @@ -195,6 +196,7 @@ public class NewsManager extends MiniPlugin RefreshNews(); } + */ @EventHandler public void FlightUpdate(UpdateEvent event) From e8d4ab25175dbde39b28751564c8f817ffda7eec Mon Sep 17 00:00:00 2001 From: Peter Miller Date: Mon, 21 Jul 2014 18:06:33 -0400 Subject: [PATCH 7/8] Re-enabled News commands after adding check to "Reset newsIndex if outside of bounds of news array after RefreshNews but before UtilTime.elapsed" in NewsManager.java --- .../Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../src/mineplex/hub/modules/NewsManager.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index ac9eda6ba..557316935 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -285,7 +285,7 @@ public class HubManager extends MiniClientPlugin public void AddCommands() { AddCommand(new GadgetToggle(this)); - //AddCommand(new NewsCommand(this)); + AddCommand(new NewsCommand(this)); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 6fac74c51..e540d04d0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -41,7 +41,7 @@ public class NewsManager extends MiniPlugin Manager = manager; - //_repository.initialize(manager.GetPlugin().getConfig().getBoolean("serverstatus.us")); + _repository.initialize(manager.GetPlugin().getConfig().getBoolean("serverstatus.us")); _news = new String[] { @@ -49,7 +49,7 @@ public class NewsManager extends MiniPlugin "Survival: " + C.cGreen + C.Bold + "UHC Alpha", }; - //RefreshNews(); + RefreshNews(); } private void RefreshNews() @@ -66,9 +66,9 @@ public class NewsManager extends MiniPlugin String[] newsStrings = new String[maxPosition]; for (Iterator iterator = newsEntries.keySet().iterator(); iterator.hasNext();) { - String newsPosition = iterator.next(); + String newsPosition = iterator.next(); newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition); - } + } _news = newsStrings; } @@ -187,7 +187,6 @@ public class NewsManager extends MiniPlugin }); } - /* @EventHandler public void NewsUpdate(UpdateEvent event) { @@ -196,7 +195,6 @@ public class NewsManager extends MiniPlugin RefreshNews(); } - */ @EventHandler public void FlightUpdate(UpdateEvent event) @@ -218,6 +216,11 @@ public class NewsManager extends MiniPlugin { _newsIndex = (_newsIndex + 1)%_news.length; _newsTime = System.currentTimeMillis(); + } + if (_newsIndex >= _news.length) + { + // Resets newsIndex if outside of bounds of news array after RefreshNews but before UtilTime.elapsed above + _newsIndex = 0; } //Text From d7037f1619570a75884308cd0edea7473bdbf344 Mon Sep 17 00:00:00 2001 From: Peter Miller Date: Tue, 22 Jul 2014 22:18:29 -0400 Subject: [PATCH 8/8] Breaking up "/news" commands (like "/npc" sub-commands) using multicommandbase. --- .../mineplex/hub/commands/NewsAddCommand.java | 71 ++++++ .../mineplex/hub/commands/NewsCommand.java | 208 +----------------- .../hub/commands/NewsConfirmCommand.java | 45 ++++ .../hub/commands/NewsDeleteCommand.java | 59 +++++ .../hub/commands/NewsListCommand.java | 66 ++++++ .../mineplex/hub/commands/NewsSetCommand.java | 81 +++++++ .../src/mineplex/hub/modules/NewsManager.java | 19 ++ 7 files changed, 351 insertions(+), 198 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java new file mode 100644 index 000000000..455218794 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java @@ -0,0 +1,71 @@ +package mineplex.hub.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.hub.HubManager; +import mineplex.hub.modules.NewsManager; + +public class NewsAddCommand extends CommandBase +{ + public NewsAddCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "add"); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null || args.length == 0 || args.length > 128) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + else + { + NewsManager newsMang = Plugin.GetNewsManager(); + + String newsEntry = ""; + for (int i = 0; i < args.length; i++) + { + newsEntry += args[i] + " "; + } + newsEntry = newsEntry.substring(0, newsEntry.length() - 1); + + // Check for 256 character length for MySQL! + if (newsEntry.length() > 256) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!")); + return; + } + + newsMang.AddNewsEntry(newsEntry, new Callback() + { + public void run(Boolean success) + { + if (success) + { + String newsEntry = ""; + for (int i = 0; i < args.length; i++) + { + newsEntry += args[i] + " "; + } + newsEntry = newsEntry.substring(0, newsEntry.length() - 1); + + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error adding the news entry to the database!")); + } + } + }); + return; + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java index 71067f06a..dd1e33d77 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java @@ -1,215 +1,27 @@ package mineplex.hub.commands; -import java.util.HashMap; -import java.util.Iterator; - import org.bukkit.entity.Player; -import mineplex.core.command.CommandBase; +import mineplex.core.command.MultiCommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.hub.HubManager; -import mineplex.hub.modules.NewsManager; -public class NewsCommand extends CommandBase +public class NewsCommand extends MultiCommandBase { public NewsCommand(HubManager plugin) { super(plugin, Rank.ADMIN, "news"); + + AddCommand(new NewsAddCommand(plugin)); + AddCommand(new NewsDeleteCommand(plugin)); + AddCommand(new NewsConfirmCommand(plugin)); + AddCommand(new NewsListCommand(plugin)); + AddCommand(new NewsSetCommand(plugin)); } @Override - public void Execute(final Player caller, final String[] args) + protected void Help(Player caller, String args[]) { - final NewsManager newsMang = Plugin.GetNewsManager(); - - if (args == null || args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); - - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Available news arguments for this command:")); - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news list" + C.cGray + " - Lists (numbered) stored news messages from database.")); - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news add " + C.cGray + " - Adds specified news entry string to database at end of table.")); - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news delete #" + C.cGray + " - Removes specified (numbered) news entry string from database.")); - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news set # " + C.cGray + " - Updates specified (numbered) news entry string in database.")); - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "*Please Note: " + C.cGray + "Updates to server news entries from the database are on a 4 minute refresh cycle!")); - return; - } - else if (args.length == 1 && args[0].equalsIgnoreCase("list")) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages:")); - - newsMang.RetriveNewsEntries(new Callback>() - { - public void run(final HashMap newsEntries) - { - // Order newsEntries set or its output by newsPosition, not hash order... - newsMang.RetrieveMaxNewsPosition(new Callback() - { - public void run(Integer maxPosition) - { - String[] newsStrings = new String[maxPosition]; - for (Iterator iterator = newsEntries.keySet().iterator(); iterator.hasNext();) - { - String newsPosition = iterator.next(); - newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition); - } - - for (int i = 0; i < newsStrings.length; i++) - { - UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}"); - } - } - }); - } - }); - return; - } - else if (args.length >= 2 && args.length <= 128) - { - if (args[0].equals("¢¤₦₣¡₨₥") && args.length == 2) - { - int newsPosition; - try - { - newsPosition = Integer.parseInt(args[1]); - } - catch (Exception exception) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!")); - return; - } - - UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}"); - return; - } - else if (args[0].equalsIgnoreCase("delete") && args.length == 2) - { - final int newsPosition; - try - { - newsPosition = Integer.parseInt(args[1]); - } - catch (Exception exception) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!")); - return; - } - newsMang.DeleteNewsEntry(newsPosition, new Callback() - { - public void run(Boolean success) - { - if (success) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!")); - } - } - }); - return; - } - else if (args[0].equalsIgnoreCase("add")) - { - String newsEntry = ""; - for (int i = 1; i < args.length; i++) - { - newsEntry += args[i] + " "; - } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); - - // Check for 256 character length for MySQL! - if (newsEntry.length() > 256) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!")); - return; - } - - newsMang.AddNewsEntry(newsEntry, new Callback() - { - public void run(Boolean success) - { - if (success) - { - String newsEntry = ""; - for (int i = 1; i < args.length; i++) - { - newsEntry += args[i] + " "; - } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); - - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error adding the news entry to the database!")); - } - } - }); - return; - } - else if (args[0].equalsIgnoreCase("set") && args.length >= 3) - { - final int newsPosition; - String newsEntry = ""; - for (int i = 2; i < args.length; i++) - { - newsEntry += args[i] + " "; - } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); - - // Check for 256 character length for MySQL! - if (newsEntry.length() > 256) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!")); - return; - } - - try - { - newsPosition = Integer.parseInt(args[1]); - } - catch (Exception exception) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!")); - return; - } - newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback() - { - public void run(Boolean success) - { - if (success) - { - String newsEntry = ""; - for (int i = 2; i < args.length; i++) - { - newsEntry += args[i] + " "; - } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); - - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!")); - } - } - }); - return; - } - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); - return; - } - else - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); - return; - } + Plugin.GetNewsManager().Help(caller); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java new file mode 100644 index 000000000..337da8a8c --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java @@ -0,0 +1,45 @@ +package mineplex.hub.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.hub.HubManager; + +public class NewsConfirmCommand extends CommandBase +{ + public NewsConfirmCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "¢¤₦₣¡₨₥"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length == 0 || args.length > 1) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + else + { + int newsPosition; + try + { + newsPosition = Integer.parseInt(args[0]); + } + catch (Exception exception) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!")); + return; + } + + UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}"); + return; + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java new file mode 100644 index 000000000..039de916f --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java @@ -0,0 +1,59 @@ +package mineplex.hub.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.hub.HubManager; +import mineplex.hub.modules.NewsManager; + +public class NewsDeleteCommand extends CommandBase +{ + public NewsDeleteCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "delete"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length == 0 || args.length > 1) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + else + { + NewsManager newsMang = Plugin.GetNewsManager(); + final int newsPosition; + try + { + newsPosition = Integer.parseInt(args[0]); + } + catch (Exception exception) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!")); + return; + } + newsMang.DeleteNewsEntry(newsPosition, new Callback() + { + public void run(Boolean success) + { + if (success) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!")); + } + } + }); + return; + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java new file mode 100644 index 000000000..cc53857ab --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java @@ -0,0 +1,66 @@ +package mineplex.hub.commands; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.hub.HubManager; +import mineplex.hub.modules.NewsManager; + +public class NewsListCommand extends CommandBase +{ + public NewsListCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "list"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length == 0) + { + final NewsManager newsMang = Plugin.GetNewsManager(); + + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages:")); + + newsMang.RetriveNewsEntries(new Callback>() + { + public void run(final HashMap newsEntries) + { + // Order newsEntries set or its output by newsPosition, not hash order... + newsMang.RetrieveMaxNewsPosition(new Callback() + { + public void run(Integer maxPosition) + { + String[] newsStrings = new String[maxPosition]; + for (Iterator iterator = newsEntries.keySet().iterator(); iterator.hasNext();) + { + String newsPosition = iterator.next(); + newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition); + } + + for (int i = 0; i < newsStrings.length; i++) + { + UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}"); + } + } + }); + } + }); + return; + } + else + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java new file mode 100644 index 000000000..ea34f8cd5 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java @@ -0,0 +1,81 @@ +package mineplex.hub.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.hub.HubManager; +import mineplex.hub.modules.NewsManager; + +public class NewsSetCommand extends CommandBase +{ + public NewsSetCommand(HubManager plugin) + { + super(plugin, Rank.ADMIN, "set"); + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null || args.length < 2 || args.length > 128) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + else + { + NewsManager newsMang = Plugin.GetNewsManager(); + + final int newsPosition; + String newsEntry = ""; + for (int i = 1; i < args.length; i++) + { + newsEntry += args[i] + " "; + } + newsEntry = newsEntry.substring(0, newsEntry.length() - 1); + + // Check for 256 character length for MySQL! + if (newsEntry.length() > 256) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!")); + return; + } + + try + { + newsPosition = Integer.parseInt(args[0]); + } + catch (Exception exception) + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!")); + return; + } + newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback() + { + public void run(Boolean success) + { + if (success) + { + String newsEntry = ""; + for (int i = 1; i < args.length; i++) + { + newsEntry += args[i] + " "; + } + newsEntry = newsEntry.substring(0, newsEntry.length() - 1); + + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!")); + } + } + }); + return; + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index e540d04d0..6d67b4986 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -187,6 +188,24 @@ public class NewsManager extends MiniPlugin }); } + public void Help(Player caller, String message) + { + UtilPlayer.message(caller, F.main(_moduleName, "Available news arguments for this command:")); + UtilPlayer.message(caller, F.help(C.cGold + "/news list", "Lists (numbered) stored news messages from database.", Rank.ADMIN)); + UtilPlayer.message(caller, F.help(C.cGold + "/news add ", "Adds specified news entry string to database at end of table.", Rank.ADMIN)); + UtilPlayer.message(caller, F.help(C.cGold + "/news delete #", "Removes specified (numbered) news entry string from database.", Rank.ADMIN)); + UtilPlayer.message(caller, F.help(C.cGold + "/news set # ", "Updates specified (numbered) news entry string in database.", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("*Please Note:", "Updates to server news entries from the database are on a 4 minute refresh cycle!", Rank.ADMIN)); + + if (message != null) + UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); + } + + public void Help(Player caller) + { + Help(caller, null); + } + @EventHandler public void NewsUpdate(UpdateEvent event) {