Pushing unfinished code for laptop

This commit is contained in:
Shaun Bennett 2014-12-16 11:42:06 -06:00
parent 2e7d101850
commit 83218c9a73
18 changed files with 588 additions and 47 deletions

View File

@ -446,10 +446,10 @@ public class CoreClientManager extends MiniPlugin
if (event.getType() != UpdateType.SLOWER) if (event.getType() != UpdateType.SLOWER)
return; return;
System.out.println("====="); // System.out.println("=====");
System.out.println("Connecting : " + _clientsConnecting.get()); // System.out.println("Connecting : " + _clientsConnecting.get());
System.out.println("Processing : " + _clientsProcessing.get()); // System.out.println("Processing : " + _clientsProcessing.get());
System.out.println("====="); // System.out.println("=====");
} }
public void addStoredProcedureLoginProcessor(ILoginProcessor processor) public void addStoredProcedureLoginProcessor(ILoginProcessor processor)

View File

@ -110,7 +110,7 @@ public class Chat extends MiniPlugin
@EventHandler @EventHandler
public void preventMe(PlayerCommandPreprocessEvent event) public void preventMe(PlayerCommandPreprocessEvent event)
{ {
if (event.getMessage().toLowerCase().startsWith("/me") if (event.getMessage().toLowerCase().startsWith("/me ")
|| event.getMessage().toLowerCase().startsWith("/bukkit")) || event.getMessage().toLowerCase().startsWith("/bukkit"))
{ {
event.getPlayer().sendMessage(F.main(getName(), "No, you!")); event.getPlayer().sendMessage(F.main(getName(), "No, you!"));

View File

@ -1,6 +1,8 @@
package mineplex.core.shop.item; package mineplex.core.shop.item;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
public abstract class ComplexButton implements IButton public abstract class ComplexButton implements IButton
@ -8,6 +10,8 @@ public abstract class ComplexButton implements IButton
@Override @Override
public void Clicked(InventoryClickEvent event) public void Clicked(InventoryClickEvent event)
{ {
Clicked(((Player) event.getWhoClicked()), event.getClick());
if (event.isLeftClick()) if (event.isLeftClick())
{ {
if (event.isShiftClick()) if (event.isShiftClick())
@ -24,8 +28,10 @@ public abstract class ComplexButton implements IButton
} }
} }
public abstract void ClickedLeft(Player player); public void ClickedLeft(Player player) { };
public abstract void ClickedShiftLeft(Player player); public void ClickedShiftLeft(Player player) { };
public abstract void ClickedRight(Player player); public void ClickedRight(Player player) { };
public abstract void ClickedShiftRight(Player player); public void ClickedShiftRight(Player player) { };
public void Clicked(Player player, ClickType clickType) { };
} }

View File

@ -77,7 +77,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
protected abstract void BuildPage(); protected abstract void BuildPage();
protected void AddItem(int slot, ShopItem item) protected void AddItem(int slot, ItemStack item)
{ {
if (slot > inventory.getSize() - 1) if (slot > inventory.getSize() - 1)
{ {
@ -85,7 +85,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
} }
else else
{ {
getInventory().setItem(slot, item.getHandle()); setItem(slot, item);
} }
} }
@ -94,13 +94,13 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
return slot >= (inventory.getSize() + 27) ? slot - (inventory.getSize() + 27) : slot - (inventory.getSize() - 9); return slot >= (inventory.getSize() + 27) ? slot - (inventory.getSize() + 27) : slot - (inventory.getSize() - 9);
} }
protected void AddButton(int slot, ShopItem item, IButton button) protected void AddButton(int slot, ItemStack item, IButton button)
{ {
AddItem(slot, item); AddItem(slot, item);
ButtonMap.put(slot, button); ButtonMap.put(slot, button);
} }
protected void addGlow(int slot) protected void addGlow(int slot)
{ {
UtilInv.addDullEnchantment(getItem(slot)); UtilInv.addDullEnchantment(getItem(slot));

View File

@ -0,0 +1,30 @@
package nautilus.game.arcade.gui;
import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.page.GameHostMenuPage;
public class GameHostShop extends ShopBase<ArcadeManager>
{
public GameHostShop(ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Private Server Menu");
}
@Override
protected ShopPageBase<ArcadeManager, ? extends ShopBase<ArcadeManager>> BuildPagesFor(Player player)
{
return new GameHostMenuPage(Plugin, this, player);
}
}

View File

@ -0,0 +1,27 @@
package nautilus.game.arcade.gui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.ComplexButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
import nautilus.game.arcade.gui.page.BanPage;
public class BanButton extends ComplexButton
{
private ArcadeManager _arcadeManager;
private GameHostShop _shop;
public BanButton(ArcadeManager arcadeManager, GameHostShop shop)
{
_shop = shop;
_arcadeManager = arcadeManager;
}
@Override
public void Clicked(Player player, ClickType clickType)
{
_shop.OpenPageForPlayer(player, new BanPage(_arcadeManager, _shop, player));
}
}

View File

@ -0,0 +1,7 @@
package nautilus.game.arcade.gui.button;
import mineplex.core.shop.item.ComplexButton;
public class EditRotationButton extends ComplexButton
{
}

View File

@ -0,0 +1,27 @@
package nautilus.game.arcade.gui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.ComplexButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
import nautilus.game.arcade.gui.page.GiveAdminPage;
public class GiveAdminButton extends ComplexButton
{
private ArcadeManager _arcadeManager;
private GameHostShop _shop;
public GiveAdminButton(ArcadeManager arcadeManager, GameHostShop shop)
{
_shop = shop;
_arcadeManager = arcadeManager;
}
@Override
public void Clicked(Player player, ClickType clickType)
{
_shop.OpenPageForPlayer(player, new GiveAdminPage(_arcadeManager, _shop, player));
}
}

View File

@ -0,0 +1,7 @@
package nautilus.game.arcade.gui.button;
import mineplex.core.shop.item.ComplexButton;
public class SetGameButton extends ComplexButton
{
}

View File

@ -0,0 +1,7 @@
package nautilus.game.arcade.gui.button;
import mineplex.core.shop.item.ComplexButton;
public class ToggleOpenButton extends ComplexButton
{
}

View File

@ -0,0 +1,28 @@
package nautilus.game.arcade.gui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.ComplexButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
import nautilus.game.arcade.gui.page.BanPage;
import nautilus.game.arcade.gui.page.UnbanPage;
public class UnbanButton extends ComplexButton
{
private ArcadeManager _arcadeManager;
private GameHostShop _shop;
public UnbanButton(ArcadeManager arcadeManager, GameHostShop shop)
{
_shop = shop;
_arcadeManager = arcadeManager;
}
@Override
public void Clicked(Player player, ClickType clickType)
{
_shop.OpenPageForPlayer(player, new UnbanPage(_arcadeManager, _shop, player));
}
}

View File

@ -0,0 +1,71 @@
package nautilus.game.arcade.gui.page;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.shop.item.ComplexButton;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
public class BanPage extends GameHostPage
{
private int _currentPage;
public BanPage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Unban Players", player);
_currentPage = 0;
}
@Override
protected void BuildPage()
{
addBackButton(4);
HashSet<String> blackList = _manager.getBlacklist();
Player[] players = UtilServer.getPlayers();
int slot = 9;
for (Player player : players)
{
if (!_manager.isAdmin(player))
{
ItemStack head = getPlayerHead(player.getName(), C.cGreen + C.Bold + player.getName(), new String[]{ChatColor.RESET + C.cGray + "Click to Ban"});
AddButton(slot, head, getBanButton(slot, player.getName()));
slot++;
}
}
// int arrayModifier = _currentPage * 9 * 4;
// for (int i = 0; i < _currentPage; i++)
// {
// int slot = 9 + i;
// ItemStack head = getPlayerHead(blackList.)
//
// }
}
private IButton getBanButton(final int slot, final String playerName)
{
return new ComplexButton()
{
@Override
public void Clicked(Player player, ClickType clickType)
{
_manager.getBlacklist().add(playerName);
RemoveButton(slot);
}
};
}
}

View File

@ -0,0 +1,61 @@
package nautilus.game.arcade.gui.page;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
import nautilus.game.arcade.gui.button.BanButton;
import nautilus.game.arcade.gui.button.EditRotationButton;
import nautilus.game.arcade.gui.button.GiveAdminButton;
import nautilus.game.arcade.gui.button.SetGameButton;
import nautilus.game.arcade.gui.button.ToggleOpenButton;
import nautilus.game.arcade.gui.button.UnbanButton;
import nautilus.game.arcade.managers.GameHostManager;
public class GameHostMenuPage extends GameHostPage
{
private GameHostManager _manager;
public GameHostMenuPage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Private Server Menu", player, 9*3);
}
@Override
protected void BuildPage()
{
ItemStack ownerHead = getOwnerHead();
setItem(4, ownerHead);
SetGameButton setGameButton = new SetGameButton();
AddButton(1 + 9, new ShopItem(Material.BOOK_AND_QUILL, "Set Game", new String[] {}, 1, false), setGameButton);
EditRotationButton editRotationButton = new EditRotationButton();
AddButton(1 + 18, new ShopItem(Material.BOOK, "Edit Game Rotation", new String[]{}, 1, false), editRotationButton);
ToggleOpenButton toggleOpenButton = new ToggleOpenButton();
AddButton(3 + 9, new ShopItem(Material.LEVER, "Toggle Open/Closed", new String[] {}, 1, false), toggleOpenButton);
GiveAdminButton giveAdminButton = new GiveAdminButton(Plugin, Shop);
AddButton(5 + 9, new ShopItem(Material.ENDER_CHEST, "Give Admin", new String[] {}, 1, false), giveAdminButton);
BanButton banButton = new BanButton(Plugin, Shop);
AddButton(7 + 9, new ShopItem(Material.MONSTER_EGG, "Ban Player", new String[] {}, 1, false), banButton);
UnbanButton unbanButton = new UnbanButton(Plugin, Shop);
AddButton(7 + 18, new ShopItem(Material.PAPER, "Unban Player", new String[] {}, 1, false), unbanButton);
}
private ItemStack getOwnerHead()
{
return getPlayerHead(Plugin.GetHost(), ChatColor.RESET + "Host: " + ChatColor.YELLOW + Plugin.GetHost());
}
}

View File

@ -0,0 +1,68 @@
package nautilus.game.arcade.gui.page;
import java.util.Arrays;
import java.util.function.Consumer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
import nautilus.game.arcade.managers.GameHostManager;
public abstract class GameHostPage extends ShopPageBase<ArcadeManager, GameHostShop>
{
protected GameHostManager _manager;
public GameHostPage(ArcadeManager plugin, GameHostShop shop, String pageName, Player player)
{
this(plugin, shop, pageName, player, 54);
}
public GameHostPage(ArcadeManager plugin, GameHostShop shop, String pageName, Player player, int slots)
{
super(plugin, shop, plugin.GetClients(), plugin.GetDonation(), pageName, player, slots);
_manager = plugin.GetGameHostManager();
BuildPage();
}
public void addBackButton(int slot)
{
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(player, new GameHostMenuPage(Plugin, Shop, player));
}
});
}
public ItemStack getPlayerHead(String playerName, String title)
{
return getPlayerHead(playerName, title, null);
}
public ItemStack getPlayerHead(String playerName, String title, String[] lore)
{
ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta meta = ((SkullMeta) is.getItemMeta());
meta.setOwner(playerName);
meta.setDisplayName(title);
if (lore != null)
meta.setLore(Arrays.asList(lore));
is.setItemMeta(meta);
return is;
}
}

View File

@ -0,0 +1,67 @@
package nautilus.game.arcade.gui.page;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.shop.item.ComplexButton;
import mineplex.core.shop.item.IButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
public class GiveAdminPage extends GameHostPage
{
private int _currentPage;
public GiveAdminPage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Give Admin", player);
_currentPage = 0;
}
@Override
protected void BuildPage()
{
addBackButton(4);
Player[] players = UtilServer.getPlayers();
int slot = 9;
for (Player player : players)
{
if (!_manager.isAdmin(player))
{
ItemStack head = getPlayerHead(player.getName(), C.cGreen + C.Bold + player.getName(), new String[]{ChatColor.RESET + C.cGray + "Click to Give Admin"});
AddButton(slot, head, getBanButton(slot, player.getName()));
slot++;
}
}
// int arrayModifier = _currentPage * 9 * 4;
// for (int i = 0; i < _currentPage; i++)
// {
// int slot = 9 + i;
// ItemStack head = getPlayerHead(blackList.)
//
// }
}
private IButton getBanButton(final int slot, final String playerName)
{
return new ComplexButton()
{
@Override
public void Clicked(Player player, ClickType clickType)
{
_manager.getAdminList().add(playerName);
RemoveButton(slot);
}
};
}
}

View File

@ -0,0 +1,69 @@
package nautilus.game.arcade.gui.page;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.shop.item.ComplexButton;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.GameHostShop;
public class UnbanPage extends GameHostPage
{
private int _currentPage;
public UnbanPage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Unban Players", player);
_currentPage = 0;
}
@Override
protected void BuildPage()
{
addBackButton(4);
HashSet<String> blackList = _manager.getBlacklist();
Iterator<String> iterator = blackList.iterator();
int slot = 9;
while (iterator.hasNext())
{
String name = iterator.next();
ItemStack head = getPlayerHead(name, C.cGreen + C.Bold + name, new String[] {ChatColor.RESET + C.cGray + "Click to Unban"});
AddButton(slot, head, getUnbanButton(slot, name));
slot++;
}
// int arrayModifier = _currentPage * 9 * 4;
// for (int i = 0; i < _currentPage; i++)
// {
// int slot = 9 + i;
// ItemStack head = getPlayerHead(blackList.)
//
// }
}
private IButton getUnbanButton(final int slot, final String playerName)
{
return new ComplexButton()
{
@Override
public void Clicked(Player player, ClickType clickType)
{
_manager.getBlacklist().remove(playerName);
RemoveButton(slot);
}
};
}
}

View File

@ -32,7 +32,7 @@ public class GameChatManager implements Listener
@EventHandler @EventHandler
public void MeCancel(PlayerCommandPreprocessEvent event) public void MeCancel(PlayerCommandPreprocessEvent event)
{ {
if (event.getMessage().startsWith("/me")) if (event.getMessage().startsWith("/me "))
{ {
event.getPlayer().sendMessage(F.main("Mirror", "You can't see /me messages, are you a vampire?")); event.getPlayer().sendMessage(F.main("Mirror", "You can't see /me messages, are you a vampire?"));
event.setCancelled(true); event.setCancelled(true);

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.managers;
import java.util.HashSet; import java.util.HashSet;
import com.sun.org.apache.xpath.internal.SourceTree;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
@ -13,6 +14,7 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.gui.GameHostShop;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -27,6 +29,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class GameHostManager implements Listener public class GameHostManager implements Listener
{ {
private HashSet<GameType> ultraGames = new HashSet<GameType>();
private HashSet<GameType> heroGames = new HashSet<GameType>();
private HashSet<GameType> legendGames = new HashSet<GameType>();
ArcadeManager Manager; ArcadeManager Manager;
private Player _host; private Player _host;
@ -34,17 +40,52 @@ public class GameHostManager implements Listener
private long _serverExpireTime = 43200000; private long _serverExpireTime = 43200000;
private long _lastOnline = System.currentTimeMillis(); private long _lastOnline = System.currentTimeMillis();
private long _expireTime = 300000; private long _expireTime = 300000;
private HashSet<Player> _onlineAdmins = new HashSet<Player>();
private HashSet<String> _adminList = new HashSet<String>();
private HashSet<String> _whitelist = new HashSet<String>(); private HashSet<String> _whitelist = new HashSet<String>();
private HashSet<String> _blacklist = new HashSet<String>(); private HashSet<String> _blacklist = new HashSet<String>();
private GameHostShop _shop;
public GameHostManager(ArcadeManager manager) public GameHostManager(ArcadeManager manager)
{ {
Manager = manager; Manager = manager;
_shop = new GameHostShop(manager, manager.GetClients(), manager.GetDonation());
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
//Ultra Games
ultraGames.add(GameType.Smash);
ultraGames.add(GameType.BaconBrawl);
ultraGames.add(GameType.DeathTag);
ultraGames.add(GameType.DragonEscape);
ultraGames.add(GameType.Dragons);
ultraGames.add(GameType.Micro);
ultraGames.add(GameType.Paintball);
ultraGames.add(GameType.Quiver);
ultraGames.add(GameType.Runner);
ultraGames.add(GameType.Sheep);
ultraGames.add(GameType.Snake);
ultraGames.add(GameType.SneakyAssassins);
ultraGames.add(GameType.TurfWars);
//Hero Games
heroGames.add(GameType.ChampionsDominate);
heroGames.add(GameType.ChampionsTDM);
heroGames.add(GameType.HideSeek);
heroGames.add(GameType.Draw);
//Legend Games
legendGames.add(GameType.Bridge);
legendGames.add(GameType.SurvivalGames);
legendGames.add(GameType.CastleSiege);
legendGames.add(GameType.MineStrike);
_blacklist.add("Chiss");
_blacklist.add("defek7");
_blacklist.add("Ayreloc");
} }
/*
@EventHandler @EventHandler
public void updateHost(UpdateEvent event) public void updateHost(UpdateEvent event)
{ {
@ -58,37 +99,51 @@ public class GameHostManager implements Listener
//Host Update //Host Update
if (_host != null) if (_host != null)
{ {
giveHostItem(); giveAdminItem(_host);
_lastOnline = System.currentTimeMillis(); _lastOnline = System.currentTimeMillis();
} }
// Admins update
for (Player admin : _onlineAdmins)
{
giveAdminItem(admin);
}
} }
@EventHandler @EventHandler
public void hostJoin(PlayerJoinEvent event) public void adminJoin(PlayerJoinEvent event)
{ {
if (Manager.GetHost() == null || Manager.GetHost().length() == 0) if (!isPrivateServer())
return; return;
if (Manager.GetHost().equals(event.getPlayer().getName())) if (Manager.GetHost().equals(event.getPlayer().getName()))
{ {
System.out.println("Game Host Joined.");
_host = event.getPlayer(); _host = event.getPlayer();
System.out.println("Game Host Joined.");
}
else if (isAdmin(event.getPlayer()))
{
System.out.println("Admin Joined.");
_onlineAdmins.add(event.getPlayer());
} }
} }
@EventHandler @EventHandler
public void hostQuit(PlayerQuitEvent event) public void adminQuit(PlayerQuitEvent event)
{ {
if (Manager.GetHost() == null || Manager.GetHost().length() == 0) if (!isPrivateServer())
return; return;
if (Manager.GetHost().equals(event.getPlayer().getName())) if (isHost(event.getPlayer()))
{ {
System.out.println("Game Host Quit."); System.out.println("Game Host Quit.");
_host = null; _host = null;
} }
else if (isAdmin(event.getPlayer()))
{
_onlineAdmins.remove(event.getPlayer());
}
} }
public boolean isHostExpired() public boolean isHostExpired()
@ -99,18 +154,15 @@ public class GameHostManager implements Listener
return UtilTime.elapsed(_lastOnline, _expireTime) || UtilTime.elapsed(_serverStartTime, _serverExpireTime); return UtilTime.elapsed(_lastOnline, _expireTime) || UtilTime.elapsed(_serverStartTime, _serverExpireTime);
} }
private void giveHostItem() private void giveAdminItem(Player player)
{ {
if (Manager.GetGame() == null) if (Manager.GetGame() == null)
return; return;
if (_host == null) if (UtilGear.isMat(player.getInventory().getItem(5), Material.BOOK_AND_QUILL))
return; return;
if (UtilGear.isMat(_host.getInventory().getItem(5), Material.BOOK_AND_QUILL)) player.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.BOOK, (byte)0, 1, C.cGreen + C.Bold + "/menu"));
return;
_host.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte)0, 1, C.cGreen + C.Bold + "/menu"));
} }
public HashSet<String> getWhitelist() public HashSet<String> getWhitelist()
@ -122,39 +174,55 @@ public class GameHostManager implements Listener
{ {
return _blacklist; return _blacklist;
} }
public HashSet<String> getAdminList()
{
return _adminList;
}
@EventHandler @EventHandler
public void menuCommand(PlayerCommandPreprocessEvent event) public void menuCommand(PlayerCommandPreprocessEvent event)
{ {
if (_host == null || !event.getPlayer().equals(_host)) if (!isAdmin(event.getPlayer()))
return; return;
if (!event.getMessage().toLowerCase().startsWith("/menu")) if (!event.getMessage().toLowerCase().startsWith("/menu"))
return; return;
openMenu(); openMenu(event.getPlayer());
} }
@EventHandler @EventHandler
public void menuInteract(PlayerInteractEvent event) public void menuInteract(PlayerInteractEvent event)
{ {
if (_host == null || !event.getPlayer().equals(_host)) if (!isAdmin(event.getPlayer()))
return; return;
if (!UtilGear.isMat(_host.getItemInHand(), Material.BOOK_AND_QUILL)) if (!UtilGear.isMat(_host.getItemInHand(), Material.BOOK))
return; return;
openMenu(); openMenu(event.getPlayer());
event.setCancelled(true);
}
private void openMenu(Player player)
{
_shop.attemptShopOpen(_host);
} }
public boolean isAdmin(Player player)
private void openMenu()
{ {
if (_host == null) return player.equals(_host) || _adminList.contains(player.getName());
return; }
public boolean isHost(Player player)
//XXX OPEN GUI HERE {
return player.equals(Manager.GetHost());
}
public boolean isPrivateServer()
{
return Manager.GetHost() != null || Manager.GetHost().length() > 0;
} }
@EventHandler @EventHandler
@ -250,6 +318,4 @@ public class GameHostManager implements Listener
Manager.GetGame().Announce(C.cGreen + C.Bold + _host.getName() + " has stopped the game."); Manager.GetGame().Announce(C.cGreen + C.Bold + _host.getName() + " has stopped the game.");
} }
*/
} }