Finish update

This commit is contained in:
William Burns 2015-07-27 18:18:37 +01:00
parent cf61b50d98
commit 76e5d3d562
5 changed files with 122 additions and 13 deletions

View File

@ -78,10 +78,16 @@ public class EditRotationPage extends BasePage
allowedCats.add(GameCategory.EXTRA);
int gameSlot = 9;
for (GameType type : _manager.getAvailableGames(getPlayer()))
for (GameCategory cat : _manager.getGames(getPlayer()).keySet())
{
addGameButton(gameSlot, type, enabledGames.contains(type));
gameSlot++;
if (!allowedCats.contains(cat))
return;
for (GameType type : _manager.getGames(getPlayer()).get(cat))
{
addGameButton(gameSlot, type, enabledGames.contains(type));
gameSlot++;
}
}
}
@ -89,7 +95,12 @@ public class EditRotationPage extends BasePage
{
String titleString = ChatColor.RESET + (enabled ? C.cGreen : C.cRed) + ChatColor.BOLD + type.GetName();
String infoString = ChatColor.RESET + C.cGray + (enabled ? "Click to Disable" : "Click to Enable");
ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), titleString, new String[]{infoString}, 1, false, false);
String[] lore = new String[]{infoString};
if (_manager.hasWarning().contains(type))
{
lore = new String[]{infoString, "§1", "§c§lWARNING: §fThis game was rejected!"};
}
ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), titleString, lore, 1, false, false);
int itemCount = enabled ? 1 : 0;
addButtonFakeCount(slot, shopItem, new IButton()

View File

@ -56,16 +56,22 @@ public class GameVotingPage extends BasePage
allowedCats.add(GameCategory.EXTRA);
int gameSlot = 9;
for (GameType type : _manager.getAvailableGames(getPlayer()))
for (GameCategory cat : _manager.getGames(getPlayer()).keySet())
{
addGameButton(gameSlot, type);
gameSlot++;
if (!allowedCats.contains(cat))
return;
for (GameType type : _manager.getGames(getPlayer()).get(cat))
{
addGameButton(gameSlot, type);
gameSlot++;
}
}
}
private void addCloseButton(int slot)
{
ShopItem item = new ShopItem(Material.BED, (byte)0, "§c§lClose Menu", new String[]{}, 1, false, false);
ShopItem item = new ShopItem(Material.BED, (byte)0, "§cClose Menu", new String[]{}, 1, false, false);
addButton(slot, item, new IButton()
{
@Override
@ -131,6 +137,11 @@ public class GameVotingPage extends BasePage
votes++;
}
String curVotes = "§7Votes: §e" + votes;
String[] lore = new String[]{click, curVotes};
if (_manager.hasWarning().contains(type))
{
lore = new String[]{click, curVotes, "§1", "§c§lWARNING: §fThis game was rejected!"};
}
ShopItem item = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), new String[]{click, curVotes}, 1, false, false);
if (votes >= 1)
{

View File

@ -138,6 +138,14 @@ public class OptionsPage extends BasePage
ChatColor.RED + " ",
ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") };
if (name.equalsIgnoreCase("Enforce Whitelist"))
{
description = new String[] {
"" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"),
ChatColor.RED + " ",
ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable"), "", "§7Use §a/whitelist §e<name>" };
}
addButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button);
addButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte) 10 : (byte) 8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button);
}

View File

@ -74,10 +74,16 @@ public class SetGamePage extends BasePage
allowedCats.add(GameCategory.EXTRA);
int gameSlot = 9;
for (GameType type : _manager.getAvailableGames(getPlayer()))
for (GameCategory cat : _manager.getGames(getPlayer()).keySet())
{
addGameButton(gameSlot, type);
gameSlot++;
if (!allowedCats.contains(cat))
return;
for (GameType type : _manager.getGames(getPlayer()).get(cat))
{
addGameButton(gameSlot, type);
gameSlot++;
}
}
}
@ -87,7 +93,12 @@ public class SetGamePage extends BasePage
String space = "§1";
String left = ChatColor.YELLOW + "Left-Click " + C.cGray + "for a §fRandom Map§7.";
String right = ChatColor.YELLOW + "Right-Click " + C.cGray + "to §fChoose Map§7.";
ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), new String[]{infoString, space, left, right}, 1, false, false);
String[] normLore = new String[]{infoString, space, left, right};
if (_manager.hasWarning().contains(type))
{
normLore = new String[]{infoString, space, left, right, "§2", "§c§lWARNING: §fThis game was rejected!"};
}
ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), normLore, 1, false, false);
addButton(slot, shopItem, new IButton()
{
@Override

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.game.GameCategory;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -134,6 +135,16 @@ public class GameHostManager implements Listener
}
}
public ArrayList<GameType> hasWarning()
{
ArrayList<GameType> games = new ArrayList<>();
games.add(GameType.Evolution);
games.add(GameType.MilkCow);
games.add(GameType.SearchAndDestroy);
games.add(GameType.ZombieSurvival);
return games;
}
@EventHandler
public void updateHost(UpdateEvent event)
{
@ -361,6 +372,40 @@ public class GameHostManager implements Listener
return _adminList;
}
@EventHandler
public void broadcastCommand(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().toLowerCase().startsWith("/bc"))
return;
if (!isPrivateServer())
return;
if (!isAdmin(event.getPlayer(), true))
{
event.getPlayer().sendMessage(F.main("Broadcast", "Only MPS admins can use this command."));
event.setCancelled(true);
return;
}
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
event.getPlayer().sendMessage(F.main("Broadcast", "/bc <message>"));
return;
}
String msg = "";
for (int i = 1; i < event.getMessage().split(" ").length; i++)
{
msg += event.getMessage().split(" ")[i] + " ";
}
msg = msg.trim();
Bukkit.broadcastMessage("§6§l" + event.getPlayer().getName() + " §e" + msg);
}
@EventHandler
public void voteCommand(PlayerCommandPreprocessEvent event)
{
@ -445,6 +490,11 @@ public class GameHostManager implements Listener
if (!event.getMessage().toLowerCase().startsWith("/whitelist "))
return;
if (!isPrivateServer())
return;
event.setCancelled(true);
String[] args = event.getMessage().split(" ");
@ -454,7 +504,7 @@ public class GameHostManager implements Listener
if (_whitelist.add(name))
{
UtilPlayer.message(event.getPlayer(), F.main("Host", "Added " + F.elem(name) + " to the whitelist."));
UtilPlayer.message(event.getPlayer(), F.main("Host", "Added " + F.elem(args[i]) + " to the whitelist."));
}
}
}
@ -539,6 +589,24 @@ public class GameHostManager implements Listener
return games;
}
public HashMap<GameCategory, ArrayList<GameType>> getGames(Player p)
{
HashMap<GameCategory, ArrayList<GameType>> games = new HashMap<GameCategory, ArrayList<GameType>>();
for (GameCategory cat : GameCategory.values())
{
ArrayList<GameType> types = new ArrayList<>();
for (GameType type : getAvailableGames(p))
{
if (type.getGameCategory().equals(cat))
{
types.add(type);
}
}
games.put(cat, types);
}
return games;
}
public void ban(Player player)
{
_blacklist.add(player.getName());