Merge branch 'master' of ssh://198.245.50.91:7999/min/master

This commit is contained in:
Chiss 2013-10-05 07:49:21 +10:00
commit ab45c717dd
32 changed files with 667 additions and 788 deletions

View File

@ -0,0 +1,52 @@
package mineplex.core.disguise.disguises;
public abstract class DisguiseTameableAnimal extends DisguiseAnimal
{
public DisguiseTameableAnimal(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(16, Byte.valueOf((byte)0));
DataWatcher.a(17, "");
}
public boolean isTamed()
{
return (DataWatcher.getByte(16) & 0x4) != 0;
}
public void setTamed(boolean tamed)
{
int i = DataWatcher.getByte(16);
if (tamed)
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0x4)));
else
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0xFFFFFFFB)));
}
public boolean isSitting()
{
return (DataWatcher.getByte(16) & 0x1) != 0;
}
public void setSitting(boolean sitting)
{
int i = DataWatcher.getByte(16);
if (sitting)
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0x1)));
else
DataWatcher.watch(16, Byte.valueOf((byte)(i | 0xFFFFFFFE)));
}
public void setOwnerName(String name)
{
DataWatcher.watch(17, name);
}
public String getOwnerName()
{
return DataWatcher.getString(17);
}
}

View File

@ -0,0 +1,64 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_6_R3.BlockCloth;
public class DisguiseWolf extends DisguiseTameableAnimal
{
public DisguiseWolf(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(18, new Float(20F));
DataWatcher.a(19, new Byte((byte)0));
DataWatcher.a(20, new Byte((byte)BlockCloth.j_(1)));
}
public boolean isAngry()
{
return (DataWatcher.getByte(16) & 0x2) != 0;
}
public void setAngry(boolean angry)
{
byte b0 = DataWatcher.getByte(16);
if (angry)
DataWatcher.watch(16, Byte.valueOf((byte)(b0 | 0x2)));
else
DataWatcher.watch(16, Byte.valueOf((byte)(b0 & 0xFFFFFFFD)));
}
public int getCollarColor()
{
return DataWatcher.getByte(20) & 0xF;
}
public void setCollarColor(int i)
{
DataWatcher.watch(20, Byte.valueOf((byte)(i & 0xF)));
}
public void m(boolean flag)
{
if (flag)
DataWatcher.watch(19, Byte.valueOf((byte)1));
else
DataWatcher.watch(19, Byte.valueOf((byte)0));
}
public boolean ce()
{
return DataWatcher.getByte(19) == 1;
}
@Override
protected int GetEntityTypeId()
{
return 95;
}
protected String getHurtSound()
{
return "mob.wolf.hurt";
}
}

View File

@ -1,43 +1,17 @@
package mineplex.core.portal;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.arena.Region;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.portal.commands.PortalCommand;
public class Portal extends MiniPlugin
{
private NautHashMap<Region, String> _portalServerMap = new NautHashMap<Region, String>();
private NautHashMap<String, Entry<Location, Location>> _portalSetupMap = new NautHashMap<String, Entry<Location, Location>>();
private HashSet<String> _connectingPlayers = new HashSet<String>();
public Portal(JavaPlugin plugin)
@ -45,51 +19,6 @@ public class Portal extends MiniPlugin
super("Portal", plugin);
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
LoadPortals();
}
public void AddCommands()
{
AddCommand(new PortalCommand(this));
}
@EventHandler
public void OnPlayerMove(PlayerMoveEvent event)
{
for (Region region : _portalServerMap.keySet())
{
if (region.Contains(event.getTo().toVector()))
{
SendPlayerToServer(event.getPlayer(), _portalServerMap.get(region));
break;
}
}
}
@EventHandler
public void OnPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (player.isOp() && _portalSetupMap.containsKey(player.getName()))
{
if (player.getItemInHand() != null && player.getItemInHand().getType() == Material.BLAZE_ROD)
{
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{
_portalSetupMap.put(player.getName(), new AbstractMap.SimpleEntry<Location, Location>(event.getClickedBlock().getLocation(), null));
player.sendMessage(F.main(GetName(), "Set first point."));
}
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
_portalSetupMap.get(player.getName()).setValue(event.getClickedBlock().getLocation());
player.sendMessage(F.main(GetName(), "Set second point."));
}
event.setCancelled(true);
}
}
}
public void SendAllPlayers(String serverName)
@ -140,179 +69,4 @@ public class Portal extends MiniPlugin
}
}, 20L);
}
public void Help(Player caller, String message)
{
UtilPlayer.message(caller, F.main(_moduleName, "Commands List:"));
UtilPlayer.message(caller, F.help("/portal toggle", "Turn off and on Portal mode.", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/portal create <name>", "Creates portal to name server.", Rank.OWNER));
if (message != null)
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
}
public void Help(Player caller)
{
Help(caller, null);
}
public void LoadPortals()
{
FileInputStream fstream = null;
BufferedReader br = null;
try
{
File portalsFile = new File("portals.dat");
if (portalsFile.exists())
{
fstream = new FileInputStream(portalsFile);
br = new BufferedReader(new InputStreamReader(fstream));
String line = br.readLine();
while (line != null)
{
Region region = ParseRegion(line);
_portalServerMap.put(region, region.GetName());
line = br.readLine();
}
}
}
catch (Exception e)
{
System.out.println(F.main(GetName(), "Error parsing portals file."));
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
if (fstream != null)
{
try
{
fstream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
public void SavePortals()
{
FileWriter fstream = null;
BufferedWriter out = null;
try
{
fstream = new FileWriter("portals.dat");
out = new BufferedWriter(fstream);
for (Region region : _portalServerMap.keySet())
{
out.write(region.GetMinimumPoint().getBlockX() + " " + region.GetMinimumPoint().getBlockY() + " " + region.GetMinimumPoint().getBlockZ() + ", " + region.GetMaximumPoint().getBlockX() + " " + region.GetMaximumPoint().getBlockY() + " " + region.GetMaximumPoint().getBlockZ() + ", " + region.GetName());
out.newLine();
}
out.close();
}
catch (Exception e)
{
System.err.println("Portals Save Error: " + e.getMessage());
}
finally
{
if (out != null)
{
try
{
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
if (fstream != null)
{
try
{
fstream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
private Region ParseRegion(String value)
{
String [] parts = value.split(",");
Vector pointOne = ParseVector(parts[0].trim());
Vector pointTwo = ParseVector(parts[1].trim());
return new Region(parts.length == 3 ? parts[2].trim() : "Null", pointOne, pointTwo);
}
private Vector ParseVector(String vectorString)
{
Vector vector = new Vector();
String [] parts = vectorString.split(" ");
vector.setX(Double.parseDouble(parts[0]));
vector.setY(Double.parseDouble(parts[1]));
vector.setZ(Double.parseDouble(parts[2]));
return vector;
}
public void ToggleSetupAdmin(Player caller)
{
if (_portalSetupMap.containsKey(caller.getName()))
{
_portalSetupMap.remove(caller.getName());
caller.sendMessage(F.main(GetName(), "Disabled Portal Setup."));
}
else
{
_portalSetupMap.put(caller.getName(), new AbstractMap.SimpleEntry<Location, Location>(null, null));
caller.sendMessage(F.main(GetName(), "Enabled Portal Setup."));
}
}
public boolean IsAdminPortalValid(Player caller)
{
return _portalSetupMap.containsKey(caller.getName()) && _portalSetupMap.get(caller.getName()).getKey() != null && _portalSetupMap.get(caller.getName()).getValue() != null;
}
public void CreatePortal(Player caller, String name)
{
Vector first = _portalSetupMap.get(caller.getName()).getKey().toVector();
Vector second = _portalSetupMap.get(caller.getName()).getValue().toVector();
_portalServerMap.put(new Region(name, first, second), name);
caller.sendMessage(F.main(GetName(), "Created '" + name + "' portal at (" + first.toString() + ") and (" + second.toString() + "."));
SavePortals();
}
}

View File

@ -1,37 +0,0 @@
package mineplex.core.portal.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.portal.Portal;
public class CreateCommand extends CommandBase<Portal>
{
public CreateCommand(Portal plugin)
{
super(plugin, Rank.ADMIN, "create");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (!Plugin.IsAdminPortalValid(caller))
{
Plugin.Help(caller, "You don't have two points set. Use Blaze rod to set them.");
}
else
{
String serverName = args[0];
Plugin.CreatePortal(caller, serverName);
}
}
}
}

View File

@ -1,24 +0,0 @@
package mineplex.core.portal.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.core.portal.Portal;
public class PortalCommand extends MultiCommandBase<Portal>
{
public PortalCommand(Portal plugin)
{
super(plugin, Rank.ADMIN, "portal");
AddCommand(new CreateCommand(plugin));
AddCommand(new ToggleCommand(plugin));
}
@Override
protected void Help(Player caller, String[] args)
{
Plugin.Help(caller);
}
}

View File

@ -1,21 +0,0 @@
package mineplex.core.portal.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.portal.Portal;
public class ToggleCommand extends CommandBase<Portal>
{
public ToggleCommand(Portal plugin)
{
super(plugin, Rank.ADMIN, "toggle");
}
@Override
public void Execute(final Player caller, String[] args)
{
Plugin.ToggleSetupAdmin(caller);
}
}

View File

@ -9,8 +9,6 @@ import java.util.Enumeration;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -26,7 +24,10 @@ public class ServerStatusManager extends MiniPlugin
private ServerStatusRepository _repository;
private LagMeter _lagMeter;
private String _name;
private boolean _alternateSeconds;
private boolean _enabled = true;
public ServerStatusManager(JavaPlugin plugin, LagMeter lagMeter)
{
@ -34,6 +35,9 @@ public class ServerStatusManager extends MiniPlugin
_lagMeter = lagMeter;
if (new File("IgnoreUpdates.dat").exists())
_enabled = false;
ServerListPingEvent event = new ServerListPingEvent(null, plugin.getServer().getMotd(), plugin.getServer().getOnlinePlayers().length, plugin.getServer().getMaxPlayers());
GetPluginManager().callEvent(event);
@ -78,16 +82,20 @@ public class ServerStatusManager extends MiniPlugin
e.printStackTrace();
}
_name = plugin.getConfig().getString("serverstatus.name");
try
{
_repository = new ServerStatusRepository(
plugin.getConfig().getString("serverstatus.connectionurl"),
plugin.getConfig().getString("serverstatus.username"),
plugin.getConfig().getString("serverstatus.password"),
plugin.getConfig().getString("serverstatus.name"),
_name,
plugin.getConfig().getString("serverstatus.group"),
address + ":" + _plugin.getServer().getPort(), event.getMaxPlayers()
);
if (_enabled)
_repository.initialize();
}
catch (Exception ex)
@ -143,6 +151,9 @@ public class ServerStatusManager extends MiniPlugin
if (event.getType() != UpdateType.SEC)
return;
if (!_enabled)
return;
_alternateSeconds = !_alternateSeconds;
if (!_alternateSeconds)
@ -160,4 +171,9 @@ public class ServerStatusManager extends MiniPlugin
}
});
}
public String getCurrentServerName()
{
return _name;
}
}

View File

@ -26,6 +26,7 @@ import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.hub.modules.StackerManager;
import mineplex.hub.party.PartyManager;
import mineplex.hub.server.ServerManager;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -79,8 +80,8 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
PacketHandler packetHandler = new PacketHandler(this);
Portal portal = new Portal(this);
PartyManager partyManager = new PartyManager(this, clientManager);
new HubManager(this, clientManager, donationManager, new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)));
HubManager hubManager = new HubManager(this, clientManager, donationManager, new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)), hubManager, new StackerManager(hubManager));
new Chat(this, clientManager);
new MemoryFix(this);
new FileUpdater(this, portal);

View File

@ -66,7 +66,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
private PartyManager _partyManager;
private Portal _portal;
private TutorialManager _tutorialManager;
private TextManager _textCreator;
private ParkourManager _parkour;
@ -102,7 +101,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
new MapManager(this);
new WorldManager(this);
new JumpManager(this);
new StackerManager(this);
_partyManager = partyManager;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
@ -212,18 +210,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
if (((LivingEntity)entity).isCustomNameVisible() && ((LivingEntity)entity).getCustomName() != null)
{
if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("play minekart plz"))
if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Minekart"))
{
_disguiseManager.disguise(new DisguisePlayer(entity, ChatColor.YELLOW + "MineKart"));
}
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("defek7"))
_disguiseManager.disguise(new DisguisePlayer(entity, "defek7"));
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("chiss"))
_disguiseManager.disguise(new DisguisePlayer(entity, "Chiss"));
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("Sterling_"))
_disguiseManager.disguise(new DisguisePlayer(entity, "sterling_"));
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("Spu_"))
_disguiseManager.disguise(new DisguisePlayer(entity, "Spu_"));
}
}
}

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEntityEvent;
@ -99,6 +100,15 @@ public class ParkourManager extends MiniPlugin
}
}
@EventHandler
public void combustPrevent(EntityCombustEvent event)
{
if (event.getEntity() instanceof Player)
{
event.setCancelled(true);
}
}
@EventHandler
public void LavaReturn(EntityDamageEvent event)
{
@ -108,7 +118,6 @@ public class ParkourManager extends MiniPlugin
event.getEntity().eject();
event.getEntity().leaveVehicle();
event.getEntity().teleport(_lavaParkourReturn);
event.getEntity().setFireTicks(0);
}
else
@ -117,6 +126,27 @@ public class ParkourManager extends MiniPlugin
event.setCancelled(true);
}
@EventHandler
public void preventCarriers(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
if (InParkour(player))
{
if (player.getVehicle() != null || player.getPassenger() != null)
{
player.eject();
player.leaveVehicle();
UtilPlayer.message(player, F.main("Parkour", "You can't run parkours while stacked!"));
}
}
}
}
@EventHandler
public void LavaBlockReturn(UpdateEvent event)
{
@ -201,7 +231,7 @@ public class ParkourManager extends MiniPlugin
{
final Player player = event.getPlayer();
if (Recharge.Instance.use(player, "Finish Parkour", 30000, false))
if (!Recharge.Instance.use(player, "Finish Parkour", 30000, false))
return;
for (ParkourData data : _parkour)

View File

@ -246,6 +246,9 @@ public class StackerManager extends MiniPlugin implements IThrown
if (target == null)
return;
if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null))
return;
//Velocity
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown(), target), 1, true, 0.8, 0, 10, true);

View File

@ -51,7 +51,9 @@ public class TextManager extends MiniPlugin
"DEATH TAG",
"TURF WARS",
"DRAGONS",
"RUNNER"
"RUNNER",
"BACON BRAWL",
"SQUID SAUCE"
};
CreateText();
@ -82,10 +84,10 @@ public class TextManager extends MiniPlugin
UtilText.MakeText("THE BRIDGES", locSurvival.clone().add(-15, 14, 0), faceSurvival, 159, (byte)4, TextAlign.CENTER);
UtilText.MakeText("THE BRIDGES", locSurvival.clone().add(-16, 14, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER);
/*
UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-15, 21, 0), faceSurvival, 159, (byte)1, TextAlign.CENTER);
UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-16, 21, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER);
*/
//Other
UtilText.MakeText("CLASSICS", locClassics, faceOther, 159, (byte)5, TextAlign.CENTER);

View File

@ -0,0 +1,14 @@
package mineplex.hub.server;
import java.util.Comparator;
public class LobbySorter implements Comparator<ServerInfo>
{
public int compare(ServerInfo a, ServerInfo b)
{
if (Integer.parseInt(a.Name.split("-")[1]) < Integer.parseInt(b.Name.split("-")[1]))
return -1;
return 1;
}
}

View File

@ -1,13 +1,13 @@
package mineplex.hub.server;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -17,9 +17,13 @@ import org.bukkit.Material;
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.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
@ -28,20 +32,25 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.portal.Portal;
import mineplex.core.recharge.Recharge;
import mineplex.core.status.ServerStatusData;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.StackerManager;
import mineplex.hub.party.Party;
import mineplex.hub.party.PartyManager;
import mineplex.hub.server.command.ServerNpcCommand;
import mineplex.hub.server.ui.ServerGameMenu;
import mineplex.hub.server.ui.LobbyShop;
import mineplex.hub.server.ui.QuickShop;
import mineplex.hub.server.ui.ServerNpcShop;
public class ServerManager extends MiniPlugin
@ -51,19 +60,23 @@ public class ServerManager extends MiniPlugin
private Portal _portal;
private PartyManager _partyManager;
private ServerStatusManager _statusManager;
private HubManager _hubManager;
private StackerManager _stackerManager;
private NautHashMap<String, HashSet<ServerInfo>> _serverNpcMap = new NautHashMap<String, HashSet<ServerInfo>>();
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
private NautHashMap<String, String> _serverKeyTagMap = new NautHashMap<String, String>();
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>();
private NautHashMap<Vector, String> _serverPortalLocations = new NautHashMap<Vector, String>();
private ServerNpcShop _quickShop;
private QuickShop _quickShop;
private LobbyShop _lobbyShop;
private boolean _loading = false;
private boolean _alternateUpdateFire = false;
private boolean _retrieving = false;
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager)
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager)
{
super("Server Manager", plugin);
@ -72,24 +85,95 @@ public class ServerManager extends MiniPlugin
_portal = portal;
_partyManager = partyManager;
_statusManager = statusManager;
_hubManager = hubManager;
_stackerManager = stackerManager;
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
LoadServers();
new ServerManagerUpdater(this);
_quickShop = new ServerNpcShop(this, clientManager, donationManager, "Quick Menu");
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
}
public void AddCommands()
@EventHandler(priority = EventPriority.LOW)
public void playerPortalEvent(PlayerPortalEvent event)
{
AddCommand(new ServerNpcCommand(this));
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW)
public void entityPortalEvent(EntityPortalEvent event)
{
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW)
public void playerCheckPortalEvent(EntityPortalEnterEvent event)
{
if (!(event.getEntity() instanceof Player))
{
UtilAction.velocity(event.getEntity(), UtilAlg.getTrajectory(event.getEntity().getLocation(), _hubManager.GetSpawn()), 1, true, 0.8, 0, 1, true);
return;
}
Player player = (Player)event.getEntity();
if (!_stackerManager.CanPortal(player))
{
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1, true, 0.8, 0, 1, true);
return;
}
if (!Recharge.Instance.use(player, "Portal Server", 1000, false))
return;
String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector());
if (serverName != null)
{
List<ServerInfo> serverList = new ArrayList<ServerInfo>(GetServerList(serverName));
int slots = 1;
if (serverList.size() > 0)
{
slots = GetRequiredSlots(player, serverList.get(0).ServerType);
}
try
{
Collections.sort(serverList, new ServerSorter(slots));
for (ServerInfo serverInfo : serverList)
{
if ((serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup")) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slots)
{
SelectServer(player, serverInfo);
return;
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
for (ServerInfo serverInfo : serverList)
{
System.out.println(F.main("ServerManager", ChatColor.YELLOW + serverInfo.Name + ": " + serverInfo.MOTD + " " + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers));
}
}
player.sendMessage(F.main("Server Portal", "There are currently no joinable servers!"));
}
}
@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"));
//event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WATCH.getId(), (byte)0, 1, ChatColor.GREEN + "Lobby Menu"));
}
@EventHandler(priority = EventPriority.LOWEST)
@ -97,47 +181,39 @@ public class ServerManager extends MiniPlugin
{
if (event.getItem() != null && event.getItem().getType() == Material.COMPASS)
{
_quickShop.OpenPageForPlayer(event.getPlayer(), new ServerGameMenu(this, _quickShop, _clientManager, _donationManager, " " + ChatColor.UNDERLINE + "Quick Game Menu", event.getPlayer()));
_quickShop.attemptShopOpen(event.getPlayer());
}
}
public void AddServer(String serverNpcName, String serverName)
else if (event.getItem() != null && event.getItem().getType() == Material.WATCH)
{
ServerInfo serverInfo = new ServerInfo();
serverInfo.Name = serverName;
if (_serverInfoMap.containsKey(serverName))
{
_serverInfoMap.remove(serverName);
_serverUpdate.remove(serverName);
_lobbyShop.attemptShopOpen(event.getPlayer());
}
_serverNpcMap.get(serverNpcName).add(serverInfo);
_serverInfoMap.put(serverName, serverInfo);
_serverUpdate.put(serverName, System.currentTimeMillis());
SaveServers();
}
public void RemoveServer(String serverName)
{
for (String key : _serverNpcMap.keySet())
for (String key : _serverKeyInfoMap.keySet())
{
_serverNpcMap.get(key).remove(serverName);
_serverKeyInfoMap.get(key).remove(serverName);
}
_serverInfoMap.remove(serverName);
}
public void AddServerNpc(String serverNpcName)
public void addServerGroup(String serverKey, String serverTag)
{
_serverNpcMap.put(serverNpcName, new HashSet<ServerInfo>());
_serverKeyInfoMap.put(serverKey, new HashSet<ServerInfo>());
_serverKeyTagMap.put(serverTag, serverKey);
}
public void AddServerNpc(String serverNpcName, String serverTag)
{
addServerGroup(serverNpcName, serverTag);
_serverNpcShopMap.put(serverNpcName, new ServerNpcShop(this, _clientManager, _donationManager, serverNpcName));
}
public void RemoveServerNpc(String serverNpcName)
{
Set<ServerInfo> mappedServers = _serverNpcMap.remove(serverNpcName);
Set<ServerInfo> mappedServers = _serverKeyInfoMap.remove(serverNpcName);
_serverNpcShopMap.remove(serverNpcName);
if (mappedServers != null)
@ -146,9 +222,9 @@ public class ServerManager extends MiniPlugin
{
boolean isMappedElseWhere = false;
for (String key : _serverNpcMap.keySet())
for (String key : _serverKeyInfoMap.keySet())
{
for (ServerInfo value : _serverNpcMap.get(key))
for (ServerInfo value : _serverKeyInfoMap.get(key))
{
if (value.Name.equalsIgnoreCase(mappedServer.Name))
{
@ -169,7 +245,7 @@ public class ServerManager extends MiniPlugin
public Collection<ServerInfo> GetServerList(String serverNpcName)
{
return _serverNpcMap.get(serverNpcName);
return _serverKeyInfoMap.get(serverNpcName);
}
public Set<String> GetAllServers()
@ -184,7 +260,7 @@ public class ServerManager extends MiniPlugin
public boolean HasServerNpc(String serverNpcName)
{
return _serverNpcMap.containsKey(serverNpcName);
return _serverKeyInfoMap.containsKey(serverNpcName);
}
@EventHandler
@ -220,9 +296,15 @@ public class ServerManager extends MiniPlugin
{
for (ServerStatusData serverStatus : serverStatusList)
{
if (_serverInfoMap.containsKey(serverStatus.Name))
if (!_serverInfoMap.containsKey(serverStatus.Name))
{
ServerInfo newServerInfo = new ServerInfo();
newServerInfo.Name = serverStatus.Name;
_serverInfoMap.put(serverStatus.Name, newServerInfo);
}
String[] args = serverStatus.Motd.split("\\|");
String tag = (serverStatus.Name != null && serverStatus.Name.contains("-")) ? serverStatus.Name.split("-")[0] : "N/A";
ServerInfo serverInfo = _serverInfoMap.get(serverStatus.Name);
serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.Motd;
@ -239,6 +321,11 @@ public class ServerManager extends MiniPlugin
serverInfo.Map = args[3];
_serverUpdate.put(serverStatus.Name, System.currentTimeMillis());
if (_serverKeyTagMap.containsKey(tag))
{
_serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo);
}
}
for (String name : _serverUpdate.keySet())
@ -253,7 +340,6 @@ public class ServerManager extends MiniPlugin
_serverUpdate.put(name, -1L);
}
}
}
// Reset
_retrieving = false;
@ -340,7 +426,7 @@ public class ServerManager extends MiniPlugin
{
UtilPlayer.message(caller, F.main(GetName(), "Listing Server Npcs:"));
for (String serverNpc : _serverNpcMap.keySet())
for (String serverNpc : _serverKeyInfoMap.keySet())
{
UtilPlayer.message(caller, F.main(GetName(), C.cYellow + serverNpc));
}
@ -350,7 +436,7 @@ public class ServerManager extends MiniPlugin
{
UtilPlayer.message(caller, F.main(GetName(), "Listing Servers for '" + serverNpcName + "':"));
for (ServerInfo serverNpc : _serverNpcMap.get(serverNpcName))
for (ServerInfo serverNpc : _serverKeyInfoMap.get(serverNpcName))
{
UtilPlayer.message(caller, F.main(GetName(), C.cYellow + serverNpc.Name + C.cWhite + " - " + serverNpc.MOTD + " " + serverNpc.CurrentPlayers + "/" + serverNpc.MaxPlayers));
}
@ -369,74 +455,17 @@ public class ServerManager extends MiniPlugin
}
}
public void SaveServers()
{
if (_loading)
return;
FileWriter fstream = null;
BufferedWriter out = null;
try
{
fstream = new FileWriter("ServerManager.dat");
out = new BufferedWriter(fstream);
for (String key : _serverNpcMap.keySet())
{
System.out.println("Saving serverinfos for " + key);
for (ServerInfo serverInfo : _serverNpcMap.get(key))
{
out.write(key + " | " + serverInfo.Name);
out.newLine();
}
}
out.close();
}
catch (Exception e)
{
System.err.println("ServerManager Save Error: " + e.getMessage());
}
finally
{
if (out != null)
{
try
{
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
if (fstream != null)
{
try
{
fstream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
public void LoadServers()
{
_serverInfoMap.clear();
_serverUpdate.clear();
for (String npcName : _serverNpcMap.keySet())
for (String npcName : _serverKeyInfoMap.keySet())
{
_serverNpcMap.get(npcName).clear();
_serverKeyInfoMap.get(npcName).clear();
}
_loading = true;
_serverKeyTagMap.clear();
FileInputStream fstream = null;
BufferedReader br = null;
@ -457,14 +486,19 @@ public class ServerManager extends MiniPlugin
while (line != null)
{
String serverNpcName = line.substring(0, line.indexOf('|')).trim();
String server = line.substring(line.indexOf('|') + 1).trim();
String serverTag = line.substring(line.indexOf('|') + 1, line.indexOf('|', line.indexOf('|') + 1)).trim();
String[] locations = line.substring(line.indexOf('|', line.indexOf('|') + 1) + 1).trim().split(",");
for (String location : locations)
{
_serverPortalLocations.put(ParseVector(location), serverNpcName);
}
if (!HasServerNpc(serverNpcName))
{
AddServerNpc(serverNpcName);
AddServerNpc(serverNpcName, serverTag);
}
AddServer(serverNpcName, server);
npcNames.add(serverNpcName);
line = br.readLine();
@ -500,8 +534,6 @@ public class ServerManager extends MiniPlugin
e.printStackTrace();
}
}
_loading = false;
}
for (String npcName : npcNames)
@ -509,8 +541,8 @@ public class ServerManager extends MiniPlugin
if (!_serverNpcShopMap.containsKey(npcName))
_serverNpcShopMap.remove(npcName);
if (!_serverNpcMap.containsKey(npcName))
_serverNpcMap.remove(npcName);
if (!_serverKeyInfoMap.containsKey(npcName))
_serverKeyInfoMap.remove(npcName);
}
}
@ -549,7 +581,7 @@ public class ServerManager extends MiniPlugin
public ServerNpcShop getMixedArcadeShop()
{
return _serverNpcShopMap.get("Mixed Arcade Games");
return _serverNpcShopMap.get("Mixed Arcade");
}
public ServerNpcShop getSuperSmashMobsShop()
@ -559,7 +591,7 @@ public class ServerManager extends MiniPlugin
public ServerNpcShop getDominateShop()
{
return _serverNpcShopMap.get("Dominate Beta");
return _serverNpcShopMap.get("Dominate");
}
public ServerNpcShop getBridgesShop()
@ -569,6 +601,24 @@ public class ServerManager extends MiniPlugin
public ServerNpcShop getMinekartShop()
{
return _serverNpcShopMap.get("play minekart plz");
return _serverNpcShopMap.get("Minekart");
}
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()
{
return _statusManager;
}
}

View File

@ -1,55 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.server.ServerManager;
public class AddServerCommand extends CommandBase<ServerManager>
{
public AddServerCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "addserver");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length < 2)
{
Plugin.Help(caller, "Invalid arguments");
return;
}
String argsCombined = args[0];
String serverNpcName = "";
String serverName = "";
for (int i = 1; i < args.length; i++)
{
argsCombined += " " + args[i];
}
if (!argsCombined.contains("|"))
{
Plugin.Help(caller, "Invalid arguments");
}
serverNpcName = argsCombined.substring(0, argsCombined.indexOf("|")).trim();
serverName = argsCombined.substring(argsCombined.indexOf("|") + 1).trim();
if (!Plugin.HasServerNpc(serverNpcName))
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), ChatColor.RED + "That ServerNpc doesn't exist."));
}
else
{
Plugin.AddServer(serverNpcName, serverName);
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Added '" + serverName + "' to '" + serverNpcName + "' server list."));
}
}
}

View File

@ -1,45 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.server.ServerManager;
public class CreateCommand extends CommandBase<ServerManager>
{
public CreateCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "create");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0)
{
Plugin.Help(caller, "Invalid name for servernpc");
return;
}
String serverNpcName = args[0];
for (int i = 1; i < args.length; i++)
{
serverNpcName += " " + args[i];
}
if (Plugin.HasServerNpc(serverNpcName))
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), ChatColor.RED + "That ServerNpc already exists."));
}
else
{
Plugin.AddServerNpc(serverNpcName);
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Created '" + serverNpcName + "' server npc."));
}
}
}

View File

@ -1,38 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.server.ServerManager;
public class DeleteCommand extends CommandBase<ServerManager>
{
public DeleteCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "delete");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length != 1)
{
Plugin.Help(caller, "Invalid name for servernpc");
return;
}
if (!Plugin.HasServerNpc(args[0]))
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), ChatColor.RED + "That ServerNpc doesn't exist."));
}
else
{
Plugin.RemoveServerNpc(args[0]);
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Removed '" + args[0] + "' server npc."));
}
}
}

View File

@ -1,27 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.hub.server.ServerManager;
public class ListNpcsCommand extends CommandBase<ServerManager>
{
public ListNpcsCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "listnpcs");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args != null)
{
Plugin.Help(caller, "Invalid arguments");
return;
}
Plugin.ListServerNpcs(caller);
}
}

View File

@ -1,27 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.hub.server.ServerManager;
public class ListOfflineCommand extends CommandBase<ServerManager>
{
public ListOfflineCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "listoffline");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args != null)
{
Plugin.Help(caller, "Invalid arguments");
return;
}
Plugin.ListOfflineServers(caller);
}
}

View File

@ -1,34 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.hub.server.ServerManager;
public class ListServersCommand extends CommandBase<ServerManager>
{
public ListServersCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "listservers");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length < 1)
{
Plugin.Help(caller, "Invalid arguments");
return;
}
String serverNpcName = args[0];
for (int i = 1; i < args.length; i++)
{
serverNpcName += " " + args[i];
}
Plugin.ListServers(caller, serverNpcName);
}
}

View File

@ -1,30 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.server.ServerManager;
public class RemoveServerCommand extends CommandBase<ServerManager>
{
public RemoveServerCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "removeserver");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length != 1)
{
Plugin.Help(caller, "Invalid arguments");
return;
}
Plugin.RemoveServer(args[0]);
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Removed '" + args[0] + "' from server list."));
}
}

View File

@ -1,29 +0,0 @@
package mineplex.hub.server.command;
import org.bukkit.entity.Player;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.hub.server.ServerManager;
public class ServerNpcCommand extends MultiCommandBase<ServerManager>
{
public ServerNpcCommand(ServerManager plugin)
{
super(plugin, Rank.OWNER, "servernpc");
AddCommand(new CreateCommand(plugin));
AddCommand(new DeleteCommand(plugin));
AddCommand(new AddServerCommand(plugin));
AddCommand(new RemoveServerCommand(plugin));
AddCommand(new ListNpcsCommand(plugin));
AddCommand(new ListServersCommand(plugin));
AddCommand(new ListOfflineCommand(plugin));
}
@Override
protected void Help(Player caller, String args[])
{
Plugin.Help(caller);
}
}

View File

@ -0,0 +1,10 @@
package mineplex.hub.server.ui;
import mineplex.hub.server.ServerInfo;
import org.bukkit.entity.Player;
public interface IServerPage
{
void SelectServer(Player player, ServerInfo _serverInfo);
}

View File

@ -0,0 +1,116 @@
package mineplex.hub.server.ui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.Material;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
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.ui.button.JoinServerButton;
public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements IServerPage
{
private String _serverGroup;
public LobbyMenu(ServerManager plugin, LobbyShop lobbyShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroup)
{
super(plugin, lobbyShop, clientManager, donationManager, name, player, 27);
_serverGroup = serverGroup;
BuildPage();
}
@Override
protected void BuildPage()
{
List<ServerInfo> serverList = new ArrayList<ServerInfo>(Plugin.GetServerList(_serverGroup));
try
{
Collections.sort(serverList, 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<String>();
if (slot >= 27)
break;
slot += 1;
if (serverInfo.Name.equalsIgnoreCase(Plugin.getStatusManager().getCurrentServerName()))
status = Material.EMERALD_BLOCK;
lore.add(ChatColor.RESET + "");
if (serverInfo.Game != null)
lore.add(ChatColor.RESET + "" + ChatColor.YELLOW + "Game: " + ChatColor.WHITE + serverInfo.Game);
if (serverInfo.Map != null && !serverInfo.ServerType.equalsIgnoreCase("Competitive"))
lore.add(ChatColor.RESET + "" + ChatColor.YELLOW + "Map: " + ChatColor.WHITE + serverInfo.Map);
lore.add(ChatColor.RESET + "" + ChatColor.YELLOW + "Players: " + ChatColor.WHITE + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers);
lore.add(ChatColor.RESET + "");
lore.add(ChatColor.RESET + serverInfo.MOTD);
if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers)
{
if (!Client.GetRank().Has(Rank.ULTRA))
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()]), Math.max(1, serverInfo.CurrentPlayers), false), new JoinServerButton(this, serverInfo));
}
while (slot < 27)
{
setItem(slot, null);
}
}
public void Update()
{
BuildPage();
}
@Override
public void SelectServer(org.bukkit.entity.Player player, ServerInfo serverInfo)
{
int slots = Plugin.GetRequiredSlots(player, serverInfo.ServerType);
if (serverInfo.MaxPlayers - serverInfo.CurrentPlayers < slots)
{
PlayDenySound(player);
return;
}
Plugin.SelectServer(player, serverInfo);
}
}

View File

@ -0,0 +1,34 @@
package mineplex.hub.server.ui;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerManager;
public class LobbyShop extends ShopBase<ServerManager>
{
public LobbyShop(ServerManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager, String name)
{
super(plugin, clientManager, donationManager, name);
}
@Override
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> BuildPagesFor(Player player)
{
return new LobbyMenu(Plugin, this, ClientManager, DonationManager, " " + ChatColor.UNDERLINE + "Lobby Selector", player, "Lobby");
}
public void UpdatePages()
{
for (ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> page : PlayerPageMap.values())
{
if (page instanceof LobbyMenu)
{
((LobbyMenu)page).Update();
}
}
}
}

View File

@ -0,0 +1,34 @@
package mineplex.hub.server.ui;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerManager;
public class QuickShop extends ShopBase<ServerManager>
{
public QuickShop(ServerManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager, String name)
{
super(plugin, clientManager, donationManager, name);
}
@Override
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> BuildPagesFor(Player player)
{
return new ServerGameMenu(Plugin, this, ClientManager, DonationManager, " " + ChatColor.UNDERLINE + "Quick Game Menu", player);
}
public void UpdatePages()
{
for (ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> page : PlayerPageMap.values())
{
if (page instanceof ServerGameMenu)
{
((ServerGameMenu)page).Update();
}
}
}
}

View File

@ -15,7 +15,7 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerManager;
public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
{
private List<ItemStack> _superSmashCycle = new ArrayList<ItemStack>();
private List<ItemStack> _minigameCycle = new ArrayList<ItemStack>();
@ -25,9 +25,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
private int _minigameIndex;
private int _turfFortsIndex;
public ServerGameMenu(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player, 9);
super(plugin, quickShop, clientManager, donationManager, name, player, 9);
createSuperSmashCycle();
createMinigameCycle();
@ -105,6 +105,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.GOLD_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -121,6 +123,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(122, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -137,6 +141,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -153,6 +159,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -169,6 +177,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.MILK_BUCKET.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -185,6 +195,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -201,6 +213,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + C.Bold + ChatColor.GREEN + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(159, (byte)14, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -217,6 +231,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(144, (byte)1, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
@ -231,8 +247,46 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
ChatColor.RESET + "Dragon Escape",
ChatColor.RESET + "Milk the Cow",
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET +"Turf Forts",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(144, (byte)1, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
{
ChatColor.RESET + "",
ChatColor.RESET + "Play all of these fun minigames:",
ChatColor.RESET + "",
ChatColor.RESET + "Super Spleef",
ChatColor.RESET + "Runner",
ChatColor.RESET + "Dragons",
ChatColor.RESET + "One in the Quiver",
ChatColor.RESET + "Dragon Escape",
ChatColor.RESET + "Milk the Cow",
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl",
ChatColor.RESET + "Squid Sauce"
}));
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(144, (byte)1, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
{
ChatColor.RESET + "",
ChatColor.RESET + "Play all of these fun minigames:",
ChatColor.RESET + "",
ChatColor.RESET + "Super Spleef",
ChatColor.RESET + "Runner",
ChatColor.RESET + "Dragons",
ChatColor.RESET + "One in the Quiver",
ChatColor.RESET + "Dragon Escape",
ChatColor.RESET + "Milk the Cow",
ChatColor.RESET + "A Barbarian's Life",
ChatColor.RESET + "Turf Forts",
ChatColor.RESET + "Death Tag",
ChatColor.RESET + "Bacon Brawl",
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Squid Sauce"
}));
}

View File

@ -20,7 +20,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop>
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> implements IServerPage
{
private String _serverNpcKey;

View File

@ -4,14 +4,15 @@ import org.bukkit.entity.Player;
import mineplex.core.shop.item.IButton;
import mineplex.hub.server.ServerInfo;
import mineplex.hub.server.ui.IServerPage;
import mineplex.hub.server.ui.ServerNpcPage;
public class JoinServerButton implements IButton
{
private ServerNpcPage _page;
private IServerPage _page;
private ServerInfo _serverInfo;
public JoinServerButton(ServerNpcPage page, ServerInfo serverInfo)
public JoinServerButton(IServerPage page, ServerInfo serverInfo)
{
_page = page;
_serverInfo = serverInfo;

View File

@ -378,8 +378,23 @@ public class ClientClass
public void ClearSkills()
{
if (_skillMap != null)
{
for (ISkill skill : _skillMap.values())
{
if (skill == null)
{
System.out.println("Skill is null in ClientClass.ClearSkills()");
}
else if (_client == null)
{
System.out.println("Client is null in ClientClass.ClearSkills()");
}
else
{
skill.RemoveUser(_client.GetPlayer());
}
}
}
_skillMap.clear();
}

View File

@ -955,6 +955,9 @@ public class GameLobbyManager implements IPacketRunnable, Listener
private String GetKitCustomName(Player player, Game game, LobbyEnt ent)
{
if (!player.isOnline())
return ent.GetKit().GetName();
CoreClient client = Manager.GetClients().Get(player);
Donor donor = Manager.GetDonation().Get(player.getName());

View File

@ -43,12 +43,15 @@ public class DominateGameEngine extends TeamGameEngine<IDominateGame, IDominateS
super.ActivateGame(game, arena);
for (IDominatePlayer dominatePlayer : game.GetPlayers())
{
if (dominatePlayer.isOnline())
{
ClientClass clientClass = ClassManager.Get(dominatePlayer.GetPlayer());
clientClass.ResetToDefaults(true, true);
}
}
}
@Override
public IDominateGame ScheduleNewGame()