From badfa76166fc8968442df64159e8600ce4839897 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 23 Sep 2017 04:02:49 -0400 Subject: [PATCH] Fixed merge conflicts --- .../clansqueue/common/QueueConstant.java | 1 + .../messages/ClansServerStatusMessage.java | 1 + Plugins/Mineplex.ClansQueue/pom.xml | 29 +++++++++++++- .../clansqueue/service/QueueService.java | 5 ++- .../service/commands/CommandSystem.java | 1 + .../service/commands/UnpauseQueueCommand.java | 38 +++++++++++++++++++ .../service/queue/ClansQueueManager.java | 18 +++++---- .../game/clans/clans/ClansManager.java | 5 ++- .../game/clans/items/ItemListener.java | 13 +++++++ .../mineplex/clanshub/ClansServerPage.java | 31 +++++++++------ .../src/mineplex/clanshub/HubManager.java | 17 ++++----- .../mineplex/clanshub/HubScoreboardLine.java | 4 +- .../clanshub/queue/HubQueueManager.java | 14 +++++-- 13 files changed, 140 insertions(+), 37 deletions(-) create mode 100644 Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java index 505022227..241f40ea0 100644 --- a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/QueueConstant.java @@ -4,4 +4,5 @@ public class QueueConstant { public static final String SERVICE_MESSENGER_IDENTIFIER = "Queue System"; public static final int BYPASS_QUEUE_WEIGHT = -1; + public static final int MAX_TRANSFERS_PER_UPDATE = 5; } \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java index 929e084ee..f8e0d7119 100644 --- a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/messages/ClansServerStatusMessage.java @@ -6,4 +6,5 @@ public class ClansServerStatusMessage extends ClansQueueMessageBody { public String ServerName; public int OpenSlots; + public boolean Online; } \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/pom.xml b/Plugins/Mineplex.ClansQueue/pom.xml index e1e058ba4..a202846c3 100644 --- a/Plugins/Mineplex.ClansQueue/pom.xml +++ b/Plugins/Mineplex.ClansQueue/pom.xml @@ -5,12 +5,12 @@ com.mineplex - mineplex-parent + mineplex-plugin dev-SNAPSHOT ../plugin.xml - ClansQueue-Common + ClansQueue mineplex-clansqueue @@ -20,4 +20,29 @@ ${project.version} + + + + org.apache.maven.plugins + maven-shade-plugin + + false + + + com.mineplex.clansqueue.service.QueueService + + + + + + package + + shade + + + + + + diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java index c2168c01e..aea90d00d 100644 --- a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/QueueService.java @@ -26,7 +26,8 @@ public class QueueService { QueueService service = new QueueService(new File("eu.dat").exists()); service.start(); - while (service.isRunning()) {}; + while (service.isRunning()) {} + System.exit(0); } private final Region _region; @@ -63,7 +64,7 @@ public class QueueService messenger.registerListener(QueuePauseUpdateMessage.class, (pause, origin) -> _queueManager.handleQueuePause(pause.ServerName, pause.Paused)); messenger.registerListener(PlayerJoinQueueMessage.class, (join, origin) -> _queueManager.joinQueue(join.TargetServer, origin, join.PlayerUUID, join.PlayerPriority)); messenger.registerListener(PlayerLeaveQueueMessage.class, (leave, origin) -> _queueManager.leaveQueue(leave.TargetServer, leave.PlayerUUID)); - messenger.registerListener(ClansServerStatusMessage.class, (status, origin) -> _queueManager.handleServerUpdate(status.ServerName, status.OpenSlots)); + messenger.registerListener(ClansServerStatusMessage.class, (status, origin) -> _queueManager.handleServerUpdate(status.ServerName, status.OpenSlots, status.Online)); } public ClansQueueManager getQueueManager() diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java index 832a55097..e02409633 100644 --- a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/CommandSystem.java @@ -22,6 +22,7 @@ public class CommandSystem extends Thread _service.registerCommand(new DeleteQueueCommand(_service)); _service.registerCommand(new ListQueuesCommand(_service)); _service.registerCommand(new PauseQueueCommand(_service)); + _service.registerCommand(new UnpauseQueueCommand(_service)); } private boolean matches(String key, String input) diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java new file mode 100644 index 000000000..1f7369362 --- /dev/null +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/commands/UnpauseQueueCommand.java @@ -0,0 +1,38 @@ +package com.mineplex.clansqueue.service.commands; + +import com.mineplex.clansqueue.service.QueueService; +import com.mineplex.clansqueue.service.queue.ClansServer; + +public class UnpauseQueueCommand extends ConsoleCommand +{ + private final QueueService _service; + + public UnpauseQueueCommand(QueueService service) + { + super("unpause", "Resumes an existing queue"); + + _service = service; + } + + @Override + protected void use(String[] arguments) + { + if (arguments.length < 1) + { + addOutput("Usage: pause "); + sendOutput(); + return; + } + ClansServer server = _service.getQueueManager().getLoadedServer(arguments[0]); + if (server == null) + { + addOutput("Server '" + arguments[0] + "' was not found. Run 'list' for a list of servers."); + sendOutput(); + return; + } + + _service.getQueueManager().handleQueuePause(server.getName(), false); + addOutput("Queue unpaused."); + sendOutput(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java index 5c63540b2..bf08084a3 100644 --- a/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java +++ b/Plugins/Mineplex.ClansQueue/src/com/mineplex/clansqueue/service/queue/ClansQueueManager.java @@ -52,6 +52,8 @@ public class ClansQueueManager snapshot.ServerName = queue.getServer().getName(); snapshot.Queue = new HashMap<>(); queue.getPlayers().values().forEach(player -> snapshot.Queue.put(player.PlayerUUID, player.Position)); + + message.Snapshots.add(snapshot); }); return message; @@ -64,7 +66,7 @@ public class ClansQueueManager queues.forEach(q -> { - q.updatePositions(q.getServer().getOpenSlots()); + q.updatePositions(Math.min(q.getServer().getOpenSlots(), QueueConstant.MAX_TRANSFERS_PER_UPDATE)); if (q.getServer().isOnline()) { q.getNextSend().entrySet().forEach(entry -> @@ -125,16 +127,18 @@ public class ClansQueueManager }).setOnline(false); } - public synchronized void handleServerUpdate(String serverName, int openSlots) + public synchronized void handleServerUpdate(String serverName, int openSlots, boolean online) { - _servers.computeIfAbsent(serverName, (name) -> + ClansServer server = _servers.computeIfAbsent(serverName, (name) -> { - ClansServer server = new ClansServer(name); + ClansServer s = new ClansServer(name); - _queues.put(server, new ServerQueue(server)); + _queues.put(s, new ServerQueue(s)); - return server; - }).setOpenSlots(openSlots); + return s; + }); + server.setOpenSlots(openSlots); + server.setOnline(online); } public synchronized void handleQueuePause(String serverName, boolean pause) 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 8c739a2a3..3b78c8dfc 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 @@ -275,6 +275,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat public ClanTips ClanTips; + private boolean _disabling = false; + // Spawn area public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager) @@ -525,7 +527,6 @@ public class ClansManager extends MiniClientPlugin implements IRelat private void generatePermissions() { - PermissionGroup.MOD.revokePermission(Teleport.Perm.TELEPORT_COMMAND); PermissionGroup.ADMIN.setPermission(Teleport.Perm.TELEPORT_COMMAND, true, true); @@ -1313,6 +1314,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat // disable event to WorldEventManager // This is so that we can prevent any permanent world changes with // events + _disabling = true; _blockRestore.onDisable(); _worldEvent.onDisable(); _goldManager.onDisable(); @@ -1350,6 +1352,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat ClansServerStatusMessage message = new ClansServerStatusMessage(); message.ServerName = UtilServer.getServerName(); message.OpenSlots = Math.max(0, Bukkit.getMaxPlayers() - online); + message.Online = !_restartManager.isRestarting() && !_disabling; ClansQueueMessenger.getMessenger(UtilServer.getServerName()).transmitMessage(message, QueueConstant.SERVICE_MESSENGER_IDENTIFIER); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java index bee703e6e..0467948bd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java @@ -12,6 +12,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; @@ -180,6 +181,18 @@ public class ItemListener implements Listener, Runnable } } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onJoin(PlayerJoinEvent event) + { + GearManager.getInstance().runSyncLater(() -> + { + if (event.getPlayer().isOnline()) + { + getGear(event.getPlayer()).updateCache(true); + } + }, 5); + } + @EventHandler(priority = EventPriority.MONITOR) public void onRespawn(PlayerRespawnEvent event) { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java index 62620ca77..3e301fe9b 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -124,26 +124,31 @@ public class ClansServerPage extends ShopPageBase @@ -139,6 +140,7 @@ public class HubQueueManager extends MiniClientPlugin Player player = Bukkit.getPlayer(callback.PlayerUUID); if (player != null) { + Get(player).Queued = false; player.leaveVehicle(); player.eject(); _portal.sendPlayerToServer(player, callback.TargetServer, Intent.FORCE_TRANSFER); @@ -161,7 +163,10 @@ public class HubQueueManager extends MiniClientPlugin if (player != null) { Get(player).QueuePosition = entry.getValue(); - UtilPlayer.message(player, F.main(getName(), "Your position: " + F.greenElem("#" + entry.getValue()))); + if (Recharge.Instance.use(player, "Queue Status Update", 7000, false, false)) + { + UtilPlayer.message(player, F.main(getName(), "Your position: " + F.greenElem("#" + entry.getValue()))); + } } }); }); @@ -318,9 +323,12 @@ public class HubQueueManager extends MiniClientPlugin public void leaveQueue(Player player, boolean informFailure) { - if (!Get(player).Queued && informFailure) + if (!Get(player).Queued) { - UtilPlayer.message(player, F.main(getName(), "You are not part of a queue!")); + if (informFailure) + { + UtilPlayer.message(player, F.main(getName(), "You are not part of a queue!")); + } return; } PlayerLeaveQueueMessage message = new PlayerLeaveQueueMessage();