From 890c9d59e1f6760610573440fdbff815c4dc1b70 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 3 Sep 2015 09:38:02 -0700 Subject: [PATCH 1/2] Fixed loading window bug. Added default rank for CoreClient in case of bugged login. --- .../Mineplex.Core/src/mineplex/core/account/CoreClient.java | 3 +++ .../src/mineplex/core/account/CoreClientManager.java | 3 +-- .../src/mineplex/core/gui/pages/LoadingWindow.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 9d1c4c3b0..156f18867 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -61,6 +61,9 @@ public class CoreClient public Rank GetRank() { + if (_rank == null) + _rank = Rank.ALL; + return _rank; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index efb8646a9..9fbd04fc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -125,7 +125,6 @@ public class CoreClientManager extends MiniPlugin if (client == null) { client = new CoreClient(name); - client.SetRank(Rank.ALL); } return client; @@ -305,7 +304,7 @@ public class CoreClientManager extends MiniPlugin TimingManager.stop(client.GetPlayerName() + " GetClient."); token = gson.fromJson(response, ClientToken.class); - + client.SetRank(Rank.valueOf(token.Rank)); // _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java index 6398b4e6b..3546d17cc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gui/pages/LoadingWindow.java @@ -151,7 +151,7 @@ public class LoadingWindow implements Runnable, Listener { { Player player = Bukkit.getPlayer(_playersUUID); - if (player == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) { + if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) { end(); return; } From 921292a5c67fd70165f9527551f4f265d7c2f378 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 3 Sep 2015 09:38:26 -0700 Subject: [PATCH 2/2] Added timings capture and server log copy on server kill inside server monitor. --- .../mineplex/servermonitor/ServerMonitor.java | 154 +++++++++++++++--- 1 file changed, 133 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 511f30d41..ca9557402 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -16,6 +16,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Timer; +import java.util.TimerTask; import java.util.logging.FileHandler; import java.util.logging.Logger; @@ -42,10 +44,12 @@ public class ServerMonitor private static Map _serverGroupMap = null; private static List _dedicatedServers = null; private static HashSet _deadServers = new HashSet(); + private static HashSet _delayedKill = new HashSet(); private static HashSet _laggyServers = new HashSet(); private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); private static Logger _logger = Logger.getLogger("ServerMonitor"); + private static Timer _timer = new Timer(); private static int _totalPlayers = 0; private static Region _region; @@ -124,12 +128,15 @@ public class ServerMonitor for (MinecraftServer minecraftServer : _serverStatuses) { - if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0)) + if (!ignoreServer(minecraftServer.getGroup())) { - killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), minecraftServer.getPlayerCount(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true); - - handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup())); - continue; + if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0)) + { + killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), minecraftServer.getPlayerCount(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true); + + handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup())); + continue; + } } for (DedicatedServer server : _dedicatedServers) @@ -202,6 +209,9 @@ public class ServerMonitor for (ServerGroup groupStatus : _serverGroups) { + if (ignoreServer(groupStatus.getName())) + continue; + NautHashMap serverMap = new NautHashMap(); for (Iterator serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();) @@ -226,17 +236,6 @@ public class ServerMonitor exception.printStackTrace(); } } - - /* - if (groupStatus.getHost() == null || groupStatus.getHost().isEmpty()) - { - if (groupStatus.getName().startsWith("0")) - { - int serverCount = groupStatus.getServers().size(); - log(groupStatus.getName() + " : " + groupStatus.getPlayerCount() + " players on " + serverCount + " servers " + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredCpu() / totalCPU)) + "% CPU," + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredRam() / totalRAM)) + "% RAM", false); - } - } - */ } HashSet onlineServers = new HashSet(); @@ -386,21 +385,35 @@ public class ServerMonitor deadServers.addAll(_deadServers); _deadServers.clear(); - for (MinecraftServer deadServer : _repository.getDeadServers()) + for (final MinecraftServer deadServer : _repository.getDeadServers()) { if (deadServer.getUptime() <= 10 || ignoreServer(deadServer.getGroup())) continue; if (_count == 0 || deadServers.contains(deadServer.getName())) { + copyServerLog(deadServer); killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup())); } - else - { - _deadServers.add(deadServer.getName()); - log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + else if (!_delayedKill.contains(deadServer.getName())) + { + startTimingReport(deadServer); + + _timer.schedule(new TimerTask() + { + public void run() + { + _deadServers.add(deadServer.getName()); + _delayedKill.remove(deadServer.getName()); + + stopTimingReport(deadServer); + log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + } + }, 20 * 1000); + + _delayedKill.add(deadServer.getName()); } } } @@ -653,6 +666,105 @@ public class ServerMonitor killServer(serverToKill.getName(), serverToKill.getPublicAddress(), serverToKill.getPlayerCount(), message, true); } + private static void startTimingReport(final MinecraftServer server) + { + if (_debug) + return; + + String cmd = "/home/mineplex/remoteStartTiming.sh"; + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (error) + log("[TIMING START] Errored " + server.getName() + "(" + server.getPublicAddress() + ")"); + else + log("[TIMING START] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")"); + + } + }); + + try + { + pr.join(100); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + + if (!pr.isDone()) + _processes.add(pr); + } + + private static void stopTimingReport(final MinecraftServer server) + { + if (_debug) + return; + + String cmd = "/home/mineplex/remoteStopTiming.sh"; + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (error) + log("[TIMING PASTE] Errored " + server.getName() + "(" + server.getPublicAddress() + ")"); + else + log("[TIMING PASTE] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")"); + + } + }); + + try + { + pr.join(100); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + + if (!pr.isDone()) + _processes.add(pr); + } + + private static void copyServerLog(final MinecraftServer server) + { + if (_debug) + return; + + String cmd = "/home/mineplex/easyRemoteCopyLog.sh"; + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (error) + log("[COPY LOG] Errored " + server.getName() + "(" + server.getPublicAddress() + ")"); + else + log("[COPY LOG] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")"); + + } + }); + + try + { + pr.join(100); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + + if (!pr.isDone()) + _processes.add(pr); + } + private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free) { if (_debug)