Implemented quick game menu.
Fixed dom team size at 1. Removed old server update code from server manager.
This commit is contained in:
parent
7d31b24c75
commit
7329cc0aea
@ -109,6 +109,29 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean attemptShopOpen(Player player)
|
||||
{
|
||||
if (!_openedShop.contains(player.getName()))
|
||||
{
|
||||
if (!CanOpenShop(player))
|
||||
return false;
|
||||
|
||||
_openedShop.add(player.getName());
|
||||
|
||||
OpenShopForPlayer(player);
|
||||
if (!PlayerPageMap.containsKey(player.getName()))
|
||||
{
|
||||
PlayerPageMap.put(player.getName(), BuildPagesFor(player));
|
||||
}
|
||||
|
||||
OpenPageForPlayer(player, GetOpeningPageForPlayer(player));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected ShopPageBase<PluginType, ? extends ShopBase<PluginType>> GetOpeningPageForPlayer(Player player)
|
||||
{
|
||||
|
@ -2,10 +2,6 @@ package mineplex.hub.server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
@ -16,7 +12,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -25,7 +20,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -50,7 +44,7 @@ import mineplex.hub.server.command.ServerNpcCommand;
|
||||
import mineplex.hub.server.ui.ServerGameMenu;
|
||||
import mineplex.hub.server.ui.ServerNpcShop;
|
||||
|
||||
public class ServerManager extends MiniPlugin implements PluginMessageListener
|
||||
public class ServerManager extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
@ -80,13 +74,11 @@ public class ServerManager extends MiniPlugin implements PluginMessageListener
|
||||
_statusManager = statusManager;
|
||||
|
||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeSigns");
|
||||
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, "BungeeSigns", this);
|
||||
|
||||
LoadServers();
|
||||
|
||||
new ServerManagerUpdater(this);
|
||||
//_quickShop = new ServerNpcShop(this, clientManager, donationManager, "Quick Menu");
|
||||
_quickShop = new ServerNpcShop(this, clientManager, donationManager, "Quick Menu");
|
||||
}
|
||||
|
||||
public void AddCommands()
|
||||
@ -97,7 +89,7 @@ public class ServerManager extends MiniPlugin implements PluginMessageListener
|
||||
@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.COMPASS.getId(), (byte)0, 1, ChatColor.GREEN + "Game Menu"));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -105,7 +97,7 @@ public class ServerManager extends MiniPlugin implements PluginMessageListener
|
||||
{
|
||||
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.OpenPageForPlayer(event.getPlayer(), new ServerGameMenu(this, _quickShop, _clientManager, _donationManager, " " + ChatColor.UNDERLINE + "Quick Game Menu", event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,71 +187,13 @@ public class ServerManager extends MiniPlugin implements PluginMessageListener
|
||||
return _serverNpcMap.containsKey(serverNpcName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message)
|
||||
{
|
||||
if (!channel.equalsIgnoreCase("BungeeSigns"))
|
||||
return;
|
||||
|
||||
DataInputStream in = null;
|
||||
String serverName = null;
|
||||
String motd = null;
|
||||
int players = 0;
|
||||
int maxPlayers = 0;
|
||||
|
||||
try
|
||||
{
|
||||
in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
serverName = in.readUTF();
|
||||
motd = in.readUTF();
|
||||
players = in.readInt();
|
||||
maxPlayers = in.readInt();
|
||||
|
||||
if (_serverInfoMap.containsKey(serverName))
|
||||
{
|
||||
String[] args = motd.split("\\|");
|
||||
|
||||
ServerInfo serverInfo = _serverInfoMap.get(serverName);
|
||||
serverInfo.MOTD = args.length > 0 ? args[0] : motd;
|
||||
serverInfo.CurrentPlayers = players;
|
||||
serverInfo.MaxPlayers = maxPlayers;
|
||||
|
||||
if (args.length > 1)
|
||||
serverInfo.ServerType = args[1];
|
||||
|
||||
if (args.length > 2)
|
||||
serverInfo.Game = args[2];
|
||||
|
||||
if (args.length > 3)
|
||||
serverInfo.Map = args[3];
|
||||
|
||||
_serverUpdate.put(serverName, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updatePages(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
//_quickShop.UpdatePages();
|
||||
_quickShop.UpdatePages();
|
||||
|
||||
for (ServerNpcShop shop : _serverNpcShopMap.values())
|
||||
{
|
||||
@ -612,4 +546,29 @@ public class ServerManager extends MiniPlugin implements PluginMessageListener
|
||||
|
||||
return slots;
|
||||
}
|
||||
|
||||
public ServerNpcShop getMixedArcadeShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("Mixed Arcade Games");
|
||||
}
|
||||
|
||||
public ServerNpcShop getSuperSmashMobsShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("Super Smash Mobs");
|
||||
}
|
||||
|
||||
public ServerNpcShop getDominateShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("Dominate Beta");
|
||||
}
|
||||
|
||||
public ServerNpcShop getBridgesShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("The Bridges");
|
||||
}
|
||||
|
||||
public ServerNpcShop getMinekartShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("play minekart plz");
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
package mineplex.hub.server.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class SelectOITQButton implements IButton
|
||||
{
|
||||
private ServerGameMenu _menu;
|
||||
|
||||
public SelectOITQButton(ServerGameMenu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
_menu.OpenOITQ(player);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package mineplex.hub.server.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class SelectTFButton implements IButton
|
||||
{
|
||||
private ServerGameMenu _menu;
|
||||
|
||||
public SelectTFButton(ServerGameMenu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
_menu.OpenTF(player);
|
||||
}
|
||||
}
|
@ -39,10 +39,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
|
||||
@Override
|
||||
protected void BuildPage()
|
||||
{
|
||||
this.setItem(0, _superSmashCycle.get(_ssmIndex));
|
||||
this.setItem(1, _minigameCycle.get(_minigameIndex));
|
||||
this.setItem(2, _turfFortsCycle.get(_turfFortsIndex));
|
||||
this.setItem(3, ItemStackFactory.Instance.CreateStack(Material.BOW.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "One in the Quiver " + C.cGray + "Arcade Minigame", new String[] { "", ChatColor.RESET + "Fast paced, 1 shot combat!" }));
|
||||
this.setItem(2, _superSmashCycle.get(_ssmIndex));
|
||||
this.setItem(3, _minigameCycle.get(_minigameIndex));
|
||||
this.setItem(4, ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "The Bridges " + C.cGray + "4 Team Survival", new String[]
|
||||
{
|
||||
ChatColor.RESET + "",
|
||||
@ -67,13 +65,11 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
|
||||
ChatColor.RESET + "control points on the map.",
|
||||
}));
|
||||
|
||||
ButtonMap.put(0, new SelectSSMButton(this));
|
||||
ButtonMap.put(0, new SelectMINButton(this));
|
||||
ButtonMap.put(0, new SelectTFButton(this));
|
||||
ButtonMap.put(0, new SelectOITQButton(this));
|
||||
ButtonMap.put(0, new SelectBRButton(this));
|
||||
ButtonMap.put(0, new SelectMKButton(this));
|
||||
ButtonMap.put(0, new SelectDOMButton(this));
|
||||
ButtonMap.put(2, new SelectSSMButton(this));
|
||||
ButtonMap.put(3, new SelectMINButton(this));
|
||||
ButtonMap.put(4, new SelectBRButton(this));
|
||||
ButtonMap.put(5, new SelectMKButton(this));
|
||||
ButtonMap.put(6, new SelectDOMButton(this));
|
||||
}
|
||||
|
||||
private void createTurfFortsCycle()
|
||||
@ -276,43 +272,26 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, ServerNpcShop>
|
||||
|
||||
public void OpenMIN(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Plugin.getMixedArcadeShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void OpenSSM(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Plugin.getSuperSmashMobsShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void OpenDOM(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Plugin.getDominateShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void OpenBR(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Plugin.getBridgesShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void OpenMK(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void OpenTF(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void OpenOITQ(Player player)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Plugin.getMinekartShop().attemptShopOpen(player);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class DominateGameEngine extends TeamGameEngine<IDominateGame, IDominateS
|
||||
_notifier = notifier;
|
||||
new DominateStatsReporter(plugin, donationManager, webServerAddress);
|
||||
|
||||
TeamSize = 1;
|
||||
TeamSize = 5;
|
||||
AddToActiveGame = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user