Added DisguiseWolf
Added lobby menu (disabled autogive for testing) Removed unused commands.
This commit is contained in:
parent
44da981cf4
commit
57b0d06786
@ -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);
|
||||
}
|
||||
}
|
@ -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";
|
||||
}
|
||||
}
|
@ -24,6 +24,8 @@ public class ServerStatusManager extends MiniPlugin
|
||||
private ServerStatusRepository _repository;
|
||||
private LagMeter _lagMeter;
|
||||
|
||||
private String _name;
|
||||
|
||||
private boolean _alternateSeconds;
|
||||
private boolean _enabled = true;
|
||||
|
||||
@ -80,13 +82,15 @@ 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()
|
||||
);
|
||||
@ -167,4 +171,9 @@ public class ServerStatusManager extends MiniPlugin
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getCurrentServerName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -21,7 +21,6 @@ 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.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -50,9 +49,8 @@ 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.LobbyShop;
|
||||
import mineplex.hub.server.ui.QuickShop;
|
||||
import mineplex.hub.server.ui.ServerGameMenu;
|
||||
import mineplex.hub.server.ui.ServerNpcShop;
|
||||
|
||||
public class ServerManager extends MiniPlugin
|
||||
@ -65,14 +63,15 @@ public class ServerManager extends MiniPlugin
|
||||
private HubManager _hubManager;
|
||||
private StackerManager _stackerManager;
|
||||
|
||||
private NautHashMap<String, HashSet<ServerInfo>> _serverNpcMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
||||
private NautHashMap<String, String> _serverNpcTag = new NautHashMap<String, String>();
|
||||
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 QuickShop _quickShop;
|
||||
private LobbyShop _lobbyShop;
|
||||
|
||||
private boolean _alternateUpdateFire = false;
|
||||
private boolean _retrieving = false;
|
||||
@ -95,11 +94,7 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
new ServerManagerUpdater(this);
|
||||
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
|
||||
}
|
||||
|
||||
public void AddCommands()
|
||||
{
|
||||
AddCommand(new ServerNpcCommand(this));
|
||||
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@ -178,6 +173,7 @@ public class ServerManager extends MiniPlugin
|
||||
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)
|
||||
@ -187,27 +183,37 @@ public class ServerManager extends MiniPlugin
|
||||
{
|
||||
_quickShop.attemptShopOpen(event.getPlayer());
|
||||
}
|
||||
else if (event.getItem() != null && event.getItem().getType() == Material.WATCH)
|
||||
{
|
||||
_lobbyShop.attemptShopOpen(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@ -216,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))
|
||||
{
|
||||
@ -239,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()
|
||||
@ -254,7 +260,7 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
public boolean HasServerNpc(String serverNpcName)
|
||||
{
|
||||
return _serverNpcMap.containsKey(serverNpcName);
|
||||
return _serverKeyInfoMap.containsKey(serverNpcName);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -316,9 +322,9 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
_serverUpdate.put(serverStatus.Name, System.currentTimeMillis());
|
||||
|
||||
if (_serverNpcTag.containsKey(tag))
|
||||
if (_serverKeyTagMap.containsKey(tag))
|
||||
{
|
||||
_serverNpcMap.get(_serverNpcTag.get(tag)).add(serverInfo);
|
||||
_serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,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));
|
||||
}
|
||||
@ -430,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));
|
||||
}
|
||||
@ -454,12 +460,12 @@ public class ServerManager extends MiniPlugin
|
||||
_serverInfoMap.clear();
|
||||
_serverUpdate.clear();
|
||||
|
||||
for (String npcName : _serverNpcMap.keySet())
|
||||
for (String npcName : _serverKeyInfoMap.keySet())
|
||||
{
|
||||
_serverNpcMap.get(npcName).clear();
|
||||
_serverKeyInfoMap.get(npcName).clear();
|
||||
}
|
||||
|
||||
_serverNpcTag.clear();
|
||||
_serverKeyTagMap.clear();
|
||||
|
||||
FileInputStream fstream = null;
|
||||
BufferedReader br = null;
|
||||
@ -490,10 +496,9 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
if (!HasServerNpc(serverNpcName))
|
||||
{
|
||||
AddServerNpc(serverNpcName);
|
||||
AddServerNpc(serverNpcName, serverTag);
|
||||
}
|
||||
|
||||
_serverNpcTag.put(serverTag, serverNpcName);
|
||||
npcNames.add(serverNpcName);
|
||||
|
||||
line = br.readLine();
|
||||
@ -536,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -611,4 +616,9 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public ServerStatusManager getStatusManager()
|
||||
{
|
||||
return _statusManager;
|
||||
}
|
||||
}
|
||||
|
@ -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."));
|
||||
}
|
||||
}
|
||||
}
|
@ -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."));
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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."));
|
||||
}
|
||||
}
|
@ -1,28 +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 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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
116
Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java
Normal file
116
Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java
Normal 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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -940,6 +940,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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user