Make a start on the new server selection menu
This commit is contained in:
parent
bffd474322
commit
304833dbae
@ -11,19 +11,23 @@ public class GameInfo
|
|||||||
return Constants.GSON.fromJson(json, GameInfo.class);
|
return Constants.GSON.fromJson(json, GameInfo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String _game, _mode, _map, _serverType;
|
private final String _game, _mode, _map;
|
||||||
private final int _timer;
|
private final int _timer;
|
||||||
private final String[] _votingOn;
|
private final String[] _votingOn;
|
||||||
private final PermissionGroup _hostRank;
|
private final PermissionGroup _hostRank;
|
||||||
private final GameDisplayStatus _status;
|
private final GameDisplayStatus _status;
|
||||||
private final GameJoinStatus _joinable;
|
private final GameJoinStatus _joinable;
|
||||||
|
|
||||||
public GameInfo(String game, String mode, String map, String serverType, int timer, String[] votingOn, PermissionGroup hostRank, GameDisplayStatus status, GameJoinStatus joinable)
|
public GameInfo()
|
||||||
|
{
|
||||||
|
this(null, null, null, -1, new String[0], null, GameDisplayStatus.CLOSING, GameJoinStatus.CLOSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameInfo(String game, String mode, String map, int timer, String[] votingOn, PermissionGroup hostRank, GameDisplayStatus status, GameJoinStatus joinable)
|
||||||
{
|
{
|
||||||
_game = game;
|
_game = game;
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
_map = map;
|
_map = map;
|
||||||
_serverType = serverType;
|
|
||||||
_timer = timer;
|
_timer = timer;
|
||||||
_votingOn = votingOn;
|
_votingOn = votingOn;
|
||||||
_hostRank = hostRank;
|
_hostRank = hostRank;
|
||||||
@ -46,11 +50,6 @@ public class GameInfo
|
|||||||
return _map;
|
return _map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerType()
|
|
||||||
{
|
|
||||||
return _serverType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTimer()
|
public int getTimer()
|
||||||
{
|
{
|
||||||
return _timer;
|
return _timer;
|
||||||
|
@ -16,7 +16,6 @@ import mineplex.core.MiniPlugin;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.common.Constants;
|
import mineplex.core.common.Constants;
|
||||||
import mineplex.core.common.util.Callback;
|
|
||||||
import mineplex.core.monitor.LagMeter;
|
import mineplex.core.monitor.LagMeter;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -100,23 +99,6 @@ public class ServerStatusManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveServerStatuses(final Callback<Collection<MinecraftServer>> callback)
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (callback != null)
|
|
||||||
{
|
|
||||||
callback.run(_repository.getServerStatuses());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void saveServerStatus(UpdateEvent event)
|
public void saveServerStatus(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -189,18 +171,14 @@ public class ServerStatusManager extends MiniPlugin
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveServerGroups(final Callback<Collection<ServerGroup>> callback)
|
public Collection<ServerGroup> retrieveServerGroups()
|
||||||
{
|
{
|
||||||
if (!_enabled)
|
return _enabled ? _repository.getServerGroups(null) : null;
|
||||||
return;
|
|
||||||
|
|
||||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), () ->
|
|
||||||
{
|
|
||||||
if (callback != null)
|
|
||||||
{
|
|
||||||
callback.run(_repository.getServerGroups(null));
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
public Collection<MinecraftServer> retrieveServerStatuses()
|
||||||
|
{
|
||||||
|
return _enabled ? _repository.getServerStatuses() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region getRegion()
|
public Region getRegion()
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.world;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,9 +28,11 @@ public class MineplexWorld
|
|||||||
_ironLocations = new LinkedHashMap<>();
|
_ironLocations = new LinkedHashMap<>();
|
||||||
_goldLocations = new LinkedHashMap<>();
|
_goldLocations = new LinkedHashMap<>();
|
||||||
_spongeLocations = new LinkedHashMap<>();
|
_spongeLocations = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
loadWorldConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWorldConfig()
|
private void loadWorldConfig()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -237,16 +238,16 @@ public class MineplexWorld
|
|||||||
|
|
||||||
public Map<String, List<Location>> getIronLocations()
|
public Map<String, List<Location>> getIronLocations()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableMap(_ironLocations);
|
return _ironLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<Location>> getGoldLocations()
|
public Map<String, List<Location>> getGoldLocations()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableMap(_goldLocations);
|
return _goldLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<Location>> getSpongeLocations()
|
public Map<String, List<Location>> getSpongeLocations()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableMap(_spongeLocations);
|
return _spongeLocations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,6 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.core.world.MineplexWorld;
|
import mineplex.core.world.MineplexWorld;
|
||||||
import mineplex.core.youtube.YoutubeManager;
|
import mineplex.core.youtube.YoutubeManager;
|
||||||
import mineplex.hub.commands.GadgetToggle;
|
import mineplex.hub.commands.GadgetToggle;
|
||||||
import mineplex.hub.commands.ListCommand;
|
|
||||||
import mineplex.hub.doublejump.JumpManager;
|
import mineplex.hub.doublejump.JumpManager;
|
||||||
import mineplex.hub.gimmicks.AdminPunch;
|
import mineplex.hub.gimmicks.AdminPunch;
|
||||||
import mineplex.hub.gimmicks.SecretAreas;
|
import mineplex.hub.gimmicks.SecretAreas;
|
||||||
@ -166,7 +165,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
|||||||
World world = Bukkit.getWorld("world");
|
World world = Bukkit.getWorld("world");
|
||||||
|
|
||||||
_worldData = new MineplexWorld(world);
|
_worldData = new MineplexWorld(world);
|
||||||
_worldData.loadWorldConfig();
|
|
||||||
_spawn = _worldData.getSpongeLocation("SPAWN");
|
_spawn = _worldData.getSpongeLocation("SPAWN");
|
||||||
_lookAt = _worldData.getSpongeLocations("LOOK_AT");
|
_lookAt = _worldData.getSpongeLocations("LOOK_AT");
|
||||||
|
|
||||||
@ -314,7 +312,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
|||||||
public void addCommands()
|
public void addCommands()
|
||||||
{
|
{
|
||||||
addCommand(new GadgetToggle(this));
|
addCommand(new GadgetToggle(this));
|
||||||
addCommand(new ListCommand(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
@ -1,136 +0,0 @@
|
|||||||
package mineplex.hub.commands;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.Managers;
|
|
||||||
import mineplex.core.command.CommandBase;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.hub.HubManager;
|
|
||||||
import mineplex.hub.server.ServerInfo;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists player and version distributions
|
|
||||||
*/
|
|
||||||
public class ListCommand extends CommandBase<HubManager>
|
|
||||||
{
|
|
||||||
private ServerManager _serverManager;
|
|
||||||
|
|
||||||
public ListCommand(HubManager plugin)
|
|
||||||
{
|
|
||||||
super(plugin, HubManager.Perm.LIST_COMMAND, "list");
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServerManager getServerManager()
|
|
||||||
{
|
|
||||||
if (_serverManager == null)
|
|
||||||
{
|
|
||||||
_serverManager = Managers.require(ServerManager.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _serverManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void Execute(Player player, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length == 0)
|
|
||||||
{
|
|
||||||
reply(player, "List", "There are " + C.cGreen + Bukkit.getOnlinePlayers().size() +
|
|
||||||
C.cGray + " players online.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[0].toLowerCase())
|
|
||||||
{
|
|
||||||
case "network": // Lists the player distribution across the network
|
|
||||||
network(player);
|
|
||||||
return;
|
|
||||||
case "group": // Lists the player distribution across a group
|
|
||||||
group(player, args);
|
|
||||||
return;
|
|
||||||
case "servers": // Lists the available servers
|
|
||||||
ServerManager manager = Managers.get(ServerManager.class);
|
|
||||||
Set<String> allServers = manager.getAllServers();
|
|
||||||
|
|
||||||
reply(player, "List", "Available servers: " + allServers);
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
reply(player, "List", "Unknown directive: " + args[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void network(Player player)
|
|
||||||
{
|
|
||||||
int total = 0;
|
|
||||||
int maxTotal = 0;
|
|
||||||
|
|
||||||
ServerManager manager = getServerManager();
|
|
||||||
Set<String> groups = manager.getServerGroups();
|
|
||||||
Map<String, Integer> players = new HashMap<>();
|
|
||||||
|
|
||||||
for (String group : groups)
|
|
||||||
{
|
|
||||||
int groupCount = 0;
|
|
||||||
|
|
||||||
Collection<ServerInfo> servers = manager.getServerList(group);
|
|
||||||
for (ServerInfo info : servers)
|
|
||||||
{
|
|
||||||
groupCount += info.CurrentPlayers;
|
|
||||||
total += info.CurrentPlayers;
|
|
||||||
maxTotal += info.MaxPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
players.put(group, groupCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
reply(player, "List", "Network-wide player count:");
|
|
||||||
|
|
||||||
for (Map.Entry<String, Integer> entry : players.entrySet())
|
|
||||||
{
|
|
||||||
if (entry.getValue() == 0) continue;
|
|
||||||
|
|
||||||
reply(player, "List", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen +
|
|
||||||
entry.getValue() + C.cGray + " online");
|
|
||||||
}
|
|
||||||
|
|
||||||
reply(player, "List", "Total: " + C.cGreen + total + C.cGray + " / " + C.cGreen + maxTotal);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void group(Player player, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
reply(player, "List", "You must specify a server group!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerManager manager = Managers.get(ServerManager.class);
|
|
||||||
Set<String> allServers = manager.getAllServers();
|
|
||||||
|
|
||||||
List<ServerInfo> coll = new ArrayList<>();
|
|
||||||
for (String server : allServers)
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase("all") || server.toLowerCase().startsWith(args[1].toLowerCase()))
|
|
||||||
coll.add(manager.getServerInfo(server));
|
|
||||||
}
|
|
||||||
|
|
||||||
reply(player, "List", "Server info for group " + C.cBlue + args[1] + C.cGray + ":");
|
|
||||||
|
|
||||||
for (ServerInfo info : coll)
|
|
||||||
{
|
|
||||||
String line = C.cYellow + info.Name + C.cGray + ": " + info.CurrentPlayers + "/" + info.MaxPlayers;
|
|
||||||
reply(player, "List", line);
|
|
||||||
}
|
|
||||||
|
|
||||||
reply(player,"List", C.cYellow + "---------------");
|
|
||||||
}
|
|
||||||
}
|
|
86
Plugins/Mineplex.Hub/src/mineplex/hub/server/GameServer.java
Normal file
86
Plugins/Mineplex.Hub/src/mineplex/hub/server/GameServer.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package mineplex.hub.server;
|
||||||
|
|
||||||
|
import mineplex.core.game.status.GameInfo;
|
||||||
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
|
|
||||||
|
public class GameServer
|
||||||
|
{
|
||||||
|
|
||||||
|
private MinecraftServer _server;
|
||||||
|
private final String _prefix;
|
||||||
|
private final int _number;
|
||||||
|
private GameInfo _info;
|
||||||
|
private long _lastUpdate;
|
||||||
|
|
||||||
|
GameServer(MinecraftServer server)
|
||||||
|
{
|
||||||
|
_server = server;
|
||||||
|
|
||||||
|
// Split the server name to get it's prefix and number ("CW4-5" = "CW4" & 5)
|
||||||
|
String[] split = server.getName().split("-");
|
||||||
|
|
||||||
|
if (split.length > 1)
|
||||||
|
{
|
||||||
|
_prefix = split[0];
|
||||||
|
|
||||||
|
int number;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
number = Integer.parseInt(split[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
number = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_number = number;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_prefix = "null";
|
||||||
|
_number = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServer(MinecraftServer server)
|
||||||
|
{
|
||||||
|
_server = server;
|
||||||
|
_lastUpdate = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MinecraftServer getServer()
|
||||||
|
{
|
||||||
|
return _server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefix()
|
||||||
|
{
|
||||||
|
return _prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber()
|
||||||
|
{
|
||||||
|
return _number;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInfo(GameInfo info)
|
||||||
|
{
|
||||||
|
_info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameInfo getInfo()
|
||||||
|
{
|
||||||
|
return _info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLastUpdate()
|
||||||
|
{
|
||||||
|
return _lastUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDevServer()
|
||||||
|
{
|
||||||
|
return _number >= 777;
|
||||||
|
}
|
||||||
|
}
|
@ -3,17 +3,15 @@ package mineplex.hub.server;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -24,11 +22,12 @@ import org.bukkit.event.entity.EntityPortalEnterEvent;
|
|||||||
import org.bukkit.event.entity.EntityPortalEvent;
|
import org.bukkit.event.entity.EntityPortalEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerPortalEvent;
|
import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||||
@ -37,17 +36,16 @@ import mineplex.core.account.permissions.Permission;
|
|||||||
import mineplex.core.account.permissions.PermissionGroup;
|
import mineplex.core.account.permissions.PermissionGroup;
|
||||||
import mineplex.core.achievement.AchievementManager;
|
import mineplex.core.achievement.AchievementManager;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.common.util.Callback;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.game.status.GameInfo;
|
||||||
import mineplex.core.newnpc.NPC;
|
import mineplex.core.newnpc.NPC;
|
||||||
import mineplex.core.newnpc.NewNPCManager;
|
import mineplex.core.newnpc.NewNPCManager;
|
||||||
import mineplex.core.newnpc.StoredNPC;
|
import mineplex.core.newnpc.StoredNPC;
|
||||||
import mineplex.core.newnpc.event.NPCInteractEvent;
|
import mineplex.core.newnpc.event.NPCInteractEvent;
|
||||||
import mineplex.core.party.PartyManager;
|
|
||||||
import mineplex.core.party.event.PartySelectServerEvent;
|
import mineplex.core.party.event.PartySelectServerEvent;
|
||||||
import mineplex.core.personalServer.PersonalServerManager;
|
import mineplex.core.personalServer.PersonalServerManager;
|
||||||
import mineplex.core.portal.Intent;
|
import mineplex.core.portal.Intent;
|
||||||
@ -62,10 +60,9 @@ import mineplex.core.twofactor.TwoFactorAuth;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.hub.HubManager;
|
import mineplex.hub.HubManager;
|
||||||
|
import mineplex.hub.server.newui.ServerSelectionShop;
|
||||||
import mineplex.hub.server.ui.LobbyShop;
|
import mineplex.hub.server.ui.LobbyShop;
|
||||||
import mineplex.hub.server.ui.QuickShop;
|
import mineplex.hub.server.ui.QuickShop;
|
||||||
import mineplex.hub.server.ui.ServerNpcShop;
|
|
||||||
import mineplex.serverdata.Region;
|
|
||||||
import mineplex.serverdata.data.MinecraftServer;
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
import mineplex.serverdata.data.ServerGroup;
|
import mineplex.serverdata.data.ServerGroup;
|
||||||
|
|
||||||
@ -78,16 +75,17 @@ public class ServerManager extends MiniPlugin
|
|||||||
FEATURE_SERVER,
|
FEATURE_SERVER,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Random random = new Random();
|
private static final Random RANDOM = new Random();
|
||||||
|
|
||||||
private static final int TOP_SERVERS = 3; // The number of top contending servers for auto-joining games
|
private static final int TOP_SERVERS = 3; // The number of top contending servers for auto-joining games
|
||||||
private static final int MIN_SLOTS_REQUIRED = 12; // The number of slots the max server must have for auto-join
|
private static final int MIN_SLOTS_REQUIRED = 12; // The number of slots the max server must have for auto-join
|
||||||
|
private static final long SELECT_SERVER_COOLDOWN = TimeUnit.SECONDS.toMillis(3);
|
||||||
|
private static final long SERVER_TIMEOUT = TimeUnit.SECONDS.toMillis(5);
|
||||||
|
private static final String MPS_PREFIX = "MPS";
|
||||||
|
|
||||||
public final long QUEUE_COOLDOWN = 2000; // Cooldown (in milliseconds) between queueing again for players
|
|
||||||
private final CoreClientManager _clientManager;
|
private final CoreClientManager _clientManager;
|
||||||
private final DonationManager _donationManager;
|
private final DonationManager _donationManager;
|
||||||
private final Portal _portal;
|
private final Portal _portal;
|
||||||
private final PartyManager _partyManager;
|
|
||||||
private final ServerStatusManager _statusManager;
|
private final ServerStatusManager _statusManager;
|
||||||
private final HubManager _hubManager;
|
private final HubManager _hubManager;
|
||||||
private final BoosterManager _boosterManager;
|
private final BoosterManager _boosterManager;
|
||||||
@ -98,39 +96,47 @@ public class ServerManager extends MiniPlugin
|
|||||||
private final PersonalServerManager _personalServerManager;
|
private final PersonalServerManager _personalServerManager;
|
||||||
private final Titles _titles;
|
private final Titles _titles;
|
||||||
|
|
||||||
private NautHashMap<String, Long> _queueCooldowns = new NautHashMap<String, Long>();
|
// private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
||||||
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
// private NautHashMap<String, Integer> _serverPlayerCounts = new NautHashMap<String, Integer>();
|
||||||
private NautHashMap<String, Integer> _serverPlayerCounts = new NautHashMap<String, Integer>();
|
// private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>();
|
||||||
private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>();
|
// private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>();
|
||||||
private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>();
|
// private NautHashMap<String, Long> _serverUpdate = new NautHashMap<String, Long>();
|
||||||
private NautHashMap<String, Long> _serverUpdate = new NautHashMap<String, Long>();
|
// Maps ServerGroup name to ServerGroup
|
||||||
private NautHashMap<Vector, String> _portalToServerKey = new NautHashMap<Vector, String>();
|
private final Map<String, ServerGroup> _serverGroupsByName;
|
||||||
|
// Maps ServerGroup NPC name to ServerGroup
|
||||||
|
private final Map<String, ServerGroup> _serverGroupsByNPCName;
|
||||||
|
// Maps ServerGroup prefix (CW4) to a Map that maps server name (CW4-5) to GameServer
|
||||||
|
private final Map<String, Map<String, GameServer>> _gameServers;
|
||||||
|
// Maps ServerGroup prefix (CW4) to the number of players on that server
|
||||||
|
private final Map<String, Integer> _playersPlaying;
|
||||||
|
// Maps (in both directions) ServerGroup NPC name to the game room location
|
||||||
private final BiMap<String, Location> _serverNPCTeleport;
|
private final BiMap<String, Location> _serverNPCTeleport;
|
||||||
|
// Maps NPC name to the ServerGroup tags associated with that NPC
|
||||||
private final Map<String, String[]> _serverGroupTags = ImmutableMap.<String, String[]>builder()
|
private final Map<String, String[]> _serverGroupTags = ImmutableMap.<String, String[]>builder()
|
||||||
.put("Master Builders", new String[] {"BLD"})
|
.put("Master Builders", new String[]{"BLD"})
|
||||||
.put("Draw My Thing", new String[] {"DMT"})
|
.put("Draw My Thing", new String[]{"DMT"})
|
||||||
.put("Micro Battles", new String[] {"MB"})
|
.put("Micro Battles", new String[]{"MB"})
|
||||||
.put("Mixed Arcade", new String[] {"MIN"})
|
.put("Mixed Arcade", new String[]{"MIN"})
|
||||||
.put("Turf Wars", new String[] {"TF"})
|
.put("Turf Wars", new String[]{"TF"})
|
||||||
.put("Speed Builders", new String[] {"SB"})
|
.put("Speed Builders", new String[]{"SB"})
|
||||||
.put("Block Hunt", new String[] {"BH"})
|
.put("Block Hunt", new String[]{"BH"})
|
||||||
.put("Cake Wars", new String[] {"CW2", "CW4"})
|
.put("Cake Wars", new String[]{"CW2", "CW4"})
|
||||||
.put("Survival Games", new String[] {"HG", "SG2"})
|
.put("Survival Games", new String[]{"HG", "SG2"})
|
||||||
.put("Skywars", new String[] {"SKY", "SKY2"})
|
.put("Skywars", new String[]{"SKY", "SKY2"})
|
||||||
.put("The Bridges", new String[] {"BR"})
|
.put("The Bridges", new String[]{"BR"})
|
||||||
.put("Mine-Strike", new String[] {"MS"})
|
.put("Mine-Strike", new String[]{"MS"})
|
||||||
.put("Super Smash Mobs", new String[] {"SSM", "SSM2"})
|
.put("Super Smash Mobs", new String[]{"SSM", "SSM2"})
|
||||||
.put("Champions", new String[] {"DOM", "CTF"})
|
.put("Champions", new String[]{"DOM", "CTF"})
|
||||||
.put("Clans", new String[] {"ClansHub", "Clans"})
|
.put("Clans", new String[]{"ClansHub", "Clans"})
|
||||||
.put("Retro", new String[] {"RETRO"})
|
.put("Retro", new String[]{"RETRO"})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final QuickShop _quickShop;
|
private final QuickShop _quickShop;
|
||||||
private final LobbyShop _lobbyShop;
|
private final LobbyShop _lobbyShop;
|
||||||
|
private final ServerSelectionShop _serverShop;
|
||||||
|
|
||||||
private boolean _alternateUpdateFire = false;
|
private boolean _alternateUpdateFire, _retrieving;
|
||||||
private boolean _retrieving = false;
|
private long _lastRetrieve;
|
||||||
private long _lastRetrieve = 0;
|
|
||||||
|
|
||||||
private ServerManager()
|
private ServerManager()
|
||||||
{
|
{
|
||||||
@ -139,7 +145,6 @@ public class ServerManager extends MiniPlugin
|
|||||||
_clientManager = require(CoreClientManager.class);
|
_clientManager = require(CoreClientManager.class);
|
||||||
_donationManager = require(DonationManager.class);
|
_donationManager = require(DonationManager.class);
|
||||||
_portal = require(Portal.class);
|
_portal = require(Portal.class);
|
||||||
_partyManager = require(PartyManager.class);
|
|
||||||
_statusManager = require(ServerStatusManager.class);
|
_statusManager = require(ServerStatusManager.class);
|
||||||
_hubManager = require(HubManager.class);
|
_hubManager = require(HubManager.class);
|
||||||
_boosterManager = require(BoosterManager.class);
|
_boosterManager = require(BoosterManager.class);
|
||||||
@ -150,7 +155,12 @@ public class ServerManager extends MiniPlugin
|
|||||||
_personalServerManager = require(PersonalServerManager.class);
|
_personalServerManager = require(PersonalServerManager.class);
|
||||||
_titles = require(Titles.class);
|
_titles = require(Titles.class);
|
||||||
|
|
||||||
|
_serverGroupsByName = new HashMap<>();
|
||||||
|
_serverGroupsByNPCName = new HashMap<>();
|
||||||
|
_gameServers = new HashMap<>();
|
||||||
|
_playersPlaying = new HashMap<>();
|
||||||
_serverNPCTeleport = HashBiMap.create();
|
_serverNPCTeleport = HashBiMap.create();
|
||||||
|
|
||||||
_hubManager.getWorldData().getSpongeLocations().forEach((key, locations) ->
|
_hubManager.getWorldData().getSpongeLocations().forEach((key, locations) ->
|
||||||
{
|
{
|
||||||
String[] split = key.split(" ");
|
String[] split = key.split(" ");
|
||||||
@ -175,6 +185,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
|
|
||||||
_quickShop = new QuickShop(this, _clientManager, _donationManager, "Quick Menu");
|
_quickShop = new QuickShop(this, _clientManager, _donationManager, "Quick Menu");
|
||||||
_lobbyShop = new LobbyShop(this, _clientManager, _donationManager, "Lobby Menu");
|
_lobbyShop = new LobbyShop(this, _clientManager, _donationManager, "Lobby Menu");
|
||||||
|
_serverShop = new ServerSelectionShop(this, _clientManager, _donationManager, "Server Menu");
|
||||||
|
|
||||||
NewNPCManager npcManager = require(NewNPCManager.class);
|
NewNPCManager npcManager = require(NewNPCManager.class);
|
||||||
npcManager.spawnNPCs("GAME_", this::addNPCInfo);
|
npcManager.spawnNPCs("GAME_", this::addNPCInfo);
|
||||||
@ -259,14 +270,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, ServerNpcShop> entry : _serverNpcShopMap.entrySet())
|
openServerShop(player, npcName);
|
||||||
{
|
|
||||||
if (npcName.equals(entry.getKey()))
|
|
||||||
{
|
|
||||||
entry.getValue().attemptShopOpen(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
@ -295,8 +299,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
Map<Location, String> teleports = _serverNPCTeleport.inverse();
|
Location location = UtilAlg.findClosest(player.getLocation(), _serverNPCTeleport.values());
|
||||||
Location location = UtilAlg.findClosest(player.getLocation(), teleports.keySet());
|
|
||||||
|
|
||||||
if (location == null || !Recharge.Instance.use(player, "Game Portal", 500, false, false))
|
if (location == null || !Recharge.Instance.use(player, "Game Portal", 500, false, false))
|
||||||
{
|
{
|
||||||
@ -304,55 +307,48 @@ public class ServerManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.teleport(location);
|
player.teleport(location);
|
||||||
runSyncLater(() -> teleportOrOpen(player, teleports.get(location), false), 3);
|
runSyncLater(() -> teleportOrOpen(player, _serverNPCTeleport.inverse().get(location), false), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerInteract(PlayerInteractEvent event)
|
public void playerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (_twofactor.isAuthenticating(event.getPlayer()) || _treasureManager.isOpeningTreasure(event.getPlayer()))
|
Player player = event.getPlayer();
|
||||||
|
ItemStack itemStack = player.getItemInHand();
|
||||||
|
|
||||||
|
if (_twofactor.isAuthenticating(player) || _treasureManager.isOpeningTreasure(player) || itemStack == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getItem() != null && event.getItem().getType() == Material.COMPASS)
|
if (itemStack.getType() == Material.COMPASS)
|
||||||
{
|
{
|
||||||
_quickShop.attemptShopOpen(event.getPlayer());
|
_quickShop.attemptShopOpen(player);
|
||||||
}
|
}
|
||||||
else if (event.getItem() != null && event.getItem().getType() == Material.WATCH)
|
else if (itemStack.getType() == Material.WATCH)
|
||||||
{
|
{
|
||||||
_lobbyShop.attemptShopOpen(event.getPlayer());
|
_lobbyShop.attemptShopOpen(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addServerGroup(ServerGroup serverGroup)
|
public void addServerGroup(ServerGroup serverGroup)
|
||||||
{
|
{
|
||||||
_serverKeyInfoMap.put(serverGroup.getPrefix(), new HashSet<>());
|
_serverGroupsByName.put(serverGroup.getName(), serverGroup);
|
||||||
|
|
||||||
|
if (serverGroup.getServerNpcName() != null)
|
||||||
|
{
|
||||||
|
_serverGroupsByNPCName.put(serverGroup.getServerNpcName(), serverGroup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addServerNpc(ServerGroup serverGroup)
|
public void openServerShop(Player player, String npcName)
|
||||||
{
|
{
|
||||||
_serverNpcShopMap.put(serverGroup.getServerNpcName(), new ServerNpcShop(this, _clientManager, _donationManager, serverGroup));
|
ServerGroup serverGroup = _serverGroupsByNPCName.get(npcName);
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<ServerInfo> getServerList(String serverKey)
|
if (serverGroup != null)
|
||||||
{
|
{
|
||||||
return _serverKeyInfoMap.get(serverKey);
|
_serverShop.openServerPage(player, serverGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getServerGroups()
|
|
||||||
{
|
|
||||||
return _serverKeyInfoMap.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getAllServers()
|
|
||||||
{
|
|
||||||
return _serverInfoMap.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerInfo getServerInfo(String serverName)
|
|
||||||
{
|
|
||||||
return _serverInfoMap.get(serverName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -361,145 +357,108 @@ public class ServerManager extends MiniPlugin
|
|||||||
_quickShop.attemptShopOpen(event.getPlayer());
|
_quickShop.attemptShopOpen(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void updatePages(UpdateEvent event)
|
public void updatePages(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.SEC)
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_quickShop.UpdatePages();
|
_quickShop.UpdatePages();
|
||||||
|
_serverShop.updatePages();
|
||||||
for (ServerNpcShop shop : _serverNpcShopMap.values())
|
|
||||||
{
|
|
||||||
shop.UpdatePages();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateServers(UpdateEvent event)
|
public void updateServers(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.SEC || (_retrieving && System.currentTimeMillis() - _lastRetrieve <= 5000))
|
// Don't retrieve if we are already doing so and have not timed out.
|
||||||
|
if (event.getType() != UpdateType.SEC || (_retrieving && !UtilTime.elapsed(_lastRetrieve, SERVER_TIMEOUT)))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_alternateUpdateFire = !_alternateUpdateFire;
|
_alternateUpdateFire = !_alternateUpdateFire;
|
||||||
|
|
||||||
if (!_alternateUpdateFire)
|
if (!_alternateUpdateFire)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_retrieving = true;
|
_retrieving = true;
|
||||||
|
|
||||||
_statusManager.retrieveServerGroups(new Callback<Collection<ServerGroup>>()
|
runAsync(() ->
|
||||||
{
|
{
|
||||||
public void run(final Collection<ServerGroup> serverGroups)
|
// Get ServerGroups and Servers
|
||||||
|
Collection<ServerGroup> serverGroups = _statusManager.retrieveServerGroups();
|
||||||
|
Collection<MinecraftServer> serverStatusList = _statusManager.retrieveServerStatuses();
|
||||||
|
|
||||||
|
if (serverGroups == null || serverStatusList == null)
|
||||||
{
|
{
|
||||||
final NautHashMap<String, ServerGroup> serverGroupMap = new NautHashMap<String, ServerGroup>();
|
_retrieving = false;
|
||||||
|
_lastRetrieve = System.currentTimeMillis();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear cache
|
||||||
|
_serverGroupsByName.clear();
|
||||||
|
_serverGroupsByNPCName.clear();
|
||||||
|
_playersPlaying.clear();
|
||||||
|
|
||||||
for (ServerGroup serverGroup : serverGroups)
|
for (ServerGroup serverGroup : serverGroups)
|
||||||
{
|
{
|
||||||
serverGroupMap.put(serverGroup.getName(), serverGroup);
|
addServerGroup(serverGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
_statusManager.retrieveServerStatuses(new Callback<Collection<MinecraftServer>>()
|
|
||||||
{
|
|
||||||
public void run(Collection<MinecraftServer> serverStatusList)
|
|
||||||
{
|
|
||||||
_serverPlayerCounts.clear();
|
|
||||||
|
|
||||||
for (MinecraftServer serverStatus : serverStatusList)
|
for (MinecraftServer serverStatus : serverStatusList)
|
||||||
{
|
{
|
||||||
if (!_serverInfoMap.containsKey(serverStatus.getName()))
|
ServerGroup serverGroup = _serverGroupsByName.get(serverStatus.getGroup());
|
||||||
|
|
||||||
|
// ServerGroup of server not valid
|
||||||
|
if (serverGroup == null)
|
||||||
{
|
{
|
||||||
ServerInfo newServerInfo = new ServerInfo();
|
continue;
|
||||||
newServerInfo.Name = serverStatus.getName();
|
|
||||||
_serverInfoMap.put(serverStatus.getName(), newServerInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] args = serverStatus.getMotd().split("\\|");
|
Map<String, GameServer> servers = _gameServers.computeIfAbsent(serverGroup.getPrefix(), k -> new HashMap<>());
|
||||||
String tag = (serverStatus.getName() != null && serverStatus.getName().contains("-")) ? serverStatus.getName().split("-")[0] : "N/A";
|
GameServer gameServer = servers.computeIfAbsent(serverStatus.getName(), k -> new GameServer(serverStatus));
|
||||||
|
gameServer.setServer(serverStatus);
|
||||||
//Private Servers
|
GameInfo gameInfo;
|
||||||
if (serverGroupMap.containsKey(serverStatus.getGroup()))
|
|
||||||
{
|
|
||||||
ServerGroup serverGroup = serverGroupMap.get(serverStatus.getGroup());
|
|
||||||
if (serverGroup.getHost() != null && !serverGroup.getHost().isEmpty())
|
|
||||||
tag = "MPS";
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerInfo serverInfo = _serverInfoMap.get(serverStatus.getName());
|
|
||||||
serverInfo.Server = serverStatus;
|
|
||||||
serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.getMotd();
|
|
||||||
serverInfo.CurrentPlayers = serverStatus.getPlayerCount();
|
|
||||||
serverInfo.MaxPlayers = serverStatus.getMaxPlayerCount();
|
|
||||||
|
|
||||||
for (String arg : args)
|
|
||||||
{
|
|
||||||
if (arg != null && arg.startsWith("HostRank.") && arg.length() > "HostRank.".length())
|
|
||||||
{
|
|
||||||
String identifier = arg.split("\\.")[1];
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serverInfo.HostRank = PermissionGroup.valueOf(identifier);
|
gameInfo = GameInfo.fromString(serverStatus.getMotd());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (JsonSyntaxException ex)
|
||||||
{
|
{
|
||||||
// Ignore
|
// Invalid MOTD. Most likely restarting or starting up
|
||||||
|
gameInfo = new GameInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
gameServer.setInfo(gameInfo);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length > 1)
|
String prefix = gameServer.getPrefix();
|
||||||
serverInfo.ServerType = args[1];
|
|
||||||
|
|
||||||
if (args.length > 2)
|
// Special case for MPS. Normally they are all separate ServerGroups however here we want to group them together
|
||||||
serverInfo.Game = args[2];
|
if (serverGroup.getHost() != null && !serverGroup.getHost().isEmpty())
|
||||||
|
|
||||||
if (args.length > 3)
|
|
||||||
serverInfo.Map = args[3];
|
|
||||||
|
|
||||||
_serverUpdate.put(serverStatus.getName(), System.currentTimeMillis());
|
|
||||||
|
|
||||||
if (_serverKeyInfoMap.containsKey(tag))
|
|
||||||
{
|
{
|
||||||
_serverKeyInfoMap.get(tag).add(serverInfo);
|
prefix = MPS_PREFIX;
|
||||||
|
|
||||||
if (!_serverPlayerCounts.containsKey(tag))
|
|
||||||
_serverPlayerCounts.put(tag, 0);
|
|
||||||
|
|
||||||
_serverPlayerCounts.put(tag, _serverPlayerCounts.get(tag) + serverInfo.CurrentPlayers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String name : _serverUpdate.keySet())
|
_playersPlaying.put(prefix, _playersPlaying.getOrDefault(prefix, 0) + gameServer.getServer().getPlayerCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
_gameServers.values().forEach(map -> map.values().removeIf(gameServer ->
|
||||||
{
|
{
|
||||||
if (_serverUpdate.get(name) != -1L && System.currentTimeMillis() - _serverUpdate.get(name) > 5000)
|
// Dead server, hasn't updated it's status in 5 seconds
|
||||||
{
|
return UtilTime.elapsed(gameServer.getLastUpdate(), SERVER_TIMEOUT);
|
||||||
ServerInfo serverInfo = _serverInfoMap.get(name);
|
}));
|
||||||
serverInfo.MOTD = ChatColor.DARK_RED + "OFFLINE";
|
|
||||||
serverInfo.CurrentPlayers = 0;
|
|
||||||
serverInfo.MaxPlayers = 0;
|
|
||||||
|
|
||||||
_serverUpdate.put(name, -1L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
_retrieving = false;
|
_retrieving = false;
|
||||||
_lastRetrieve = System.currentTimeMillis();
|
_lastRetrieve = System.currentTimeMillis();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
updateCooldowns();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PartyManager getPartyManager()
|
|
||||||
{
|
|
||||||
return _partyManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectServer(Player player, ServerInfo serverInfo)
|
public void selectServer(Player player, ServerInfo serverInfo)
|
||||||
{
|
{
|
||||||
@ -518,7 +477,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
*/
|
*/
|
||||||
public void selectServer(Player player, String serverType)
|
public void selectServer(Player player, String serverType)
|
||||||
{
|
{
|
||||||
if (isOnCooldown(player))
|
if (!Recharge.Instance.use(player, "Select Server", SELECT_SERVER_COOLDOWN, false, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -528,37 +487,6 @@ public class ServerManager extends MiniPlugin
|
|||||||
if (bestServer != null)
|
if (bestServer != null)
|
||||||
{
|
{
|
||||||
selectServer(player, bestServer);
|
selectServer(player, bestServer);
|
||||||
addCooldown(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isOnCooldown(Player player)
|
|
||||||
{
|
|
||||||
if (_queueCooldowns.containsKey(player.getName()))
|
|
||||||
{
|
|
||||||
long elapsed = System.currentTimeMillis() - _queueCooldowns.get(player.getName());
|
|
||||||
|
|
||||||
return elapsed < QUEUE_COOLDOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addCooldown(Player player)
|
|
||||||
{
|
|
||||||
_queueCooldowns.put(player.getName(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCooldowns()
|
|
||||||
{
|
|
||||||
for (Iterator<String> playerIterator = _queueCooldowns.keySet().iterator(); playerIterator.hasNext(); )
|
|
||||||
{
|
|
||||||
Player player = Bukkit.getPlayer(playerIterator.next());
|
|
||||||
|
|
||||||
if (player == null || !isOnCooldown(player))
|
|
||||||
{
|
|
||||||
playerIterator.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,7 +496,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
*/
|
*/
|
||||||
public ServerInfo getBestServer(Player player, String serverKey)
|
public ServerInfo getBestServer(Player player, String serverKey)
|
||||||
{
|
{
|
||||||
Collection<ServerInfo> serverList = getServerList(serverKey);
|
Collection<ServerInfo> serverList = null;
|
||||||
|
|
||||||
if (serverList == null)
|
if (serverList == null)
|
||||||
{
|
{
|
||||||
@ -591,7 +519,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return servers.get(random.nextInt(count));
|
return servers.get(RANDOM.nextInt(count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,68 +555,20 @@ public class ServerManager extends MiniPlugin
|
|||||||
return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting");
|
return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadServers()
|
public Collection<GameServer> getServers(String prefix)
|
||||||
{
|
{
|
||||||
_serverInfoMap.clear();
|
Map<String, GameServer> servers = _gameServers.get(prefix);
|
||||||
_serverUpdate.clear();
|
return servers == null ? Collections.emptyList() : servers.values();
|
||||||
|
|
||||||
for (String npcName : _serverKeyInfoMap.keySet())
|
|
||||||
{
|
|
||||||
_serverKeyInfoMap.get(npcName).clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Region region = getPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
private void loadServers()
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
for (ServerGroup serverGroup : mineplex.serverdata.servers.ServerManager.getServerRepository(region).getServerGroups(null))
|
_serverGroupsByName.clear();
|
||||||
{
|
_serverGroupsByNPCName.clear();
|
||||||
addServerGroup(serverGroup);
|
_gameServers.clear();
|
||||||
|
|
||||||
if (!serverGroup.getServerNpcName().isEmpty())
|
addServerGroup(new ServerGroup("Event", "Event Servers", "EVENT"));
|
||||||
addServerNpc(serverGroup);
|
addServerGroup(new ServerGroup("MPS", "Mineplex Player Servers", MPS_PREFIX));
|
||||||
|
|
||||||
if (!serverGroup.getPortalBottomCornerLocation().isEmpty() && !serverGroup.getPortalTopCornerLocation().isEmpty())
|
|
||||||
{
|
|
||||||
Vector bottomVector = ParseVector(serverGroup.getPortalBottomCornerLocation());
|
|
||||||
Vector topVector = ParseVector(serverGroup.getPortalTopCornerLocation());
|
|
||||||
int blocks = 0;
|
|
||||||
|
|
||||||
while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ()))
|
|
||||||
{
|
|
||||||
_portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix());
|
|
||||||
|
|
||||||
if (bottomVector.getBlockX() != topVector.getBlockX())
|
|
||||||
{
|
|
||||||
bottomVector.add(new Vector(-(bottomVector.getBlockX() - topVector.getBlockX()) / Math.abs(bottomVector.getBlockX() - topVector.getBlockX()), 0, 0));
|
|
||||||
}
|
|
||||||
else if (bottomVector.getBlockZ() != topVector.getBlockZ())
|
|
||||||
{
|
|
||||||
bottomVector.add(new Vector(0, 0, -(bottomVector.getBlockZ() - topVector.getBlockZ()) / Math.abs(bottomVector.getBlockZ() - topVector.getBlockZ())));
|
|
||||||
}
|
|
||||||
|
|
||||||
blocks++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_portalToServerKey.put(bottomVector, serverGroup.getPrefix());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("ServerManager - Error parsing servergroups : " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddServerNpc("Event Servers", "EVENT");
|
|
||||||
// AddServerNpc("Mineplex Player Servers", "MPS");
|
|
||||||
|
|
||||||
ServerGroup eventGroup = new ServerGroup("Event", "Event Servers", "EVENT");
|
|
||||||
ServerGroup mpsGroup = new ServerGroup("MPS", "Mineplex Player Servers", "MPS");
|
|
||||||
|
|
||||||
addServerNpc(eventGroup);
|
|
||||||
addServerGroup(eventGroup);
|
|
||||||
addServerNpc(mpsGroup);
|
|
||||||
addServerGroup(mpsGroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRequiredSlots(Player player, String serverType)
|
public int getRequiredSlots(Player player, String serverType)
|
||||||
@ -701,22 +581,9 @@ public class ServerManager extends MiniPlugin
|
|||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerNpcShop getShop(String name)
|
public int getGroupTagPlayerCount(String tag)
|
||||||
{
|
{
|
||||||
return _serverNpcShopMap.get(name);
|
return _playersPlaying.getOrDefault(tag, 0);
|
||||||
}
|
|
||||||
|
|
||||||
private Vector ParseVector(String vectorString)
|
|
||||||
{
|
|
||||||
Vector vector = new Vector();
|
|
||||||
|
|
||||||
String[] parts = vectorString.trim().split(" ");
|
|
||||||
|
|
||||||
vector.setX(Double.parseDouble(parts[0]));
|
|
||||||
vector.setY(Double.parseDouble(parts[1]));
|
|
||||||
vector.setZ(Double.parseDouble(parts[2]));
|
|
||||||
|
|
||||||
return vector;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStatusManager getStatusManager()
|
public ServerStatusManager getStatusManager()
|
||||||
@ -724,20 +591,11 @@ public class ServerManager extends MiniPlugin
|
|||||||
return _statusManager;
|
return _statusManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HubManager getHubManager()
|
public HubManager getHubManager()
|
||||||
{
|
{
|
||||||
return _hubManager;
|
return _hubManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGroupTagPlayerCount(String tag)
|
|
||||||
{
|
|
||||||
if (_serverPlayerCounts.containsKey(tag))
|
|
||||||
return _serverPlayerCounts.get(tag);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getServerTags(String npcName)
|
public String[] getServerTags(String npcName)
|
||||||
{
|
{
|
||||||
return _serverGroupTags.get(npcName);
|
return _serverGroupTags.get(npcName);
|
||||||
|
@ -0,0 +1,252 @@
|
|||||||
|
package mineplex.hub.server.newui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.LineFormat;
|
||||||
|
import mineplex.core.common.util.UtilText;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.game.status.GameInfo;
|
||||||
|
import mineplex.core.game.status.GameInfo.GameDisplayStatus;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.shop.item.IButton;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.hub.server.GameServer;
|
||||||
|
import mineplex.hub.server.ServerManager;
|
||||||
|
import mineplex.serverdata.data.ServerGroup;
|
||||||
|
|
||||||
|
public class ServerSelectionPage extends ShopPageBase<ServerManager, ServerSelectionShop>
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final int STARTING_SLOT = 19;
|
||||||
|
private static final int MAX_SHOWN_SERVERS = 7;
|
||||||
|
|
||||||
|
|
||||||
|
private final ServerGroup _serverGroup;
|
||||||
|
|
||||||
|
private boolean _showInProgress;
|
||||||
|
|
||||||
|
ServerSelectionPage(ServerManager plugin, ServerSelectionShop shop, CoreClientManager clientManager, DonationManager donationManager, ServerGroup serverGroup, Player player)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, serverGroup.getServerNpcName(), player);
|
||||||
|
|
||||||
|
_serverGroup = serverGroup;
|
||||||
|
buildPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildPage()
|
||||||
|
{
|
||||||
|
if (_showInProgress)
|
||||||
|
{
|
||||||
|
// TODO MAKE
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buildMainPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildMainPage()
|
||||||
|
{
|
||||||
|
// Instant join
|
||||||
|
addRow(0, (byte) 3, new ItemBuilder(Material.DIAMOND_BLOCK)
|
||||||
|
.setTitle(C.cGreenB + "Click To Join Instantly!")
|
||||||
|
.setLore(UtilText.splitLineToArray(C.cGray + "Join the best server in an instant. No fiddling to find what server to join, let us pick one for you and join a game as fast as you can.", LineFormat.LORE)),
|
||||||
|
(player, clickType) ->
|
||||||
|
{
|
||||||
|
// TODO select best server
|
||||||
|
});
|
||||||
|
|
||||||
|
// Public Servers
|
||||||
|
List<GameServer> servers = new ArrayList<>(getPlugin().getServers(_serverGroup.getPrefix()));
|
||||||
|
int slot = STARTING_SLOT;
|
||||||
|
|
||||||
|
for (GameServer server : servers)
|
||||||
|
{
|
||||||
|
if (server.isDevServer())
|
||||||
|
{
|
||||||
|
addServer(slot++ + 9, server);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addServer(slot++, server);
|
||||||
|
|
||||||
|
if (slot >= STARTING_SLOT + MAX_SHOWN_SERVERS)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In Progress Servers
|
||||||
|
addRow(5, (byte) 4, new ItemBuilder(Material.GOLD_BLOCK)
|
||||||
|
.setTitle(C.cYellowB + "X Games In Progress")
|
||||||
|
.setLore(UtilText.splitLinesToArray(new String[]
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
C.cWhite + C.Line + "Click to Spectate",
|
||||||
|
"",
|
||||||
|
C.cGray + "List all servers in the middle of playing. Find a random one to learn how to play better, or find one that your friend might be in."
|
||||||
|
}, LineFormat.LORE)),
|
||||||
|
(player, clickType) ->
|
||||||
|
{
|
||||||
|
// TODO show in progress servers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRow(int row, byte glassData, ItemBuilder builder, IButton button)
|
||||||
|
{
|
||||||
|
ItemStack glass = builder.clone()
|
||||||
|
.setType(Material.STAINED_GLASS_PANE)
|
||||||
|
.setData(glassData)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
for (int column = 0; column < 9; column++)
|
||||||
|
{
|
||||||
|
addButton(getSlot(row, column), column == 4 ? builder.build() : glass, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addServer(int slot, GameServer server)
|
||||||
|
{
|
||||||
|
GameInfo info = server.getInfo();
|
||||||
|
Material material;
|
||||||
|
byte data = 0;
|
||||||
|
String votingColour = null, votingStatus = null, votingOn = null;
|
||||||
|
String motd;
|
||||||
|
|
||||||
|
getPlugin().log(info.toString());
|
||||||
|
|
||||||
|
switch (info.getStatus())
|
||||||
|
{
|
||||||
|
case WAITING:
|
||||||
|
material = Material.STAINED_GLASS;
|
||||||
|
data = (byte) 8;
|
||||||
|
votingColour = C.cGray;
|
||||||
|
votingStatus = "Not Enough Players To Start";
|
||||||
|
motd = "Recruiting";
|
||||||
|
break;
|
||||||
|
case VOTING:
|
||||||
|
material = Material.STAINED_GLASS;
|
||||||
|
data = (byte) 5;
|
||||||
|
votingColour = C.cYellow;
|
||||||
|
votingStatus = "Voting is in Progress";
|
||||||
|
motd = "Voting Ends in " + timeString(info.getTimer());
|
||||||
|
break;
|
||||||
|
case STARTING:
|
||||||
|
material = Material.EMERALD_BLOCK;
|
||||||
|
votingColour = C.cGreen;
|
||||||
|
votingStatus = "Voting Already Finished!";
|
||||||
|
motd = "Starting in " + timeString(info.getTimer());
|
||||||
|
break;
|
||||||
|
case IN_PROGRESS:
|
||||||
|
material = Material.GOLD_BLOCK;
|
||||||
|
motd = "In Progress";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
material = Material.IRON_BLOCK;
|
||||||
|
motd = "Not Open";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_serverGroup.getGameVoting())
|
||||||
|
{
|
||||||
|
votingOn = "Game";
|
||||||
|
}
|
||||||
|
else if (_serverGroup.getMapVoting())
|
||||||
|
{
|
||||||
|
votingOn = "Map";
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemBuilder builder = new ItemBuilder(material, data)
|
||||||
|
.setTitle(C.cGreenB + _serverGroup.getServerNpcName() + " Server " + server.getNumber())
|
||||||
|
.addLore("");
|
||||||
|
|
||||||
|
// If there's a game and the ServerGroup could run more than 1 game
|
||||||
|
if (info.getGame() != null && _serverGroup.getGames().contains(","))
|
||||||
|
{
|
||||||
|
builder.addLore(C.cYellow + "Game: " + C.cWhite + info.getGame());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.getMode() != null)
|
||||||
|
{
|
||||||
|
builder.addLore(C.cYellow + "Mode: " + C.cWhite + info.getMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.addLore(
|
||||||
|
C.cYellow + "Players: " + C.cWhite + server.getServer().getPlayerCount() + "/" + server.getServer().getMaxPlayerCount(),
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
// Voting enabled
|
||||||
|
if (votingOn != null)
|
||||||
|
{
|
||||||
|
// Has information
|
||||||
|
if (votingStatus != null)
|
||||||
|
{
|
||||||
|
if (info.getStatus() != GameDisplayStatus.WAITING)
|
||||||
|
{
|
||||||
|
builder.addLore(votingColour + votingOn + " " + votingStatus);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.addLore(votingColour + votingStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is voting
|
||||||
|
if (info.getStatus() == GameDisplayStatus.VOTING)
|
||||||
|
{
|
||||||
|
for (String value : info.getVotingOn())
|
||||||
|
{
|
||||||
|
builder.addLore(C.cYellow + votingOn + ": " + C.cWhite + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map
|
||||||
|
if (info.getMap() != null)
|
||||||
|
{
|
||||||
|
builder.addLore(C.cYellow + "Map: " + C.cWhite + info.getMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.addLore(
|
||||||
|
"",
|
||||||
|
C.cGreen + motd,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
String footer;
|
||||||
|
|
||||||
|
switch (info.getJoinable())
|
||||||
|
{
|
||||||
|
case OPEN:
|
||||||
|
footer = "Click to Join!";
|
||||||
|
break;
|
||||||
|
case RANKS_ONLY:
|
||||||
|
footer = "ULTRA+ can join";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
footer = "Closed";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.addLore(C.cWhite + C.Line + footer);
|
||||||
|
|
||||||
|
addButton(slot, builder.build(), (player, clickType) ->
|
||||||
|
{
|
||||||
|
// TODO select server
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String timeString(int time)
|
||||||
|
{
|
||||||
|
return time + " Second" + (time == 1 ? "" : "s") + "...";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package mineplex.hub.server.newui;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.ShopBase;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.hub.server.ServerManager;
|
||||||
|
import mineplex.serverdata.data.ServerGroup;
|
||||||
|
|
||||||
|
public class ServerSelectionShop extends ShopBase<ServerManager>
|
||||||
|
{
|
||||||
|
|
||||||
|
public ServerSelectionShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||||
|
{
|
||||||
|
super(plugin, clientManager, donationManager, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> buildPagesFor(Player player)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openServerPage(Player player, ServerGroup group)
|
||||||
|
{
|
||||||
|
openPageForPlayer(player, new ServerSelectionPage(getPlugin(), this, getClientManager(), getDonationManager(), group, player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePages()
|
||||||
|
{
|
||||||
|
getPageMap().values().forEach(ShopPageBase::refresh);
|
||||||
|
}
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
package mineplex.hub.server.ui;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
|
|
||||||
public class CakeWarsServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
|
||||||
{
|
|
||||||
|
|
||||||
CakeWarsServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
|
||||||
{
|
|
||||||
super(plugin, shop, clientManager, donationManager, "Cake Wars", player, 27);
|
|
||||||
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buildPage()
|
|
||||||
{
|
|
||||||
addButton(12, new ItemBuilder(Material.CAKE).setTitle("Play " + C.cRedB + "Cake Wars " + C.cWhiteB + "Standard")
|
|
||||||
.addLore
|
|
||||||
(
|
|
||||||
C.blankLine,
|
|
||||||
C.Reset + C.cGreen + "Click to Play"
|
|
||||||
).build(),
|
|
||||||
(player, clickType) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Cake Wars Standard", player, "CW4")));
|
|
||||||
|
|
||||||
addButton(14, new ItemBuilder(Material.SUGAR).setTitle("Play " + C.cRedB + "Cake Wars " + C.cWhiteB + "Duos")
|
|
||||||
.addLore
|
|
||||||
(
|
|
||||||
C.blankLine,
|
|
||||||
C.Reset + C.cGreen + "Click to Play"
|
|
||||||
).build(),
|
|
||||||
(player, clickType) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Cake Wars Duos", player, "CW2")));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package mineplex.hub.server.ui;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
|
|
||||||
public class ChampionsServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
|
||||||
{
|
|
||||||
|
|
||||||
ChampionsServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
|
||||||
{
|
|
||||||
super(plugin, shop, clientManager, donationManager, "Champions", player, 27);
|
|
||||||
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buildPage()
|
|
||||||
{
|
|
||||||
addButton(12, new ItemBuilder(Material.BEACON).setTitle("Play " + C.cGreen + "Champions Dominate")
|
|
||||||
.addLore
|
|
||||||
(
|
|
||||||
C.blankLine,
|
|
||||||
C.Reset + C.cGreen + "Click to Play"
|
|
||||||
).build(),
|
|
||||||
(player, clickType) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Champions Dominate", player, "DOM")));
|
|
||||||
|
|
||||||
addButton(14, new ItemBuilder(Material.BANNER).setTitle("Play " + C.cGreen + "Champions CTF")
|
|
||||||
.addLore
|
|
||||||
(
|
|
||||||
C.blankLine,
|
|
||||||
C.Reset + C.cGreen + "Click to Play"
|
|
||||||
).build(),
|
|
||||||
(player, clickType) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Champions CTF", player, "CTF")));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +1,11 @@
|
|||||||
package mineplex.hub.server.ui;
|
package mineplex.hub.server.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.hub.server.LobbySorter;
|
|
||||||
import mineplex.hub.server.ServerInfo;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
import mineplex.hub.server.ServerManager;
|
||||||
import mineplex.hub.server.ui.button.JoinServerButton;
|
|
||||||
|
|
||||||
public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop>
|
public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop>
|
||||||
{
|
{
|
||||||
@ -34,51 +24,5 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop>
|
|||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
List<ServerInfo> serverList = new ArrayList<>(getPlugin().getServerList(_serverGroup));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serverList.sort(new LobbySorter());
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
int slot = 0;
|
|
||||||
String openFull = ChatColor.RESET + C.Line + "Get Ultra to join full servers!";
|
|
||||||
String openFullUltra = ChatColor.RESET + C.Line + "Click to join!";
|
|
||||||
|
|
||||||
for (ServerInfo serverInfo : serverList)
|
|
||||||
{
|
|
||||||
Material status = Material.IRON_BLOCK;
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
|
|
||||||
slot = Integer.parseInt(serverInfo.Name.split("-")[1]) - 1;
|
|
||||||
if (slot >= 54)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (serverInfo.Name.equalsIgnoreCase(getPlugin().getStatusManager().getCurrentServerName()))
|
|
||||||
status = Material.EMERALD_BLOCK;
|
|
||||||
|
|
||||||
lore.add(ChatColor.RESET + "");
|
|
||||||
lore.add(ChatColor.RESET + "" + ChatColor.YELLOW + "Players: " + ChatColor.WHITE + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers);
|
|
||||||
lore.add(ChatColor.RESET + "");
|
|
||||||
|
|
||||||
if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers)
|
|
||||||
{
|
|
||||||
if (!getClientManager().Get(getPlayer()).hasPermission(ServerManager.Perm.JOIN_FULL))
|
|
||||||
lore.add(openFull);
|
|
||||||
else
|
|
||||||
lore.add(openFullUltra);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
lore.add(ChatColor.RESET + C.Line + "Click to join!");
|
|
||||||
|
|
||||||
if (status != Material.EMERALD_BLOCK)
|
|
||||||
addButton(slot, new ShopItem(status, ChatColor.UNDERLINE + "" + ChatColor.BOLD + "" + ChatColor.WHITE + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), Integer.parseInt(serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1)), false), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
else
|
|
||||||
addItem(slot, new ShopItem(status, ChatColor.UNDERLINE + "" + ChatColor.BOLD + "" + ChatColor.WHITE + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), Integer.parseInt(serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1)), false));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,514 +0,0 @@
|
|||||||
package mineplex.hub.server.ui;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.game.GameDisplay;
|
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.core.shop.item.ShopItem;
|
|
||||||
import mineplex.core.shop.page.ShopPageInventory;
|
|
||||||
import mineplex.hub.server.ServerInfo;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
import mineplex.hub.server.ServerSorter;
|
|
||||||
import mineplex.hub.server.ui.button.JoinServerButton;
|
|
||||||
|
|
||||||
public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcShop>
|
|
||||||
{
|
|
||||||
private static final int MAX_FULL_SERVERS = 3;
|
|
||||||
|
|
||||||
// Shop Item Messages
|
|
||||||
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!";
|
|
||||||
private static final String MESSAGE_JOIN = ChatColor.RESET + C.Line + "Click to Join";
|
|
||||||
private static final String MESSAGE_IN_PROGRESS = ChatColor.RESET + C.Line + "Game in Progress.";
|
|
||||||
private static final String MESSAGE_SPECTATE = ChatColor.RESET + C.Line + "Click to Spectate";
|
|
||||||
private static final String MESSAGE_WAIT = ChatColor.RESET + C.Line + "and wait for next game!";
|
|
||||||
private static final String MESSAGE_FULL_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join full servers!";
|
|
||||||
private static final String MESSAGE_RESTARTING = ChatColor.RESET + C.Line + "This server will be open shortly!";
|
|
||||||
|
|
||||||
private String _serverGroupName;
|
|
||||||
private boolean _onMainPage = true;
|
|
||||||
|
|
||||||
private IButton[] _buttons;
|
|
||||||
private ItemStack[] _items;
|
|
||||||
|
|
||||||
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName)
|
|
||||||
{
|
|
||||||
super(plugin, shop, clientManager, donationManager, name, player, 54);
|
|
||||||
|
|
||||||
_serverGroupName = serverGroupName;
|
|
||||||
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buildItems()
|
|
||||||
{
|
|
||||||
_items = new ItemStack[0];
|
|
||||||
_buttons = new IButton[0];
|
|
||||||
|
|
||||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().getServerList(_serverGroupName));
|
|
||||||
|
|
||||||
int slotsNeeded = 1;
|
|
||||||
|
|
||||||
if (serverList.size() > 0)
|
|
||||||
{
|
|
||||||
slotsNeeded = getPlugin().getRequiredSlots(getPlayer(), serverList.get(0).ServerType);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Collections.sort(serverList, new ServerSorter(slotsNeeded));
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_onMainPage)
|
|
||||||
{
|
|
||||||
buildAvailableServerPage(serverList, slotsNeeded);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buildInProgressServerPage(serverList, slotsNeeded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShopItem buildShopItem(ServerInfo serverInfo, int slotsNeeded, boolean isDev)
|
|
||||||
{
|
|
||||||
boolean ownsUltraPackage = getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage(serverInfo.ServerType + " ULTRA") || getClientManager().Get(getPlayer()).hasPermission(ServerManager.Perm.JOIN_FULL);
|
|
||||||
Material status = Material.REDSTONE_BLOCK;
|
|
||||||
List<String> lore = new ArrayList<String>();
|
|
||||||
|
|
||||||
String inProgress = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? MESSAGE_IN_PROGRESS : MESSAGE_SPECTATE;
|
|
||||||
String wait = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? null : MESSAGE_WAIT;
|
|
||||||
|
|
||||||
if (isStarting(serverInfo) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slotsNeeded)
|
|
||||||
status = isDev ? Material.COMMAND : Material.EMERALD_BLOCK;
|
|
||||||
else if (isInProgress(serverInfo))
|
|
||||||
status = Material.GOLD_BLOCK;
|
|
||||||
|
|
||||||
lore.add(ChatColor.RESET + "");
|
|
||||||
|
|
||||||
if (serverInfo.Game != null)
|
|
||||||
lore.add(ChatColor.RESET + C.cYellow + "Game: " + C.cWhite + serverInfo.Game);
|
|
||||||
|
|
||||||
if (serverInfo.Map != null && !serverInfo.ServerType.equalsIgnoreCase("Competitive"))
|
|
||||||
lore.add(ChatColor.RESET + C.cYellow + "Map: " + C.cWhite + serverInfo.Map);
|
|
||||||
|
|
||||||
lore.add(ChatColor.RESET + C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers);
|
|
||||||
lore.add(ChatColor.RESET + "");
|
|
||||||
lore.add(ChatColor.RESET + serverInfo.MOTD);
|
|
||||||
|
|
||||||
if (serverInfo.Name.contains("T_") && !ownsUltraPackage)
|
|
||||||
{
|
|
||||||
lore.add(MESSAGE_BETA_GET_ULTRA);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isInProgress(serverInfo))
|
|
||||||
{
|
|
||||||
if (serverInfo.MOTD.contains("Restarting"))
|
|
||||||
{
|
|
||||||
status = Material.IRON_BLOCK;
|
|
||||||
lore.add(MESSAGE_RESTARTING);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (serverInfo.Game.equalsIgnoreCase("Survival Games"))
|
|
||||||
{
|
|
||||||
lore.add(ChatColor.RESET + C.Line + "Full Survival Games servers");
|
|
||||||
lore.add(ChatColor.RESET + C.Line + "cannot be joined.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!ownsUltraPackage)
|
|
||||||
{
|
|
||||||
lore.add(MESSAGE_FULL_GET_ULTRA);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lore.add(inProgress);
|
|
||||||
if (wait != null)
|
|
||||||
lore.add(wait);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers && !ownsUltraPackage)
|
|
||||||
{
|
|
||||||
lore.add(MESSAGE_FULL_GET_ULTRA);
|
|
||||||
}
|
|
||||||
else if (!serverInfo.MOTD.contains("Open in"))
|
|
||||||
{
|
|
||||||
if (isDev)
|
|
||||||
{
|
|
||||||
lore.add(ChatColor.RESET + C.cRed + "Warning: This is a test server run by a developer");
|
|
||||||
lore.add(ChatColor.RESET + C.cRed + "It may contain unreleased updates");
|
|
||||||
}
|
|
||||||
lore.add(MESSAGE_JOIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShopItem(status, ChatColor.RESET + C.cGreen + C.Line + C.Bold + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), serverInfo.CurrentPlayers, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildAvailableServerPage(List<ServerInfo> serverList, int slotsNeeded)
|
|
||||||
{
|
|
||||||
boolean hasDevServers = false;
|
|
||||||
|
|
||||||
for (Iterator<ServerInfo> iterator = serverList.iterator(); iterator.hasNext(); )
|
|
||||||
{
|
|
||||||
ServerInfo serverInfo = iterator.next();
|
|
||||||
if (serverInfo.isDevServer())
|
|
||||||
{
|
|
||||||
if (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - serverInfo.Server.getCurrentTime()) < 5)
|
|
||||||
{
|
|
||||||
if (!isInProgress(serverInfo))
|
|
||||||
{
|
|
||||||
hasDevServers = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean privateServer = serverList.size() > 0 && serverList.get(0).ServerType.equals("Player");
|
|
||||||
|
|
||||||
if (privateServer)
|
|
||||||
{
|
|
||||||
int staffSlot = 0;
|
|
||||||
int slot = 18;
|
|
||||||
for (ServerInfo serverInfo : serverList)
|
|
||||||
{
|
|
||||||
if (serverInfo.MOTD.contains("Private"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (serverInfo.MaxPlayers - serverInfo.CurrentPlayers <= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (serverInfo.HostRank != null && serverInfo.HostRank.hasPermission(ServerManager.Perm.FEATURE_SERVER) && staffSlot < 9)
|
|
||||||
{
|
|
||||||
addButton(staffSlot, getPrivateItem(serverInfo), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
staffSlot++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (slot >= 54)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
slot++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gamesInProgress = 0;
|
|
||||||
|
|
||||||
if (!hasDevServers)
|
|
||||||
{
|
|
||||||
int normalSlotStart = 19;
|
|
||||||
int normalSlotEnd = 25;
|
|
||||||
int currentNormalSlot = normalSlotStart;
|
|
||||||
int fullCount = 0;
|
|
||||||
|
|
||||||
for (ServerInfo serverInfo : serverList)
|
|
||||||
{
|
|
||||||
if (isStarting(serverInfo) && hasEnoughSlots(serverInfo, slotsNeeded))
|
|
||||||
{
|
|
||||||
boolean full = serverInfo.MaxPlayers - serverInfo.CurrentPlayers <= 0;
|
|
||||||
|
|
||||||
if (full && fullCount >= MAX_FULL_SERVERS)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, false);
|
|
||||||
|
|
||||||
if (serverInfo.MOTD.contains("Open in"))
|
|
||||||
addItemStack(currentNormalSlot, shopItem);
|
|
||||||
else
|
|
||||||
addButton(currentNormalSlot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
|
|
||||||
if (full)
|
|
||||||
fullCount++;
|
|
||||||
|
|
||||||
currentNormalSlot++;
|
|
||||||
if (currentNormalSlot > normalSlotEnd)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (isInProgress(serverInfo))
|
|
||||||
{
|
|
||||||
gamesInProgress++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentNormalSlot <= normalSlotEnd)
|
|
||||||
for (int i = currentNormalSlot; i <= normalSlotEnd; i++)
|
|
||||||
{
|
|
||||||
addItemStack(i, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int normalSlotStart = 10;
|
|
||||||
int normalSlotEnd = 16;
|
|
||||||
int currentNormalSlot = normalSlotStart;
|
|
||||||
int normalFullCount = 0;
|
|
||||||
int devSlotStart = 28;
|
|
||||||
int devSlotEnd = 34;
|
|
||||||
int currentDevSlot = devSlotStart;
|
|
||||||
int devFullCount = 0;
|
|
||||||
|
|
||||||
for (ServerInfo serverInfo : serverList)
|
|
||||||
{
|
|
||||||
boolean isDevServer = serverInfo.isDevServer();
|
|
||||||
if (isStarting(serverInfo) && hasEnoughSlots(serverInfo, slotsNeeded))
|
|
||||||
{
|
|
||||||
if (isDevServer && currentDevSlot > devSlotEnd)
|
|
||||||
continue;
|
|
||||||
else if (!isDevServer && currentNormalSlot > normalSlotEnd)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
boolean full = serverInfo.MaxPlayers - serverInfo.CurrentPlayers <= 0;
|
|
||||||
|
|
||||||
if (full)
|
|
||||||
{
|
|
||||||
if (isDevServer && devFullCount >= MAX_FULL_SERVERS)
|
|
||||||
continue;
|
|
||||||
else if (!isDevServer && normalFullCount >= MAX_FULL_SERVERS)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, isDevServer);
|
|
||||||
|
|
||||||
if (serverInfo.MOTD.contains("Open in"))
|
|
||||||
addItemStack(isDevServer ? currentDevSlot : currentNormalSlot, shopItem);
|
|
||||||
else
|
|
||||||
addButton(isDevServer ? currentDevSlot : currentNormalSlot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
|
|
||||||
if (full)
|
|
||||||
{
|
|
||||||
if (isDevServer)
|
|
||||||
devFullCount++;
|
|
||||||
else
|
|
||||||
normalFullCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isDevServer)
|
|
||||||
currentDevSlot++;
|
|
||||||
else
|
|
||||||
currentNormalSlot++;
|
|
||||||
}
|
|
||||||
else if (isInProgress(serverInfo))
|
|
||||||
{
|
|
||||||
gamesInProgress++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentNormalSlot <= normalSlotEnd)
|
|
||||||
for (int i = currentNormalSlot; i <= normalSlotEnd; i++)
|
|
||||||
{
|
|
||||||
addItemStack(i, null);
|
|
||||||
}
|
|
||||||
if (currentDevSlot <= devSlotEnd)
|
|
||||||
for (int i = currentDevSlot; i <= devSlotEnd; i++)
|
|
||||||
{
|
|
||||||
addItemStack(i, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + gamesInProgress + " Game" + (gamesInProgress == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, gamesInProgress > 64 ? 64 : gamesInProgress, false), new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
_onMainPage = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addButton(4, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BLOCK, (byte) 0, 1, C.cGreen + "Click to join instantly!"), new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
getPlugin().selectServer(player, _serverGroupName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addItemStack(int slot, ItemStack item)
|
|
||||||
{
|
|
||||||
if (_items.length <= slot)
|
|
||||||
{
|
|
||||||
if (item == null || item.getType() == Material.AIR)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items = Arrays.copyOf(_items, slot + 1);
|
|
||||||
_buttons = Arrays.copyOf(_buttons, slot + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
_items[slot] = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addButton(int slot, ItemStack item, IButton button)
|
|
||||||
{
|
|
||||||
if (_items.length <= slot)
|
|
||||||
{
|
|
||||||
_items = Arrays.copyOf(_items, slot + 1);
|
|
||||||
_buttons = Arrays.copyOf(_buttons, slot + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
_items[slot] = item;
|
|
||||||
_buttons[slot] = button;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShopItem getPrivateItem(ServerInfo serverInfo)
|
|
||||||
{
|
|
||||||
String hostName = serverInfo.Name.substring(0, serverInfo.Name.indexOf('-'));
|
|
||||||
String server = ChatColor.GREEN + C.Bold + serverInfo.Name;
|
|
||||||
String host = ChatColor.YELLOW + "Host: " + C.cWhite + hostName;
|
|
||||||
Material material = Material.SKULL_ITEM;
|
|
||||||
byte data = (byte) 3;
|
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(host);
|
|
||||||
lore.add(" ");
|
|
||||||
lore.add(ChatColor.RESET + C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers);
|
|
||||||
lore.add(" ");
|
|
||||||
|
|
||||||
if (serverInfo.Game != null)
|
|
||||||
{
|
|
||||||
lore.add(ChatColor.RESET + C.cYellow + "Game: " + C.cWhite + serverInfo.Game);
|
|
||||||
GameDisplay display = GameDisplay.matchName(serverInfo.Game);
|
|
||||||
if (display != null)
|
|
||||||
{
|
|
||||||
material = display.getMaterial();
|
|
||||||
data = display.getMaterialData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverInfo.Map != null)
|
|
||||||
lore.add(ChatColor.RESET + C.cYellow + "Map: " + C.cWhite + serverInfo.Map);
|
|
||||||
|
|
||||||
if (serverInfo.HostRank != null && serverInfo.HostRank.hasPermission(ServerManager.Perm.FEATURE_SERVER))
|
|
||||||
{
|
|
||||||
lore.add(" ");
|
|
||||||
lore.add(ChatColor.RESET + "Host Rank: " + serverInfo.HostRank.getDisplay(true, false, true, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
ShopItem shopItem = new ShopItem(material, data, server, lore.toArray(new String[0]), 1, false, false);
|
|
||||||
if (material == Material.SKULL_ITEM)
|
|
||||||
{
|
|
||||||
SkullMeta meta = (SkullMeta) shopItem.getItemMeta();
|
|
||||||
meta.setOwner(hostName);
|
|
||||||
shopItem.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
return shopItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isStarting(ServerInfo serverInfo)
|
|
||||||
{
|
|
||||||
return (serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Generating") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Open"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isInProgress(ServerInfo serverInfo)
|
|
||||||
{
|
|
||||||
return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting");
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasEnoughSlots(ServerInfo serverInfo, int slotsNeeded)
|
|
||||||
{
|
|
||||||
return (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slotsNeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildInProgressServerPage(List<ServerInfo> serverList, int slotsNeeded)
|
|
||||||
{
|
|
||||||
int slot = 9;
|
|
||||||
|
|
||||||
ArrayList<ServerInfo> inProgress = new ArrayList<ServerInfo>();
|
|
||||||
|
|
||||||
for (ServerInfo serverInfo : serverList)
|
|
||||||
{
|
|
||||||
if (isInProgress(serverInfo))
|
|
||||||
{
|
|
||||||
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, false);
|
|
||||||
|
|
||||||
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
inProgress.add(serverInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ServerInfo serverInfo : inProgress)
|
|
||||||
{
|
|
||||||
if (inProgress.size() > 45 && slot > 9 && slot % 45 == 0)
|
|
||||||
{
|
|
||||||
addBackBed(slot + 4);
|
|
||||||
slot += 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, false);
|
|
||||||
|
|
||||||
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
|
|
||||||
|
|
||||||
slot++;
|
|
||||||
}
|
|
||||||
|
|
||||||
addBackBed(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addBackBed(int slot)
|
|
||||||
{
|
|
||||||
addButton(slot, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]
|
|
||||||
{}, 1, false), new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
_onMainPage = true;
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
getButtonMap().clear();
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IButton[] getButtons()
|
|
||||||
{
|
|
||||||
return _buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ItemStack[] getItems()
|
|
||||||
{
|
|
||||||
return _items;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package mineplex.hub.server.ui;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.shop.ShopBase;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
import mineplex.serverdata.data.ServerGroup;
|
|
||||||
|
|
||||||
public class ServerNpcShop extends ShopBase<ServerManager>
|
|
||||||
{
|
|
||||||
|
|
||||||
private final ServerGroup _serverGroup;
|
|
||||||
|
|
||||||
public ServerNpcShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager, ServerGroup serverGroup)
|
|
||||||
{
|
|
||||||
super(plugin, clientManager, donationManager, serverGroup.getServerNpcName());
|
|
||||||
|
|
||||||
_serverGroup = serverGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> buildPagesFor(Player player)
|
|
||||||
{
|
|
||||||
switch (_serverGroup.getPrefix().toUpperCase())
|
|
||||||
{
|
|
||||||
case "SKY":
|
|
||||||
case "HG":
|
|
||||||
case "SSM":
|
|
||||||
return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
|
|
||||||
|
|
||||||
case "CW2":
|
|
||||||
case "CW4":
|
|
||||||
return new CakeWarsServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
|
||||||
|
|
||||||
case "DOM":
|
|
||||||
case "CTF":
|
|
||||||
return new ChampionsServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdatePages()
|
|
||||||
{
|
|
||||||
for (ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> page : getPlayerPageMap().values())
|
|
||||||
{
|
|
||||||
if (page instanceof ServerNpcPage)
|
|
||||||
{
|
|
||||||
((ServerNpcPage) page).Update();
|
|
||||||
}
|
|
||||||
else if (page instanceof ServerGameMenu)
|
|
||||||
{
|
|
||||||
((ServerGameMenu) page).Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void openShopForPlayer(Player player)
|
|
||||||
{
|
|
||||||
getPlugin().getHubManager().GetVisibility().addHiddenPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void closeShopForPlayer(Player player)
|
|
||||||
{
|
|
||||||
getPlugin().getHubManager().GetVisibility().removeHiddenPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
|
|
||||||
package mineplex.hub.server.ui;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
import mineplex.hub.server.ui.button.SelectTypeButton;
|
|
||||||
import mineplex.serverdata.data.ServerGroup;
|
|
||||||
|
|
||||||
public class ServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
|
||||||
{
|
|
||||||
|
|
||||||
private ServerGroup _serverGroup;
|
|
||||||
|
|
||||||
public ServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager,
|
|
||||||
DonationManager donationManager, Player player, ServerGroup serverGroup)
|
|
||||||
{
|
|
||||||
super(plugin, shop, clientManager, donationManager, serverGroup.getServerNpcName(), player, 27);
|
|
||||||
|
|
||||||
_serverGroup = serverGroup;
|
|
||||||
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buildPage()
|
|
||||||
{
|
|
||||||
String friendlyName = _serverGroup.getServerNpcName();
|
|
||||||
|
|
||||||
setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "Solo " + friendlyName)
|
|
||||||
.addLore(new String[]
|
|
||||||
{
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cRed + C.Bold + "WARNING: " + C.Reset + "Teaming in Solo Mode is bannable!",
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cGreen + "Click to Play",
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
setItem(14, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "Team " + friendlyName)
|
|
||||||
.addLore(new String[]
|
|
||||||
{
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cGray + "2 Player Teams",
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cGreen + "Click to Play"
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
getButtonMap().put(12, new SelectTypeButton(this, false));
|
|
||||||
getButtonMap().put(14, new SelectTypeButton(this, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
getButtonMap().clear();
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectServer(Player player, boolean team)
|
|
||||||
{
|
|
||||||
if (team)
|
|
||||||
{
|
|
||||||
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(),
|
|
||||||
getDonationManager(), _serverGroup.getServerNpcName() + " Teams", player, _serverGroup.getTeamServerKey()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(),
|
|
||||||
getDonationManager(), _serverGroup.getServerNpcName() + " Solo", player, _serverGroup.getPrefix()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package mineplex.hub.server.ui.button;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
|
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.hub.server.ServerInfo;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
|
|
||||||
public class JoinServerButton implements IButton
|
|
||||||
{
|
|
||||||
private final ShopPageBase<?, ?> _page;
|
|
||||||
private final ServerManager _serverManager;
|
|
||||||
private final ServerInfo _serverInfo;
|
|
||||||
private final Player _player;
|
|
||||||
|
|
||||||
public JoinServerButton(ShopPageBase<?, ?> page, ServerManager serverManager, ServerInfo serverInfo, Player player)
|
|
||||||
{
|
|
||||||
_page = page;
|
|
||||||
_serverManager = serverManager;
|
|
||||||
_serverInfo = serverInfo;
|
|
||||||
_player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
selectServer(player, _serverInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectServer(Player player, ServerInfo serverInfo)
|
|
||||||
{
|
|
||||||
if (serverInfo != null)
|
|
||||||
{
|
|
||||||
int slots = _serverManager.getRequiredSlots(player, serverInfo.ServerType);
|
|
||||||
|
|
||||||
if (serverInfo.getAvailableSlots() < slots && !(_page.getDonationManager().Get(_player).ownsUnknownSalesPackage(serverInfo.ServerType + " ULTRA") || _page.getClientManager().Get(_player).hasPermission(ServerManager.Perm.JOIN_FULL)))
|
|
||||||
{
|
|
||||||
_page.playDenySound(player);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_serverManager.selectServer(player, serverInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_page.playDenySound(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package mineplex.hub.server.ui.button;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
|
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.hub.server.ui.ServerTypePage;
|
|
||||||
|
|
||||||
public class SelectTypeButton implements IButton
|
|
||||||
{
|
|
||||||
private ServerTypePage _page;
|
|
||||||
private boolean _teamBased;
|
|
||||||
|
|
||||||
public SelectTypeButton(ServerTypePage page, boolean teamBased)
|
|
||||||
{
|
|
||||||
_page = page;
|
|
||||||
_teamBased = teamBased;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
_page.selectServer(player, _teamBased);
|
|
||||||
}
|
|
||||||
}
|
|
@ -175,7 +175,7 @@ import nautilus.game.arcade.managers.lobby.LobbyManager;
|
|||||||
import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
|
import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
|
||||||
import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager;
|
import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager;
|
||||||
import nautilus.game.arcade.managers.voting.Vote;
|
import nautilus.game.arcade.managers.voting.Vote;
|
||||||
import nautilus.game.arcade.managers.voting.types.GameVote;
|
import nautilus.game.arcade.managers.voting.Voteable;
|
||||||
|
|
||||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||||
{
|
{
|
||||||
@ -1057,24 +1057,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
// Null game - GameVote
|
// Null game - GameVote
|
||||||
if (nullGame)
|
if (nullGame)
|
||||||
{
|
{
|
||||||
game = "Voting";
|
game = null;
|
||||||
map = game;
|
map = null;
|
||||||
|
|
||||||
Vote vote = _gameCreationManager.getVotingManager().getCurrentVote();
|
|
||||||
|
|
||||||
if (vote instanceof GameVote)
|
|
||||||
{
|
|
||||||
votingOn = ((GameVote) vote).getValues().stream()
|
|
||||||
.map(GameType::getName)
|
|
||||||
.toArray(String[]::new);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// MapVote
|
// MapVote
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
game = _game.GetName();
|
game = _game.GetName();
|
||||||
mode = _game.GetMode();
|
mode = _game.GetMode();
|
||||||
map = "Voting";
|
map = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vote<? extends Voteable> vote = _gameCreationManager.getVotingManager().getCurrentVote();
|
||||||
|
|
||||||
|
if (vote != null)
|
||||||
|
{
|
||||||
|
timer = vote.getTimer();
|
||||||
|
votingOn = vote.getValues().stream()
|
||||||
|
.map(Voteable::getDisplayName)
|
||||||
|
.toArray(String[]::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No vote and game null. Staff-1 or pre game voting
|
// No vote and game null. Staff-1 or pre game voting
|
||||||
@ -1087,7 +1088,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
{
|
{
|
||||||
game = _game.GetName();
|
game = _game.GetName();
|
||||||
mode = _game.GetMode();
|
mode = _game.GetMode();
|
||||||
|
|
||||||
|
// Has WorldData
|
||||||
|
if (_game.WorldData != null)
|
||||||
|
{
|
||||||
map = _game.WorldData.MapName;
|
map = _game.WorldData.MapName;
|
||||||
|
}
|
||||||
|
|
||||||
// Game not in progress
|
// Game not in progress
|
||||||
if (_game.inLobby())
|
if (_game.inLobby())
|
||||||
@ -1117,7 +1123,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
hostRank = _gameHostManager.getHostRank();
|
hostRank = _gameHostManager.getHostRank();
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setMotd(new GameInfo(game, mode, map, _serverConfig.ServerType, timer, votingOn, hostRank, status, getJoinable()).toString());
|
event.setMotd(new GameInfo(game, mode, map, timer, votingOn, hostRank, status, getJoinable()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -336,6 +336,12 @@ public enum GameType implements Voteable
|
|||||||
return _display.getName();
|
return _display.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName()
|
||||||
|
{
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
public String GetLobbyName()
|
public String GetLobbyName()
|
||||||
{
|
{
|
||||||
return _display.getLobbyName();
|
return _display.getLobbyName();
|
||||||
|
@ -7,6 +7,8 @@ public interface Voteable
|
|||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
String getDisplayName();
|
||||||
|
|
||||||
ItemStack getItemStack();
|
ItemStack getItemStack();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class VotableMap implements Voteable
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDisplayName()
|
public String getDisplayName()
|
||||||
{
|
{
|
||||||
String[] split = getName().split("_");
|
String[] split = getName().split("_");
|
||||||
|
@ -96,6 +96,8 @@ public class WorldData
|
|||||||
World.setDifficulty(Difficulty.HARD);
|
World.setDifficulty(Difficulty.HARD);
|
||||||
World.setGameRuleValue("showDeathMessages", "false");
|
World.setGameRuleValue("showDeathMessages", "false");
|
||||||
|
|
||||||
|
Host.getArcadeManager().runAsync(() ->
|
||||||
|
{
|
||||||
TimingManager.start("WorldData loading WorldConfig.");
|
TimingManager.start("WorldData loading WorldConfig.");
|
||||||
|
|
||||||
//Load World Data
|
//Load World Data
|
||||||
@ -111,10 +113,12 @@ public class WorldData
|
|||||||
MaxZ = max.getBlockZ();
|
MaxZ = max.getBlockZ();
|
||||||
|
|
||||||
MapName = _mineplexWorld.getMapName();
|
MapName = _mineplexWorld.getMapName();
|
||||||
|
Host.getArcadeManager().GetGameWorldManager().RegisterWorld(this);
|
||||||
|
|
||||||
TimingManager.stop("WorldData loading WorldConfig.");
|
TimingManager.stop("WorldData loading WorldConfig.");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean loadUHCMap()
|
private boolean loadUHCMap()
|
||||||
|
Loading…
Reference in New Issue
Block a user