From 11791bc461906878adb16045e48082e2522e38b6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 9 Feb 2017 23:05:32 -0500 Subject: [PATCH] Block joining clans servers via friends, block joining of clans servers that are restarting, clean up log mob armor stands on restart, take staff out of observer mode on restart --- .../mineplex/core/friend/ui/FriendsGUI.java | 7 ++--- .../src/mineplex/core/portal/Portal.java | 11 ++++++- .../game/clans/clans/ClansManager.java | 1 + .../game/clans/gameplay/safelog/SafeLog.java | 9 ++++-- .../gameplay/safelog/npc/CombatLogNPC.java | 3 +- .../gameplay/safelog/npc/NPCManager.java | 2 +- .../game/clans/restart/RestartManager.java | 30 +++++++++++++++++++ .../clanshub/ClansTransferManager.java | 23 +++++++------- .../src/mineplex/clanshub/ServerInfo.java | 1 + 9 files changed, 63 insertions(+), 24 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java index c94c5ff98..e20fe63b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java @@ -21,7 +21,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import net.minecraft.server.v1_8_R3.EntityPlayer; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; @@ -34,8 +33,8 @@ import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemLayout; -import mineplex.core.portal.Intent; import mineplex.core.shop.item.IButton; +import net.minecraft.server.v1_8_R3.EntityPlayer; public class FriendsGUI implements Listener { @@ -153,7 +152,6 @@ public class FriendsGUI implements Listener AddButton(slot, builder.build(), new IButton() { - @Override public void onClick(Player player, ClickType clickType) { @@ -299,11 +297,10 @@ public class FriendsGUI implements Listener AddButton(slot, builder.build(), new IButton() { - @Override public void onClick(Player player, ClickType clickType) { - _plugin.getPortal().sendPlayerToServer(player, serverName, Intent.PLAYER_REQUEST); + CommandCenter.Instance.onPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/server " + serverName)); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 47300a0e7..5d0d5eb88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -83,6 +83,10 @@ public class Portal extends MiniPlugin public void sendAllPlayersToGenericServer(GenericServer hub, Intent kick) { + for (Player player : UtilServer.GetPlayers()) + { + sendPlayerToGenericServer(player, hub, kick); + } } public void sendPlayerToGenericServer(Player player, GenericServer genericServer, Intent intent) @@ -122,9 +126,14 @@ public class Portal extends MiniPlugin if (server == null) return; - + runSync(() -> { + if (server.getGroup().equalsIgnoreCase("Clans") && server.getMotd().equalsIgnoreCase("Restarting soon")) + { + UtilPlayer.message(player, F.main(getName(), C.cGold + "serverName" + C.cRed + " is restarting!")); + return; + } if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) { sendPlayer(player, serverName); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 864afce86..989eb95b7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1219,6 +1219,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _netherManager.onDisable(); _safeLog.onDisable(); _restartManager.onDisable(); + _observerManager.onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index 93838045b..44efed198 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -26,6 +26,7 @@ import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; +import mineplex.game.clans.restart.RestartManager; public class SafeLog extends MiniPlugin { @@ -69,6 +70,11 @@ public class SafeLog extends MiniPlugin isSafeLog = true; } + if (Managers.get(RestartManager.class).isRestarting()) + { + isSafeLog = true; + } + if (!isSafeLog) { if (!_clansManager.getIncognitoManager().Get(player).Status) @@ -156,5 +162,4 @@ public class SafeLog extends MiniPlugin { onPlayerJoin(event.getPlayer()); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index 60eac7a0f..24417d878 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -239,5 +239,4 @@ public class CombatLogNPC { _lastDamager = damager; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java index 186433d54..ef71f42d4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java @@ -256,4 +256,4 @@ public class NPCManager extends MiniPlugin return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index 15a29eb5c..52571a49a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -5,8 +5,13 @@ import java.util.LinkedList; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -23,6 +28,7 @@ import mineplex.core.slack.SlackTeam; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin @@ -104,6 +110,11 @@ public class RestartManager extends MiniPlugin return restart; } + public boolean isRestarting() + { + return _restarting; + } + @Override public void disable() { @@ -120,6 +131,24 @@ public class RestartManager extends MiniPlugin _restartTime = System.currentTimeMillis() + 120000; } + @EventHandler(priority = EventPriority.HIGHEST) + public void reflectMotd(ServerListPingEvent event) + { + if (_restarting) + { + event.setMotd("Restarting soon"); + } + } + + @EventHandler + public void blockLogin(PlayerLoginEvent event) + { + if (_restarting) + { + event.disallow(Result.KICK_OTHER, C.cRed + "This server is restarting!"); + } + } + @EventHandler public void checkRestart(UpdateEvent event) { @@ -146,6 +175,7 @@ public class RestartManager extends MiniPlugin if (System.currentTimeMillis() >= _restartTime) { _restarting = true; + NPCManager.getInstance().disable(); Portal.getInstance().sendAllPlayersToGenericServer(GenericServer.CLANS_HUB, Intent.KICK); runSyncLater(() -> { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java index d98215e77..4bbbf3c9d 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansTransferManager.java @@ -6,6 +6,14 @@ import java.util.HashMap; import java.util.List; import java.util.UUID; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; + import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.F; @@ -16,13 +24,10 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent; -import mineplex.core.party.Lang; -import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; import mineplex.core.recharge.Recharge; -import mineplex.core.shop.page.ShopPageBase; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.core.repository.tokens.SimpleClanToken; @@ -30,14 +35,6 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityPortalEnterEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.common.collect.Lists; - /** * Server selection controller for clans */ @@ -93,7 +90,7 @@ public class ClansTransferManager extends MiniDbClientPlugin { for (ServerInfo server : _servers.values()) { - if (server.Name.equalsIgnoreCase(name)) + if (server.Name.equalsIgnoreCase(name) && !server.MOTD.equalsIgnoreCase("Restarting soon")) { return server; } @@ -112,6 +109,7 @@ public class ClansTransferManager extends MiniDbClientPlugin { ServerInfo info = new ServerInfo(); info.Name = server.getName(); + info.MOTD = server.getMotd(); info.CurrentPlayers = server.getPlayerCount(); info.MaxPlayers = server.getMaxPlayerCount(); _servers.put(server, info); @@ -154,7 +152,6 @@ public class ClansTransferManager extends MiniDbClientPlugin }); } - @SuppressWarnings("rawtypes") @EventHandler public void refreshPages(UpdateEvent event) { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java index 1bb5643db..e51c34ff6 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ServerInfo.java @@ -6,6 +6,7 @@ package mineplex.clanshub; public class ServerInfo { public String Name; + public String MOTD; public int CurrentPlayers = 0; public int MaxPlayers = 0;