2013-08-27 17:14:08 +02:00
|
|
|
package mineplex.hub.server;
|
|
|
|
|
2016-07-25 17:18:10 +02:00
|
|
|
import mineplex.core.MiniPlugin;
|
|
|
|
import mineplex.core.account.CoreClientManager;
|
2016-05-24 09:13:33 +02:00
|
|
|
import mineplex.core.boosters.BoosterManager;
|
2016-06-10 06:27:46 +02:00
|
|
|
import mineplex.core.brawl.fountain.BrawlShopProvider;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.Rank;
|
|
|
|
import mineplex.core.common.util.C;
|
2013-09-18 00:50:23 +02:00
|
|
|
import mineplex.core.common.util.Callback;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.NautHashMap;
|
2013-09-27 21:40:09 +02:00
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilAlg;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilTime;
|
|
|
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
|
|
|
import mineplex.core.donation.DonationManager;
|
2013-09-14 00:25:01 +02:00
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
2016-07-25 17:18:10 +02:00
|
|
|
import mineplex.core.party.Lang;
|
2015-02-17 03:17:14 +01:00
|
|
|
import mineplex.core.party.Party;
|
|
|
|
import mineplex.core.party.PartyManager;
|
2016-07-25 17:18:10 +02:00
|
|
|
import mineplex.core.party.event.PartySelectServerEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.portal.Portal;
|
2014-05-27 11:10:29 +02:00
|
|
|
import mineplex.core.shop.ShopBase;
|
2013-09-18 00:50:23 +02:00
|
|
|
import mineplex.core.status.ServerStatusManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
2013-09-27 21:40:09 +02:00
|
|
|
import mineplex.hub.HubManager;
|
|
|
|
import mineplex.hub.modules.StackerManager;
|
2014-05-27 11:10:29 +02:00
|
|
|
import mineplex.hub.queue.QueueManager;
|
2013-10-03 07:23:01 +02:00
|
|
|
import mineplex.hub.server.ui.LobbyShop;
|
2013-09-28 08:06:53 +02:00
|
|
|
import mineplex.hub.server.ui.QuickShop;
|
2015-08-02 19:24:59 +02:00
|
|
|
import mineplex.hub.server.ui.ServerCountSorter;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.hub.server.ui.ServerNpcShop;
|
2015-08-29 23:46:18 +02:00
|
|
|
import mineplex.hub.server.ui.clans.ClansServerShop;
|
2015-08-03 01:59:43 +02:00
|
|
|
import mineplex.serverdata.Region;
|
2015-03-14 01:53:36 +01:00
|
|
|
import mineplex.serverdata.data.MinecraftServer;
|
|
|
|
import mineplex.serverdata.data.ServerGroup;
|
2016-07-25 17:18:10 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
|
|
|
import org.bukkit.event.entity.EntityPortalEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPortalEvent;
|
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
2016-08-23 08:37:05 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2016-07-25 17:18:10 +02:00
|
|
|
public class ServerManager extends MiniPlugin implements BrawlShopProvider
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2016-07-15 07:01:24 +02:00
|
|
|
private static final Long FREE_PORTAL_TIMER = -1L;
|
2014-09-13 09:52:44 +02:00
|
|
|
private static final Long BETA_PORTAL_TIMER = 120000L;
|
2015-08-02 19:24:59 +02:00
|
|
|
private static final Random random = new Random();
|
|
|
|
|
|
|
|
public final int TOP_SERVERS = 3; // The number of top contending servers for auto-joining games
|
|
|
|
public final int MIN_SLOTS_REQUIRED = 12; // The number of slots the max server must have for auto-join
|
2014-08-01 07:38:26 +02:00
|
|
|
|
2015-08-03 03:18:24 +02:00
|
|
|
public final long QUEUE_COOLDOWN = 2000; // Cooldown (in milliseconds) between queueing again for players
|
2013-08-27 17:14:08 +02:00
|
|
|
private CoreClientManager _clientManager;
|
|
|
|
private DonationManager _donationManager;
|
|
|
|
private Portal _portal;
|
2013-09-09 10:28:35 +02:00
|
|
|
private PartyManager _partyManager;
|
2013-09-18 00:50:23 +02:00
|
|
|
private ServerStatusManager _statusManager;
|
2013-09-27 21:40:09 +02:00
|
|
|
private HubManager _hubManager;
|
2016-05-24 09:13:33 +02:00
|
|
|
private BoosterManager _boosterManager;
|
2015-08-03 03:18:24 +02:00
|
|
|
|
|
|
|
private NautHashMap<String, Long> _queueCooldowns = new NautHashMap<String, Long>();
|
2013-10-03 07:23:01 +02:00
|
|
|
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
2015-05-04 07:42:49 +02:00
|
|
|
private NautHashMap<String, Integer> _serverPlayerCounts = new NautHashMap<String, Integer>();
|
2013-08-27 17:14:08 +02:00
|
|
|
private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>();
|
|
|
|
private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>();
|
|
|
|
private NautHashMap<String, Long> _serverUpdate = new NautHashMap<String, Long>();
|
2016-01-04 22:41:07 +01:00
|
|
|
private NautHashMap<Vector, String> _portalToServerKey = new NautHashMap<Vector, String>();
|
2015-12-21 08:23:59 +01:00
|
|
|
|
|
|
|
private ClansServerShop _clansShop;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2014-07-31 22:36:00 +02:00
|
|
|
// Join Time for Free Players Timer
|
2014-08-23 05:53:15 +02:00
|
|
|
private NautHashMap<String, Long> _joinTime = new NautHashMap<String, Long>();
|
2014-07-31 22:36:00 +02:00
|
|
|
|
2013-09-28 08:06:53 +02:00
|
|
|
private QuickShop _quickShop;
|
2013-10-03 07:23:01 +02:00
|
|
|
private LobbyShop _lobbyShop;
|
2013-09-14 00:25:01 +02:00
|
|
|
|
2013-09-18 00:50:23 +02:00
|
|
|
private boolean _alternateUpdateFire = false;
|
|
|
|
private boolean _retrieving = false;
|
2013-10-26 23:36:48 +02:00
|
|
|
private long _lastRetrieve = 0;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2016-05-24 09:13:33 +02:00
|
|
|
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager, BoosterManager boosterManager)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2016-07-25 17:18:10 +02:00
|
|
|
super("Server Manager", plugin);
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
_clientManager = clientManager;
|
|
|
|
_donationManager = donationManager;
|
|
|
|
_portal = portal;
|
2013-09-09 10:28:35 +02:00
|
|
|
_partyManager = partyManager;
|
2013-09-18 00:50:23 +02:00
|
|
|
_statusManager = statusManager;
|
2013-09-27 21:40:09 +02:00
|
|
|
_hubManager = hubManager;
|
2016-05-24 09:13:33 +02:00
|
|
|
_boosterManager = boosterManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
|
|
|
|
2015-08-03 01:59:43 +02:00
|
|
|
loadServers();
|
2013-09-11 22:53:24 +02:00
|
|
|
|
2013-09-28 08:06:53 +02:00
|
|
|
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
|
2013-10-03 07:23:01 +02:00
|
|
|
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
|
2015-08-29 23:46:18 +02:00
|
|
|
|
|
|
|
// TODO: Find more appropriate place to initialize Clans server shop?
|
2015-12-21 08:23:59 +01:00
|
|
|
_clansShop = new ClansServerShop(this, _clientManager, _donationManager);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2013-09-14 00:25:01 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
2013-09-27 21:40:09 +02:00
|
|
|
public void playerPortalEvent(PlayerPortalEvent event)
|
2013-09-14 00:25:01 +02:00
|
|
|
{
|
2013-09-27 21:40:09 +02:00
|
|
|
event.setCancelled(true);
|
2013-09-14 00:25:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 21:40:09 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void entityPortalEvent(EntityPortalEvent event)
|
2013-09-14 00:25:01 +02:00
|
|
|
{
|
2013-09-27 21:40:09 +02:00
|
|
|
event.setCancelled(true);
|
2013-09-14 00:25:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 21:40:09 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void playerCheckPortalEvent(EntityPortalEnterEvent event)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-09-27 21:40:09 +02:00
|
|
|
if (!(event.getEntity() instanceof Player))
|
|
|
|
{
|
2014-06-15 04:35:09 +02:00
|
|
|
if (event.getEntity() instanceof LivingEntity)
|
|
|
|
UtilAction.velocity(event.getEntity(), UtilAlg.getTrajectory(event.getEntity().getLocation(), _hubManager.GetSpawn()), 1, true, 0.8, 0, 1, true);
|
|
|
|
|
2013-09-27 21:40:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-23 08:37:05 +02:00
|
|
|
Player player = (Player)event.getEntity();
|
|
|
|
player.teleport(_hubManager.GetSpawn());
|
|
|
|
runSyncLater(() -> {_quickShop.attemptShopOpen(player);}, 3L);
|
2014-07-31 22:36:00 +02:00
|
|
|
|
2013-09-27 21:40:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-27 11:10:29 +02:00
|
|
|
@EventHandler
|
|
|
|
public void checkQueuePrompts(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.SEC)
|
|
|
|
return;
|
|
|
|
|
2014-06-10 09:00:53 +02:00
|
|
|
/*
|
2014-05-28 20:18:30 +02:00
|
|
|
for (final Player player : _queueManager.findPlayersNeedingPrompt())
|
2014-05-27 11:10:29 +02:00
|
|
|
{
|
2014-05-28 20:18:30 +02:00
|
|
|
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 5f, 1f);
|
|
|
|
|
2015-02-26 06:07:07 +01:00
|
|
|
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable()
|
2014-05-28 20:18:30 +02:00
|
|
|
{
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
if (player.isOnline())
|
|
|
|
{
|
|
|
|
_domShop.attemptShopOpen(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 20);
|
2014-05-27 11:10:29 +02:00
|
|
|
}
|
2014-06-10 09:00:53 +02:00
|
|
|
*/
|
2014-05-27 11:10:29 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 21:40:09 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void playerJoin(PlayerJoinEvent event)
|
|
|
|
{
|
|
|
|
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS.getId(), (byte)0, 1, ChatColor.GREEN + "Game Menu"));
|
2013-10-05 09:59:45 +02:00
|
|
|
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WATCH.getId(), (byte)0, 1, ChatColor.GREEN + "Lobby Menu"));
|
2014-07-31 22:36:00 +02:00
|
|
|
|
|
|
|
if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL)
|
|
|
|
{
|
2014-08-23 05:53:15 +02:00
|
|
|
_joinTime.put(event.getPlayer().getName(), System.currentTimeMillis());
|
2014-07-31 22:36:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void playerQuit(PlayerQuitEvent event)
|
|
|
|
{
|
2014-08-23 05:53:15 +02:00
|
|
|
_joinTime.remove(event.getPlayer().getName());
|
2013-09-27 21:40:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void playerInteract(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
if (event.getItem() != null && event.getItem().getType() == Material.COMPASS)
|
|
|
|
{
|
2013-09-28 08:06:53 +02:00
|
|
|
_quickShop.attemptShopOpen(event.getPlayer());
|
2013-09-27 21:40:09 +02:00
|
|
|
}
|
2013-10-03 07:23:01 +02:00
|
|
|
else if (event.getItem() != null && event.getItem().getType() == Material.WATCH)
|
|
|
|
{
|
|
|
|
_lobbyShop.attemptShopOpen(event.getPlayer());
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2014-07-31 22:36:00 +02:00
|
|
|
|
2014-08-23 05:53:15 +02:00
|
|
|
public Long getMillisecondsUntilPortal(Player player, boolean beta)
|
2014-07-31 22:36:00 +02:00
|
|
|
{
|
2014-08-01 07:38:26 +02:00
|
|
|
// Party party = _partyManager.GetParty(player);
|
2014-07-31 22:36:00 +02:00
|
|
|
long timeLeft = 0;
|
|
|
|
|
2014-08-23 05:53:15 +02:00
|
|
|
if (_joinTime.containsKey(player.getName()))
|
2014-07-31 22:36:00 +02:00
|
|
|
{
|
2014-08-23 05:53:15 +02:00
|
|
|
timeLeft = (_joinTime.get(player.getName()) - System.currentTimeMillis()) + (beta ? BETA_PORTAL_TIMER : FREE_PORTAL_TIMER);
|
|
|
|
|
2014-07-31 22:36:00 +02:00
|
|
|
if (timeLeft <= 0)
|
|
|
|
timeLeft = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return timeLeft;
|
|
|
|
}
|
2016-01-17 10:20:48 +01:00
|
|
|
|
2015-08-03 03:18:24 +02:00
|
|
|
public void addServerGroup(ServerGroup serverGroup)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2015-08-04 20:54:06 +02:00
|
|
|
_serverKeyInfoMap.put(serverGroup.getPrefix(), new HashSet<ServerInfo>());
|
2013-10-03 07:23:01 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void addServerNpc(ServerGroup serverGroup)
|
2013-10-03 07:23:01 +02:00
|
|
|
{
|
2015-08-03 03:18:24 +02:00
|
|
|
_serverNpcShopMap.put(serverGroup.getServerNpcName(), new ServerNpcShop(this, _clientManager, _donationManager, serverGroup));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void removeServerNpc(String serverNpcName)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-10-03 07:23:01 +02:00
|
|
|
Set<ServerInfo> mappedServers = _serverKeyInfoMap.remove(serverNpcName);
|
2013-08-27 17:14:08 +02:00
|
|
|
_serverNpcShopMap.remove(serverNpcName);
|
|
|
|
|
|
|
|
if (mappedServers != null)
|
|
|
|
{
|
|
|
|
for (ServerInfo mappedServer : mappedServers)
|
|
|
|
{
|
|
|
|
boolean isMappedElseWhere = false;
|
|
|
|
|
2013-10-03 07:23:01 +02:00
|
|
|
for (String key : _serverKeyInfoMap.keySet())
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-10-03 07:23:01 +02:00
|
|
|
for (ServerInfo value : _serverKeyInfoMap.get(key))
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
if (value.Name.equalsIgnoreCase(mappedServer.Name))
|
|
|
|
{
|
|
|
|
isMappedElseWhere = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isMappedElseWhere)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isMappedElseWhere)
|
|
|
|
_serverInfoMap.remove(mappedServer.Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 22:41:07 +01:00
|
|
|
public Collection<ServerInfo> getServerList(String serverKey)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2016-01-04 22:41:07 +01:00
|
|
|
return _serverKeyInfoMap.get(serverKey);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public Set<String> getAllServers()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
return _serverInfoMap.keySet();
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public ServerInfo getServerInfo(String serverName)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
return _serverInfoMap.get(serverName);
|
|
|
|
}
|
2016-06-22 07:56:44 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onClickCompassPartyIcon(PartySelectServerEvent event)
|
|
|
|
{
|
|
|
|
_quickShop.attemptShopOpen(event.getPlayer());
|
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
2013-09-14 00:25:01 +02:00
|
|
|
public void updatePages(UpdateEvent event)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-12-24 07:36:33 +01:00
|
|
|
if (event.getType() != UpdateType.SEC)
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
|
2013-09-19 07:11:49 +02:00
|
|
|
_quickShop.UpdatePages();
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2013-09-14 00:25:01 +02:00
|
|
|
for (ServerNpcShop shop : _serverNpcShopMap.values())
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-09-14 00:25:01 +02:00
|
|
|
shop.UpdatePages();
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-14 00:25:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void updateServers(UpdateEvent event)
|
|
|
|
{
|
2013-10-26 23:36:48 +02:00
|
|
|
if (event.getType() != UpdateType.SEC || (_retrieving && System.currentTimeMillis() - _lastRetrieve <= 5000))
|
2013-09-14 00:25:01 +02:00
|
|
|
return;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2013-09-18 00:50:23 +02:00
|
|
|
_alternateUpdateFire = !_alternateUpdateFire;
|
|
|
|
|
|
|
|
if (!_alternateUpdateFire)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_retrieving = true;
|
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
_statusManager.retrieveServerGroups(new Callback<Collection<ServerGroup>>()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-12-23 10:19:24 +01:00
|
|
|
public void run(final Collection<ServerGroup> serverGroups)
|
2013-09-18 00:50:23 +02:00
|
|
|
{
|
2014-12-23 10:19:24 +01:00
|
|
|
final NautHashMap<String, ServerGroup> serverGroupMap = new NautHashMap<String, ServerGroup>();
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
for (ServerGroup serverGroup : serverGroups)
|
|
|
|
{
|
|
|
|
serverGroupMap.put(serverGroup.getName(), serverGroup);
|
2013-09-27 21:40:09 +02:00
|
|
|
}
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
_statusManager.retrieveServerStatuses(new Callback<Collection<MinecraftServer>>()
|
2013-09-27 21:40:09 +02:00
|
|
|
{
|
2014-12-23 10:19:24 +01:00
|
|
|
public void run(Collection<MinecraftServer> serverStatusList)
|
2013-09-27 21:40:09 +02:00
|
|
|
{
|
2015-05-04 07:42:49 +02:00
|
|
|
_serverPlayerCounts.clear();
|
2015-05-10 23:58:04 +02:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
for (MinecraftServer serverStatus : serverStatusList)
|
|
|
|
{
|
|
|
|
if (!_serverInfoMap.containsKey(serverStatus.getName()))
|
|
|
|
{
|
|
|
|
ServerInfo newServerInfo = new ServerInfo();
|
|
|
|
newServerInfo.Name = serverStatus.getName();
|
|
|
|
_serverInfoMap.put(serverStatus.getName(), newServerInfo);
|
|
|
|
}
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
String[] args = serverStatus.getMotd().split("\\|");
|
|
|
|
String tag = (serverStatus.getName() != null && serverStatus.getName().contains("-")) ? serverStatus.getName().split("-")[0] : "N/A";
|
2014-12-23 11:15:33 +01:00
|
|
|
|
|
|
|
//Private Servers
|
|
|
|
if (serverGroupMap.containsKey(serverStatus.getGroup()))
|
|
|
|
{
|
|
|
|
ServerGroup serverGroup = serverGroupMap.get(serverStatus.getGroup());
|
|
|
|
if (serverGroup.getHost() != null && !serverGroup.getHost().isEmpty())
|
|
|
|
tag = "MPS";
|
|
|
|
}
|
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
ServerInfo serverInfo = _serverInfoMap.get(serverStatus.getName());
|
|
|
|
serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.getMotd();
|
|
|
|
serverInfo.CurrentPlayers = serverStatus.getPlayerCount();
|
|
|
|
serverInfo.MaxPlayers = serverStatus.getMaxPlayerCount();
|
2015-12-29 07:50:20 +01:00
|
|
|
|
|
|
|
for (String arg : args)
|
|
|
|
{
|
|
|
|
if (arg != null && arg.startsWith("HostRank.") && arg.length() > "HostRank.".length())
|
|
|
|
{
|
|
|
|
String rankEnum = arg.split("\\.")[1];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
serverInfo.HostRank = Rank.valueOf(rankEnum);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
// Ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
if (args.length > 1)
|
|
|
|
serverInfo.ServerType = args[1];
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
if (args.length > 2)
|
|
|
|
serverInfo.Game = args[2];
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
if (args.length > 3)
|
|
|
|
serverInfo.Map = args[3];
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
_serverUpdate.put(serverStatus.getName(), System.currentTimeMillis());
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
if (_serverKeyInfoMap.containsKey(tag))
|
2014-12-23 10:19:24 +01:00
|
|
|
{
|
2015-08-04 20:54:06 +02:00
|
|
|
_serverKeyInfoMap.get(tag).add(serverInfo);
|
2015-05-10 23:58:04 +02:00
|
|
|
|
2015-05-04 07:42:49 +02:00
|
|
|
if (!_serverPlayerCounts.containsKey(tag))
|
|
|
|
_serverPlayerCounts.put(tag, 0);
|
2015-05-10 23:58:04 +02:00
|
|
|
|
2015-05-04 07:42:49 +02:00
|
|
|
_serverPlayerCounts.put(tag, _serverPlayerCounts.get(tag) + serverInfo.CurrentPlayers);
|
2014-12-23 10:19:24 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
for (String name : _serverUpdate.keySet())
|
|
|
|
{
|
|
|
|
if (_serverUpdate.get(name) != -1L && System.currentTimeMillis() - _serverUpdate.get(name) > 5000)
|
|
|
|
{
|
|
|
|
ServerInfo serverInfo = _serverInfoMap.get(name);
|
|
|
|
serverInfo.MOTD = ChatColor.DARK_RED + "OFFLINE";
|
|
|
|
serverInfo.CurrentPlayers = 0;
|
|
|
|
serverInfo.MaxPlayers = 0;
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
_serverUpdate.put(name, -1L);
|
|
|
|
}
|
|
|
|
}
|
2014-12-23 11:15:33 +01:00
|
|
|
|
2014-12-23 10:19:24 +01:00
|
|
|
// Reset
|
|
|
|
_retrieving = false;
|
|
|
|
_lastRetrieve = System.currentTimeMillis();
|
2013-09-18 00:50:23 +02:00
|
|
|
}
|
2014-12-23 10:19:24 +01:00
|
|
|
});
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-18 00:50:23 +02:00
|
|
|
});
|
2015-08-03 03:18:24 +02:00
|
|
|
|
|
|
|
updateCooldowns();
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void help(Player caller, String message)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
UtilPlayer.message(caller, F.main(_moduleName, "Commands List:"));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc create <name>", "<name> is name of npc.", Rank.OWNER));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc delete <name>", "<name> is name of npc.", Rank.OWNER));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc addserver <servernpc> | <name>", "Adds server.", Rank.OWNER));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc removeserver <name>", "Removes server.", Rank.OWNER));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc listnpcs", "Lists all server npcs.", Rank.OWNER));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc listservers <servernpc>", "Lists all servers.", Rank.OWNER));
|
|
|
|
UtilPlayer.message(caller, F.help("/servernpc listoffline", "Shows all servers offline.", Rank.OWNER));
|
|
|
|
|
|
|
|
if (message != null)
|
|
|
|
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void help(Player caller)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2015-08-04 20:54:06 +02:00
|
|
|
help(caller, null);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2013-09-09 10:28:35 +02:00
|
|
|
public PartyManager getPartyManager()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-09-09 10:28:35 +02:00
|
|
|
return _partyManager;
|
|
|
|
}
|
|
|
|
|
2016-06-23 00:28:43 +02:00
|
|
|
public void selectServer(Player player, ServerInfo serverInfo)
|
2013-09-09 10:28:35 +02:00
|
|
|
{
|
2016-06-23 00:28:43 +02:00
|
|
|
Party party = _partyManager.getParty(player);
|
|
|
|
if(party != null)
|
2013-09-09 10:28:35 +02:00
|
|
|
{
|
2016-06-23 00:28:43 +02:00
|
|
|
if(!party.getOwner().equalsIgnoreCase(player.getName()))
|
|
|
|
{
|
|
|
|
Lang.NOT_OWNER_SERVER.send(player);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_partyManager.getJoinManager().requestServerJoin(serverInfo.Name, party);
|
|
|
|
return;
|
2013-09-09 10:28:35 +02:00
|
|
|
}
|
2016-06-05 05:41:01 +02:00
|
|
|
player.leaveVehicle();
|
|
|
|
player.eject();
|
|
|
|
|
|
|
|
_portal.sendPlayerToServer(player, serverInfo.Name);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2015-08-02 19:24:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Select a {@code serverType} for a {@code player} that wishes to automatically join the best server
|
|
|
|
* available for that server type.
|
|
|
|
* @param player - the player hoping to select a server
|
|
|
|
* @param serverType - the name of the type of server to be joined
|
|
|
|
*/
|
|
|
|
public void selectServer(Player player, String serverType)
|
|
|
|
{
|
2015-08-03 03:18:24 +02:00
|
|
|
if (isOnCooldown(player))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-02 19:24:59 +02:00
|
|
|
ServerInfo bestServer = getBestServer(player, serverType);
|
|
|
|
|
|
|
|
if (bestServer != null)
|
|
|
|
{
|
2015-08-04 20:54:06 +02:00
|
|
|
selectServer(player, bestServer);
|
2015-08-03 03:18:24 +02:00
|
|
|
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()
|
|
|
|
{
|
2015-08-05 08:33:09 +02:00
|
|
|
for (Iterator<String> playerIterator = _queueCooldowns.keySet().iterator(); playerIterator.hasNext();)
|
2015-08-03 03:18:24 +02:00
|
|
|
{
|
2015-08-05 08:33:09 +02:00
|
|
|
Player player = Bukkit.getPlayer(playerIterator.next());
|
2015-08-03 03:18:24 +02:00
|
|
|
|
|
|
|
if (player == null || !isOnCooldown(player))
|
|
|
|
{
|
2015-08-05 08:33:09 +02:00
|
|
|
playerIterator.remove();
|
2015-08-03 03:18:24 +02:00
|
|
|
}
|
2015-08-02 19:24:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-22 07:59:22 +02:00
|
|
|
* @param serverKey - the type of server that should be fetched
|
2015-08-02 19:24:59 +02:00
|
|
|
* @return the best server that a new player should join according to a {@code serverType} constraint.
|
|
|
|
*/
|
2015-08-03 03:18:24 +02:00
|
|
|
public ServerInfo getBestServer(Player player, String serverKey)
|
2015-08-02 19:24:59 +02:00
|
|
|
{
|
2015-08-04 20:54:06 +02:00
|
|
|
Collection<ServerInfo> serverList = getServerList(serverKey);
|
2015-08-03 03:18:24 +02:00
|
|
|
if (serverList == null) return null;
|
|
|
|
|
|
|
|
List<ServerInfo> servers = new ArrayList<ServerInfo>(serverList);
|
2015-08-02 19:24:59 +02:00
|
|
|
servers = fetchOpenServers(player, servers, servers.size()); // Removes all full servers from list
|
2015-08-03 12:55:33 +02:00
|
|
|
Collections.sort(servers, new ServerCountSorter());
|
|
|
|
|
2015-08-02 19:24:59 +02:00
|
|
|
int count = Math.min(servers.size(), TOP_SERVERS);
|
2015-08-03 00:20:52 +02:00
|
|
|
|
2015-08-02 19:24:59 +02:00
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
ServerInfo largestServer = servers.get(0);
|
|
|
|
|
2015-08-03 09:07:23 +02:00
|
|
|
if (largestServer.getAvailableSlots() >= MIN_SLOTS_REQUIRED || largestServer.MaxPlayers > 40)
|
2015-08-02 19:24:59 +02:00
|
|
|
{
|
|
|
|
return largestServer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return servers.get(random.nextInt(count));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<ServerInfo> fetchOpenServers(Player player, List<ServerInfo> servers, int count)
|
|
|
|
{
|
|
|
|
List<ServerInfo> results = new ArrayList<ServerInfo>();
|
2015-08-04 20:54:06 +02:00
|
|
|
int requiredSlots = (servers.size() > 0) ? getRequiredSlots(player, servers.get(0).ServerType) : 0;
|
2015-08-02 19:24:59 +02:00
|
|
|
|
|
|
|
for (ServerInfo server : servers)
|
|
|
|
{
|
2015-08-03 09:56:24 +02:00
|
|
|
if (isInProgress(server))
|
|
|
|
continue;
|
|
|
|
|
2015-08-02 19:24:59 +02:00
|
|
|
if (results.size() >= count) break;
|
|
|
|
|
|
|
|
if (server.getAvailableSlots() > requiredSlots)
|
|
|
|
{
|
|
|
|
results.add(server);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
2015-08-03 09:56:24 +02:00
|
|
|
|
|
|
|
private boolean isInProgress(ServerInfo serverInfo)
|
|
|
|
{
|
|
|
|
return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting");
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void listServerNpcs(Player caller)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-11-13 04:21:12 +01:00
|
|
|
UtilPlayer.message(caller, F.main(getName(), "Listing Server Npcs:"));
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2013-10-03 07:23:01 +02:00
|
|
|
for (String serverNpc : _serverKeyInfoMap.keySet())
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-11-13 04:21:12 +01:00
|
|
|
UtilPlayer.message(caller, F.main(getName(), C.cYellow + serverNpc));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void listServers(Player caller, String serverNpcName)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-11-13 04:21:12 +01:00
|
|
|
UtilPlayer.message(caller, F.main(getName(), "Listing Servers for '" + serverNpcName + "':"));
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2013-10-03 07:23:01 +02:00
|
|
|
for (ServerInfo serverNpc : _serverKeyInfoMap.get(serverNpcName))
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-11-13 04:21:12 +01:00
|
|
|
UtilPlayer.message(caller, F.main(getName(), C.cYellow + serverNpc.Name + C.cWhite + " - " + serverNpc.MOTD + " " + serverNpc.CurrentPlayers + "/" + serverNpc.MaxPlayers));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public void listOfflineServers(Player caller)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-11-13 04:21:12 +01:00
|
|
|
UtilPlayer.message(caller, F.main(getName(), "Listing Offline Servers:"));
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
for (ServerInfo serverNpc : _serverInfoMap.values())
|
|
|
|
{
|
|
|
|
if (serverNpc.MOTD.equalsIgnoreCase(ChatColor.DARK_RED + "OFFLINE"))
|
|
|
|
{
|
2014-11-13 04:21:12 +01:00
|
|
|
UtilPlayer.message(caller, F.main(getName(), C.cYellow + serverNpc.Name + C.cWhite + " - " + F.time(UtilTime.convertString(System.currentTimeMillis() - _serverUpdate.get(serverNpc.Name), 0, TimeUnit.FIT))));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-03 01:59:43 +02:00
|
|
|
public void loadServers()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2013-09-11 22:53:24 +02:00
|
|
|
_serverInfoMap.clear();
|
|
|
|
_serverUpdate.clear();
|
|
|
|
|
2013-10-03 07:23:01 +02:00
|
|
|
for (String npcName : _serverKeyInfoMap.keySet())
|
2013-09-11 22:53:24 +02:00
|
|
|
{
|
2013-10-03 07:23:01 +02:00
|
|
|
_serverKeyInfoMap.get(npcName).clear();
|
2013-09-11 22:53:24 +02:00
|
|
|
}
|
2013-09-27 21:40:09 +02:00
|
|
|
|
2015-08-03 01:59:43 +02:00
|
|
|
Region region = getPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
2013-09-11 22:53:24 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
try
|
|
|
|
{
|
2015-08-03 01:59:43 +02:00
|
|
|
for (ServerGroup serverGroup : mineplex.serverdata.servers.ServerManager.getServerRepository(region).getServerGroups(null))
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2015-08-03 10:20:27 +02:00
|
|
|
addServerGroup(serverGroup);
|
2015-08-03 12:55:33 +02:00
|
|
|
|
2015-08-03 01:59:43 +02:00
|
|
|
if (!serverGroup.getServerNpcName().isEmpty())
|
2015-08-04 20:54:06 +02:00
|
|
|
addServerNpc(serverGroup);
|
2015-08-03 01:59:43 +02:00
|
|
|
|
|
|
|
if (!serverGroup.getPortalBottomCornerLocation().isEmpty() && !serverGroup.getPortalTopCornerLocation().isEmpty())
|
|
|
|
{
|
|
|
|
Vector bottomVector = ParseVector(serverGroup.getPortalBottomCornerLocation());
|
|
|
|
Vector topVector = ParseVector(serverGroup.getPortalTopCornerLocation());
|
|
|
|
int blocks = 0;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2015-08-03 01:59:43 +02:00
|
|
|
while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ()))
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2016-01-04 22:41:07 +01:00
|
|
|
_portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix());
|
2015-08-03 01:59:43 +02:00
|
|
|
|
|
|
|
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++;
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2016-01-04 22:41:07 +01:00
|
|
|
_portalToServerKey.put(bottomVector, serverGroup.getPrefix());
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2015-08-03 01:59:43 +02:00
|
|
|
System.out.println("ServerManager - Error parsing servergroups : " + e.getMessage());
|
2013-09-11 22:53:24 +02:00
|
|
|
}
|
2015-08-03 02:41:42 +02:00
|
|
|
|
2015-08-07 17:58:53 +02:00
|
|
|
// AddServerNpc("Event Servers", "EVENT");
|
|
|
|
// AddServerNpc("Mineplex Player Servers", "MPS");
|
2015-08-11 01:47:53 +02:00
|
|
|
|
2015-08-03 07:53:06 +02:00
|
|
|
ServerGroup eventGroup = new ServerGroup("Event", "Event Servers", "EVENT");
|
|
|
|
ServerGroup mpsGroup = new ServerGroup("MPS", "Mineplex Player Servers", "MPS");
|
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
addServerNpc(eventGroup);
|
2015-08-03 07:53:06 +02:00
|
|
|
addServerGroup(eventGroup);
|
2015-08-04 20:54:06 +02:00
|
|
|
addServerNpc(mpsGroup);
|
2015-08-03 07:53:06 +02:00
|
|
|
addServerGroup(mpsGroup);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-09 10:28:35 +02:00
|
|
|
|
2015-08-04 20:54:06 +02:00
|
|
|
public int getRequiredSlots(Player player, String serverType)
|
2013-09-09 10:28:35 +02:00
|
|
|
{
|
|
|
|
int slots = 0;
|
2016-06-05 05:41:01 +02:00
|
|
|
|
2016-06-08 01:33:03 +02:00
|
|
|
if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player).OwnsUnknownPackage(serverType + " ULTRA"))
|
2016-06-05 05:41:01 +02:00
|
|
|
slots++;
|
2013-09-09 10:28:35 +02:00
|
|
|
|
|
|
|
return slots;
|
|
|
|
}
|
2013-09-19 07:11:49 +02:00
|
|
|
|
|
|
|
public ServerNpcShop getMixedArcadeShop()
|
|
|
|
{
|
2013-09-27 21:40:09 +02:00
|
|
|
return _serverNpcShopMap.get("Mixed Arcade");
|
2013-09-19 07:11:49 +02:00
|
|
|
}
|
2015-08-03 14:36:51 +02:00
|
|
|
|
|
|
|
public ServerNpcShop getServerNPCShopByName(String name)
|
|
|
|
{
|
|
|
|
for(String shop : _serverNpcShopMap.keySet())
|
|
|
|
{
|
|
|
|
if(shop.equalsIgnoreCase(name))
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get(shop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2013-09-19 07:11:49 +02:00
|
|
|
|
|
|
|
public ServerNpcShop getSuperSmashMobsShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Super Smash Mobs");
|
|
|
|
}
|
|
|
|
|
2014-05-27 11:10:29 +02:00
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
public ShopBase getDominateShop()
|
2013-09-19 07:11:49 +02:00
|
|
|
{
|
2014-06-10 09:00:53 +02:00
|
|
|
return _serverNpcShopMap.get("Dominate");
|
2013-09-19 07:11:49 +02:00
|
|
|
}
|
2015-12-21 08:23:59 +01:00
|
|
|
|
|
|
|
public ServerNpcShop getCtfShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Capture the Flag");
|
|
|
|
}
|
2013-09-19 07:11:49 +02:00
|
|
|
|
|
|
|
public ServerNpcShop getBridgesShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("The Bridges");
|
|
|
|
}
|
2013-09-27 21:40:09 +02:00
|
|
|
|
2013-11-23 11:04:22 +01:00
|
|
|
public ServerNpcShop getSurvivalGamesShop()
|
|
|
|
{
|
2013-12-18 11:22:40 +01:00
|
|
|
return _serverNpcShopMap.get("Survival Games");
|
2013-11-23 11:04:22 +01:00
|
|
|
}
|
|
|
|
|
2016-01-29 09:56:49 +01:00
|
|
|
public ServerNpcShop getSpeedBuildersShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Speed Builders");
|
|
|
|
}
|
|
|
|
|
2013-11-23 11:04:22 +01:00
|
|
|
public ServerNpcShop getBlockHuntShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Block Hunt");
|
|
|
|
}
|
2015-05-10 23:58:04 +02:00
|
|
|
|
|
|
|
public ServerNpcShop getBetaShop()
|
|
|
|
{
|
2015-12-21 10:35:57 +01:00
|
|
|
return _serverNpcShopMap.get("Beta Monster Maze");
|
2015-05-10 23:58:04 +02:00
|
|
|
}
|
2015-12-21 08:23:59 +01:00
|
|
|
|
2015-05-14 05:52:14 +02:00
|
|
|
public ServerNpcShop getUHCShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Ultra Hardcore");
|
|
|
|
}
|
|
|
|
|
2015-06-26 09:31:35 +02:00
|
|
|
public ServerNpcShop getSKYShop()
|
|
|
|
{
|
2015-08-03 09:56:24 +02:00
|
|
|
return _serverNpcShopMap.get("Skywars");
|
2015-06-26 09:31:35 +02:00
|
|
|
}
|
|
|
|
|
2015-05-10 23:58:04 +02:00
|
|
|
public ServerNpcShop getPlayerGamesShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Mineplex Player Servers");
|
|
|
|
}
|
2013-11-23 11:04:22 +01:00
|
|
|
|
2015-12-21 08:23:59 +01:00
|
|
|
public ServerNpcShop getShop(String name)
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get(name);
|
|
|
|
}
|
|
|
|
|
2013-09-27 21:40:09 +02:00
|
|
|
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;
|
2013-09-19 07:11:49 +02:00
|
|
|
}
|
2013-10-03 07:23:01 +02:00
|
|
|
|
|
|
|
public ServerStatusManager getStatusManager()
|
|
|
|
{
|
|
|
|
return _statusManager;
|
|
|
|
}
|
2014-06-15 06:27:21 +02:00
|
|
|
|
|
|
|
public ShopBase<ServerManager> getCastleSiegeShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Castle Siege");
|
|
|
|
}
|
2014-08-09 07:06:44 +02:00
|
|
|
|
|
|
|
public HubManager getHubManager()
|
|
|
|
{
|
|
|
|
return _hubManager;
|
|
|
|
}
|
2014-08-26 08:56:58 +02:00
|
|
|
|
|
|
|
public ShopBase<ServerManager> getDrawMyThingShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Draw My Thing");
|
|
|
|
}
|
|
|
|
|
|
|
|
public ShopBase<ServerManager> getTeamDeathmatchShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Team Deathmatch");
|
|
|
|
}
|
2014-10-11 11:32:02 +02:00
|
|
|
|
|
|
|
public ShopBase<ServerManager> getMinestrikeShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Mine-Strike");
|
|
|
|
}
|
2015-05-01 08:24:01 +02:00
|
|
|
|
|
|
|
public ShopBase<ServerManager> getWizardShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Wizards");
|
|
|
|
}
|
2015-05-04 07:42:49 +02:00
|
|
|
|
|
|
|
public int getGroupTagPlayerCount(String tag)
|
|
|
|
{
|
|
|
|
if (_serverPlayerCounts.containsKey(tag))
|
|
|
|
return _serverPlayerCounts.get(tag);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ShopBase<ServerManager> getBuildShop()
|
|
|
|
{
|
2015-05-04 08:40:57 +02:00
|
|
|
return _serverNpcShopMap.get("Master Builders");
|
2015-05-04 07:42:49 +02:00
|
|
|
}
|
2015-12-21 08:23:59 +01:00
|
|
|
|
|
|
|
public ClansServerShop getClansShop()
|
|
|
|
{
|
|
|
|
return _clansShop;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ShopBase<ServerManager> getTypeWarsShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Type Wars");
|
|
|
|
}
|
2016-02-12 12:27:50 +01:00
|
|
|
|
|
|
|
public ShopBase<ServerManager> getValentinesShop()
|
|
|
|
{
|
2016-02-16 23:54:05 +01:00
|
|
|
return _serverNpcShopMap.get("Valentines Vendetta");
|
2016-02-12 12:27:50 +01:00
|
|
|
}
|
2016-04-04 20:47:45 +02:00
|
|
|
|
2016-06-10 06:27:46 +02:00
|
|
|
public ShopBase<ServerManager> getBrawlShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Weekend Brawl");
|
|
|
|
}
|
|
|
|
|
2016-07-13 20:40:31 +02:00
|
|
|
public ShopBase<ServerManager> getBawkShop()
|
|
|
|
{
|
|
|
|
return _serverNpcShopMap.get("Bawk Bawk Battles");
|
|
|
|
}
|
2016-05-24 09:13:33 +02:00
|
|
|
|
|
|
|
public BoosterManager getBoosterManager()
|
|
|
|
{
|
|
|
|
return _boosterManager;
|
|
|
|
}
|
2016-07-25 17:18:10 +02:00
|
|
|
}
|