From 78d94320a87e596161508da29b8f6d15e872efe8 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 23 Dec 2014 22:55:07 +1100 Subject: [PATCH 1/3] fixed reciptient of message --- .../game/arcade/gui/privateServer/button/KillButton.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java index 3be667314..af81643bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java @@ -29,8 +29,8 @@ public class KillButton implements IButton { for (Player other : UtilServer.getPlayers()) { - UtilPlayer.message(player, C.cGold + C.Bold + "The host has closed this Mineplex Private Server."); - other.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + UtilPlayer.message(other, C.cGold + C.Bold + "The host has closed this Mineplex Private Server."); + other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); _arcade.GetPortal().SendPlayerToServer(other, "Lobby"); } _manager.setHostExpired(true); From f4c5922b050b81545feba9db6529d2b8ceeeff00 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 23 Dec 2014 23:17:21 +1100 Subject: [PATCH 2/3] added messages for when server is expired --- .../gui/privateServer/button/KillButton.java | 8 +---- .../game/arcade/managers/GameHostManager.java | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java index af81643bf..08dc8e54b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/KillButton.java @@ -27,13 +27,7 @@ public class KillButton implements IButton { if (clickType == clickType.SHIFT_RIGHT) { - for (Player other : UtilServer.getPlayers()) - { - UtilPlayer.message(other, C.cGold + C.Bold + "The host has closed this Mineplex Private Server."); - other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); - _arcade.GetPortal().SendPlayerToServer(other, "Lobby"); - } - _manager.setHostExpired(true); + _manager.setHostExpired(true, "The host has closed this Mineplex Private Server."); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 517aef484..32f9c33ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -158,16 +158,44 @@ public class GameHostManager implements Listener } } + + @EventHandler + public void updateHostExpired(UpdateEvent event) + { + if (!isPrivateServer()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + if (Manager.GetGame() != null && Manager.GetGame().GetState() != GameState.Recruit) + return; + + if (UtilTime.elapsed(_lastOnline, _expireTime)) + setHostExpired(true, Manager.GetServerConfig().HostName + " has abandoned the server. Thanks for playing!"); + + else if (UtilTime.elapsed(_serverStartTime, _serverExpireTime)) + setHostExpired(true, "This server has expired! Thank you for playing!"); + } + + public boolean isHostExpired() { - if (Manager.GetHost() == null || Manager.GetHost().length() == 0) + if (!isPrivateServer()) return false; - return _hostExpired || UtilTime.elapsed(_lastOnline, _expireTime) || UtilTime.elapsed(_serverStartTime, _serverExpireTime); + return _hostExpired; } - public void setHostExpired(boolean expired) + public void setHostExpired(boolean expired, String string) { + for (Player other : UtilServer.getPlayers()) + { + UtilPlayer.message(other, C.cGold + C.Bold + string); + other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + Manager.GetPortal().SendPlayerToServer(other, "Lobby"); + } + _hostExpired = expired; } From 78977788a1914d2225df18a651607336e9b5f635 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 23 Dec 2014 23:18:29 +1100 Subject: [PATCH 3/3] fixed bug --- .../src/nautilus/game/arcade/managers/GameHostManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 32f9c33ec..ea59779b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -171,6 +171,9 @@ public class GameHostManager implements Listener if (Manager.GetGame() != null && Manager.GetGame().GetState() != GameState.Recruit) return; + if (_hostExpired) + return; + if (UtilTime.elapsed(_lastOnline, _expireTime)) setHostExpired(true, Manager.GetServerConfig().HostName + " has abandoned the server. Thanks for playing!");