Fixed merge conflicts
This commit is contained in:
parent
3fab186c09
commit
badfa76166
@ -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;
|
||||
}
|
@ -6,4 +6,5 @@ public class ClansServerStatusMessage extends ClansQueueMessageBody
|
||||
{
|
||||
public String ServerName;
|
||||
public int OpenSlots;
|
||||
public boolean Online;
|
||||
}
|
@ -5,12 +5,12 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-parent</artifactId>
|
||||
<artifactId>mineplex-plugin</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<relativePath>../plugin.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>ClansQueue-Common</name>
|
||||
<name>ClansQueue</name>
|
||||
<artifactId>mineplex-clansqueue</artifactId>
|
||||
|
||||
<dependencies>
|
||||
@ -20,4 +20,29 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<configuration>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>com.mineplex.clansqueue.service.QueueService</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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 <Server>");
|
||||
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();
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -275,6 +275,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> 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<ClientClan> 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<ClientClan> 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<ClientClan> 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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -124,26 +124,31 @@ public class ClansServerPage extends ShopPageBase<ClansTransferManager, ClansSer
|
||||
{
|
||||
ServerInfo serverInfo = getServerInfo(clan.getHomeServer());
|
||||
boolean serverOnline = (serverInfo != null);
|
||||
if (!serverOnline)
|
||||
{
|
||||
System.out.println("Returning null");
|
||||
}
|
||||
String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline";
|
||||
|
||||
String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!";
|
||||
String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer();
|
||||
String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus;
|
||||
String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "");
|
||||
String queue1 = C.cYellow + "Queue Status: " + (_queue.getData(serverInfo).QueuePaused ? C.cRed + "Paused" : C.cGreen + "Active");
|
||||
String queue2 = C.cYellow + "Your Position: " + ((_queue.Get(getPlayer()).TargetServer != null && _queue.Get(getPlayer()).TargetServer.equals(serverInfo.Name)) ? (_queue.Get(getPlayer()).Queued ? C.cGreen + "#" + _queue.Get(getPlayer()).QueuePosition : C.cGray + "Joining...") : C.cGray + "Not Joined");
|
||||
String mode = (serverOnline ? (C.cYellow + "Mode: " + C.cWhite + (serverInfo.Hardcore ? "Hardcore" : "Casual")) : "");
|
||||
String queue1 = (serverOnline ? (C.cYellow + "Queue Status: " + (_queue.getData(serverInfo).QueuePaused ? C.cRed + "Paused" : C.cGreen + "Active")) : "");
|
||||
String queue2 = (serverOnline ? (C.cYellow + "Your Position: " + ((_queue.Get(getPlayer()).TargetServer != null && _queue.Get(getPlayer()).TargetServer.equals(serverInfo.Name)) ? (_queue.Get(getPlayer()).Queued ? C.cGreen + "#" + _queue.Get(getPlayer()).QueuePosition : C.cGray + "Joining...") : C.cGray + "Not Joined")) : "");
|
||||
String change = C.cRed + "Note: " + C.cWhite + "You must leave your Clan to ";
|
||||
String change2 = C.cWhite + "play on a different Clans Server!";
|
||||
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " ", queue1, queue2, " ", change, change2, " "}, 0, true, true);
|
||||
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, mode, " ", queue1, queue2, " ", change, change2, " "}, 0, true, true);
|
||||
addButton(13, shopItem, new JoinServerButton(this, getServerInfo(clan.getHomeServer())));
|
||||
}
|
||||
|
||||
private void buildJoinServer(int slot, ServerInfo server)
|
||||
{
|
||||
String title = C.cGreen + C.Bold + "Join Clans Server!";
|
||||
String desc1 = C.cYellow + "Server Name " + C.cWhite + server.Name;
|
||||
String desc2 = C.cYellow + "Players " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers;
|
||||
String desc3 = C.cYellow + "Mode " + C.cWhite + (server.Hardcore ? "Hardcore" : "Casual");
|
||||
String desc1 = C.cYellow + "Server Name: " + C.cWhite + server.Name;
|
||||
String desc2 = C.cYellow + "Players: " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers;
|
||||
String desc3 = C.cYellow + "Mode: " + C.cWhite + (server.Hardcore ? "Hardcore" : "Casual");
|
||||
String queue1 = C.cYellow + "Queue Status: " + (_queue.getData(server).QueuePaused ? C.cRed + "Paused" : C.cGreen + "Active");
|
||||
String queue2 = C.cYellow + "Your Position: " + ((_queue.Get(getPlayer()).TargetServer != null && _queue.Get(getPlayer()).TargetServer.equals(server.Name)) ? (_queue.Get(getPlayer()).Queued ? C.cGreen + "#" + _queue.Get(getPlayer()).QueuePosition : C.cGray + "Joining...") : C.cGray + "Not Joined");
|
||||
String desc4 = "";
|
||||
@ -176,16 +181,20 @@ public class ClansServerPage extends ShopPageBase<ClansTransferManager, ClansSer
|
||||
{
|
||||
ServerInfo serverInfo = getServerInfo(clan.getHomeServer());
|
||||
boolean serverOnline = (serverInfo != null);
|
||||
if (!serverOnline)
|
||||
{
|
||||
System.out.println("Returning null");
|
||||
}
|
||||
String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline";
|
||||
|
||||
String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!";
|
||||
String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer();
|
||||
String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus;
|
||||
String mode = (serverOnline ? (C.cYellow + "Mode: " + C.cWhite + (serverInfo.Hardcore ? "Hardcore" : "Casual")) : "");
|
||||
String players = C.cYellow + "Players: " + C.cWhite + (serverOnline ? serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "0/0");
|
||||
String queue1 = C.cYellow + "Queue Status: " + (_queue.getData(serverInfo).QueuePaused ? C.cRed + "Paused" : C.cGreen + "Active");
|
||||
String queue2 = C.cYellow + "Your Position: " + ((_queue.Get(getPlayer()).TargetServer != null && _queue.Get(getPlayer()).TargetServer.equals(serverInfo.Name)) ? (_queue.Get(getPlayer()).Queued ? C.cGreen + "#" + _queue.Get(getPlayer()).QueuePosition : C.cGray + "Joining...") : C.cGray + "Not Joined");
|
||||
String mode = C.cYellow + "Mode " + C.cWhite + (serverInfo.Hardcore ? "Hardcore" : "Casual");
|
||||
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, queue1, queue2, mode, " "}, 0, true, true);
|
||||
String queue1 = (serverOnline ? (C.cYellow + "Queue Status: " + (_queue.getData(serverInfo).QueuePaused ? C.cRed + "Paused" : C.cGreen + "Active")) : "");
|
||||
String queue2 = (serverOnline ? (C.cYellow + "Your Position: " + ((_queue.Get(getPlayer()).TargetServer != null && _queue.Get(getPlayer()).TargetServer.equals(serverInfo.Name)) ? (_queue.Get(getPlayer()).Queued ? C.cGreen + "#" + _queue.Get(getPlayer()).QueuePosition : C.cGray + "Joining...") : C.cGray + "Not Joined")) : "");
|
||||
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, mode, " ", queue1, queue2, " "}, 0, true, true);
|
||||
addButton(13, shopItem, new JoinServerButton(this, getServerInfo(clan.getHomeServer())));
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -130,6 +123,12 @@ import mineplex.core.youtube.YoutubeManager;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
|
||||
/**
|
||||
* Main manager for clans hub
|
||||
@ -298,7 +297,8 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
}
|
||||
}
|
||||
|
||||
scoreboard.register(HubScoreboardLine.SERVER_TITLE)
|
||||
scoreboard.register(HubScoreboardLine.START_EMPTY_SPACER)
|
||||
.register(HubScoreboardLine.SERVER_TITLE)
|
||||
.register(HubScoreboardLine.SERVER_NAME)
|
||||
.register(HubScoreboardLine.SERVER_EMPTY_SPACER)
|
||||
.register(HubScoreboardLine.PLAYER_TITLE)
|
||||
@ -309,7 +309,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
.register(HubScoreboardLine.RANK_EMPTY_SPACER)
|
||||
.register(HubScoreboardLine.WEBSITE_TITLE)
|
||||
.register(HubScoreboardLine.WEBSITE_VALUE)
|
||||
.register(HubScoreboardLine.END_EMPTY_SPACER)
|
||||
.recalculate();
|
||||
|
||||
scoreboard.get(HubScoreboardLine.SERVER_TITLE).write(C.cAqua + C.Bold + "Server");
|
||||
|
@ -4,6 +4,7 @@ import mineplex.core.scoreboard.ScoreboardLine;
|
||||
|
||||
public enum HubScoreboardLine implements ScoreboardLine
|
||||
{
|
||||
START_EMPTY_SPACER,
|
||||
SERVER_TITLE,
|
||||
SERVER_NAME,
|
||||
SERVER_EMPTY_SPACER,
|
||||
@ -14,6 +15,5 @@ public enum HubScoreboardLine implements ScoreboardLine
|
||||
RANK_NAME,
|
||||
RANK_EMPTY_SPACER,
|
||||
WEBSITE_TITLE,
|
||||
WEBSITE_VALUE,
|
||||
END_EMPTY_SPACER;
|
||||
WEBSITE_VALUE;
|
||||
}
|
@ -49,6 +49,7 @@ import mineplex.core.portal.Intent;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.portal.events.ServerTransferEvent;
|
||||
import mineplex.core.punish.clans.ClansBanManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class HubQueueManager extends MiniClientPlugin<QueuePlayerData>
|
||||
@ -139,6 +140,7 @@ public class HubQueueManager extends MiniClientPlugin<QueuePlayerData>
|
||||
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,8 +163,11 @@ public class HubQueueManager extends MiniClientPlugin<QueuePlayerData>
|
||||
if (player != null)
|
||||
{
|
||||
Get(player).QueuePosition = 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<QueuePlayerData>
|
||||
|
||||
public void leaveQueue(Player player, boolean informFailure)
|
||||
{
|
||||
if (!Get(player).Queued && informFailure)
|
||||
if (!Get(player).Queued)
|
||||
{
|
||||
if (informFailure)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(getName(), "You are not part of a queue!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
PlayerLeaveQueueMessage message = new PlayerLeaveQueueMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user