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

This commit is contained in:
AlexTheCoder 2017-02-09 23:05:32 -05:00 committed by cnr
parent 1736b198f2
commit 11791bc461
9 changed files with 63 additions and 24 deletions

View File

@ -21,7 +21,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import mineplex.core.command.CommandCenter; import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C; 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.friend.data.FriendStatus;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemLayout; import mineplex.core.itemstack.ItemLayout;
import mineplex.core.portal.Intent;
import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.IButton;
import net.minecraft.server.v1_8_R3.EntityPlayer;
public class FriendsGUI implements Listener public class FriendsGUI implements Listener
{ {
@ -153,7 +152,6 @@ public class FriendsGUI implements Listener
AddButton(slot, builder.build(), new IButton() AddButton(slot, builder.build(), new IButton()
{ {
@Override @Override
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
@ -299,11 +297,10 @@ public class FriendsGUI implements Listener
AddButton(slot, builder.build(), new IButton() AddButton(slot, builder.build(), new IButton()
{ {
@Override @Override
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
_plugin.getPortal().sendPlayerToServer(player, serverName, Intent.PLAYER_REQUEST); CommandCenter.Instance.onPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/server " + serverName));
} }
}); });
} }

View File

@ -83,6 +83,10 @@ public class Portal extends MiniPlugin
public void sendAllPlayersToGenericServer(GenericServer hub, Intent kick) 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) public void sendPlayerToGenericServer(Player player, GenericServer genericServer, Intent intent)
@ -125,6 +129,11 @@ public class Portal extends MiniPlugin
runSync(() -> 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)) if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA))
{ {
sendPlayer(player, serverName); sendPlayer(player, serverName);

View File

@ -1219,6 +1219,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_netherManager.onDisable(); _netherManager.onDisable();
_safeLog.onDisable(); _safeLog.onDisable();
_restartManager.onDisable(); _restartManager.onDisable();
_observerManager.onDisable();
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View File

@ -26,6 +26,7 @@ import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.ban.ClansBanManager;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
import mineplex.game.clans.restart.RestartManager;
public class SafeLog extends MiniPlugin public class SafeLog extends MiniPlugin
{ {
@ -69,6 +70,11 @@ public class SafeLog extends MiniPlugin
isSafeLog = true; isSafeLog = true;
} }
if (Managers.get(RestartManager.class).isRestarting())
{
isSafeLog = true;
}
if (!isSafeLog) if (!isSafeLog)
{ {
if (!_clansManager.getIncognitoManager().Get(player).Status) if (!_clansManager.getIncognitoManager().Get(player).Status)
@ -156,5 +162,4 @@ public class SafeLog extends MiniPlugin
{ {
onPlayerJoin(event.getPlayer()); onPlayerJoin(event.getPlayer());
} }
} }

View File

@ -239,5 +239,4 @@ public class CombatLogNPC
{ {
_lastDamager = damager; _lastDamager = damager;
} }
} }

View File

@ -5,8 +5,13 @@ import java.util.LinkedList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; 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 org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -23,6 +28,7 @@ import mineplex.core.slack.SlackTeam;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
public class RestartManager extends MiniPlugin public class RestartManager extends MiniPlugin
@ -104,6 +110,11 @@ public class RestartManager extends MiniPlugin
return restart; return restart;
} }
public boolean isRestarting()
{
return _restarting;
}
@Override @Override
public void disable() public void disable()
{ {
@ -120,6 +131,24 @@ public class RestartManager extends MiniPlugin
_restartTime = System.currentTimeMillis() + 120000; _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 @EventHandler
public void checkRestart(UpdateEvent event) public void checkRestart(UpdateEvent event)
{ {
@ -146,6 +175,7 @@ public class RestartManager extends MiniPlugin
if (System.currentTimeMillis() >= _restartTime) if (System.currentTimeMillis() >= _restartTime)
{ {
_restarting = true; _restarting = true;
NPCManager.getInstance().disable();
Portal.getInstance().sendAllPlayersToGenericServer(GenericServer.CLANS_HUB, Intent.KICK); Portal.getInstance().sendAllPlayersToGenericServer(GenericServer.CLANS_HUB, Intent.KICK);
runSyncLater(() -> runSyncLater(() ->
{ {

View File

@ -6,6 +6,14 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; 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.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -16,13 +24,10 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcDamageByEntityEvent;
import mineplex.core.npc.event.NpcInteractEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager; import mineplex.core.party.PartyManager;
import mineplex.core.portal.Intent; import mineplex.core.portal.Intent;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.core.repository.tokens.SimpleClanToken; import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
@ -30,14 +35,6 @@ import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.servers.ServerManager; 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 * Server selection controller for clans
*/ */
@ -93,7 +90,7 @@ public class ClansTransferManager extends MiniDbClientPlugin<SimpleClanToken>
{ {
for (ServerInfo server : _servers.values()) for (ServerInfo server : _servers.values())
{ {
if (server.Name.equalsIgnoreCase(name)) if (server.Name.equalsIgnoreCase(name) && !server.MOTD.equalsIgnoreCase("Restarting soon"))
{ {
return server; return server;
} }
@ -112,6 +109,7 @@ public class ClansTransferManager extends MiniDbClientPlugin<SimpleClanToken>
{ {
ServerInfo info = new ServerInfo(); ServerInfo info = new ServerInfo();
info.Name = server.getName(); info.Name = server.getName();
info.MOTD = server.getMotd();
info.CurrentPlayers = server.getPlayerCount(); info.CurrentPlayers = server.getPlayerCount();
info.MaxPlayers = server.getMaxPlayerCount(); info.MaxPlayers = server.getMaxPlayerCount();
_servers.put(server, info); _servers.put(server, info);
@ -154,7 +152,6 @@ public class ClansTransferManager extends MiniDbClientPlugin<SimpleClanToken>
}); });
} }
@SuppressWarnings("rawtypes")
@EventHandler @EventHandler
public void refreshPages(UpdateEvent event) public void refreshPages(UpdateEvent event)
{ {

View File

@ -6,6 +6,7 @@ package mineplex.clanshub;
public class ServerInfo public class ServerInfo
{ {
public String Name; public String Name;
public String MOTD;
public int CurrentPlayers = 0; public int CurrentPlayers = 0;
public int MaxPlayers = 0; public int MaxPlayers = 0;