More changes

This commit is contained in:
Shaun Bennett 2014-12-16 20:37:14 -06:00
parent 62a621270e
commit 6eb3efa0b6
11 changed files with 206 additions and 21 deletions

View File

@ -13,7 +13,7 @@ public enum GameType
ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0),
ChampionsMOBA("Champions MOBA", "Champions", Material.SKULL_ITEM, (byte)0),
Christmas("Christmas Chaos", Material.SNOW_BALL, (byte)0),
DeathTag("Death Tag", Material.SKULL, (byte)0),
DeathTag("Death Tag", Material.SKULL_ITEM, (byte)0),
DragonEscape("Dragon Escape", Material.DRAGON_EGG, (byte)0),
DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0),
DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0),
@ -63,12 +63,16 @@ public enum GameType
{
_name = name;
_lobbyName = name;
_mat = mat;
_data = data;
}
GameType(String name, String lobbyName, Material mat, byte data)
{
_name = name;
_lobbyName = lobbyName;
_mat = mat;
_data = data;
}
public String GetName()

View File

@ -69,21 +69,7 @@ public class SetCommand extends CommandBase<ArcadeManager>
}
GameType type = matches.get(0);
Plugin.GetGameCreationManager().SetNextGameType(type);
//End Current
if (Plugin.GetGame().GetState() == GameState.Recruit)
{
Plugin.GetGame().SetState(GameState.Dead);
Plugin.GetGame().Announce(C.cAqua + C.Bold + caller.getName() + " has changed game to " + type.GetName() + ".");
}
else
{
Plugin.GetGame().Announce(C.cAqua + C.Bold + caller.getName() + " set next game to " + type.GetName() + ".");
}
Plugin.GetGame().setGame(type, caller, true);
}
@Override

View File

@ -1322,4 +1322,23 @@ public abstract class Game implements Listener
((CraftWorld) event.getWorld()).getHandle().spigotConfig.itemMerge = _itemMergeRadius;
}
}
public void setGame(GameType gameType, Player caller, boolean inform)
{
Manager.GetGameCreationManager().SetNextGameType(gameType);
//End Current
if (GetState() == GameState.Recruit)
{
SetState(GameState.Dead);
if (inform)
Announce(C.cAqua + C.Bold + caller.getName() + " has changed game to " + gameType.GetName() + ".");
}
else
{
if (inform)
Announce(C.cAqua + C.Bold + caller.getName() + " set next game to " + gameType.GetName() + ".");
}
}
}

View File

@ -1,7 +1,29 @@
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.EditRotationPage;
import nautilus.game.arcade.gui.page.GameHostOptionsPage;
import nautilus.game.arcade.gui.page.GiveAdminPage;
public class EditRotationButton extends ComplexButton
{
private ArcadeManager _arcadeManager;
private GameHostShop _shop;
public EditRotationButton(ArcadeManager arcadeManager, GameHostShop shop)
{
_shop = shop;
_arcadeManager = arcadeManager;
}
@Override
public void Clicked(Player player, ClickType clickType)
{
_shop.OpenPageForPlayer(player, new EditRotationPage(_arcadeManager, _shop, player));
}
}

View File

@ -1,7 +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.GiveAdminPage;
import nautilus.game.arcade.gui.page.SetGamePage;
public class SetGameButton extends ComplexButton
{
private ArcadeManager _arcadeManager;
private GameHostShop _shop;
public SetGameButton(ArcadeManager arcadeManager, GameHostShop shop)
{
_shop = shop;
_arcadeManager = arcadeManager;
}
@Override
public void Clicked(Player player, ClickType clickType)
{
_shop.OpenPageForPlayer(player, new SetGamePage(_arcadeManager, _shop, player));
}
}

View File

@ -19,7 +19,7 @@ public class BanPage extends PlayerPage
{
public BanPage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Unban Players", player);
super(plugin, shop, "Ban Players", player);
BuildPage();
}

View File

@ -0,0 +1,58 @@
package nautilus.game.arcade.gui.page;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.gui.GameHostShop;
public class EditRotationPage extends GameHostPage
{
public EditRotationPage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Edit Rotation", player);
BuildPage();
}
@Override
protected void BuildPage()
{
addBackButton(4);
int slot = 9;
List<GameType> enabledGames = Plugin.GetServerConfig().GameList;
for (GameType type : _manager.getAvailableGames())
{
addGameButton(slot, type, enabledGames.contains(type));
slot++;
}
}
private void addGameButton(int slot, final GameType type, boolean enabled)
{
String titleString = ChatColor.RESET + (enabled ? C.cGreen : C.cRed) + ChatColor.BOLD + type.GetLobbyName();
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);
AddButton(slot, shopItem, new SingleButton()
{
@Override
public void Clicked(Player player)
{
if (Plugin.GetServerConfig().GameList.contains(type))
Plugin.GetServerConfig().GameList.remove(type);
else
Plugin.GetServerConfig().GameList.add(type);
Refresh();
}
});
if (enabled)
addGlow(slot);
}
}

View File

@ -30,10 +30,10 @@ public class GameHostMenuPage extends GameHostPage
ItemStack ownerHead = getOwnerHead();
setItem(4, ownerHead);
SetGameButton setGameButton = new SetGameButton();
SetGameButton setGameButton = new SetGameButton(Plugin, Shop);
AddButton(1 + 9, new ShopItem(Material.BOOK_AND_QUILL, "Set Game", new String[] {}, 1, false), setGameButton);
EditRotationButton editRotationButton = new EditRotationButton();
EditRotationButton editRotationButton = new EditRotationButton(Plugin, Shop);
AddButton(1 + 18, new ShopItem(Material.BOOK, "Edit Game Rotation", new String[]{}, 1, false), editRotationButton);
GiveAdminButton giveAdminButton = new GiveAdminButton(Plugin, Shop);

View File

@ -61,7 +61,7 @@ public class GameHostOptionsPage extends GameHostPage
}
});
buildPreference(16, Material.COMPASS, "Kick Idle Players", _config.PlayerKickIdle, new SingleButton()
buildPreference(16, Material.WATCH, "Kick Idle Players", _config.PlayerKickIdle, new SingleButton()
{
@Override
public void Clicked(Player player)

View File

@ -0,0 +1,50 @@
package nautilus.game.arcade.gui.page;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.gui.GameHostShop;
public class SetGamePage extends GameHostPage
{
public SetGamePage(ArcadeManager plugin, GameHostShop shop, Player player)
{
super(plugin, shop, "Set Game", player);
BuildPage();
}
@Override
protected void BuildPage()
{
addBackButton(4);
int slot = 9;
for (GameType type : _manager.getAvailableGames())
{
addGameButton(slot, type);
slot++;
}
}
private void addGameButton(int slot, final GameType type)
{
String infoString = ChatColor.RESET + C.cGray + "Click to make this next Game Type";
ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetLobbyName(), new String[]{infoString}, 1, false, false);
AddButton(slot, shopItem, new SingleButton()
{
@Override
public void Clicked(Player player)
{
Plugin.GetGame().setGame(type, player, true);
Player.closeInventory();
}
});
}
}

View File

@ -1,8 +1,11 @@
package nautilus.game.arcade.managers;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import com.sun.org.apache.xpath.internal.SourceTree;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
@ -68,6 +71,7 @@ public class GameHostManager implements Listener
ultraGames.add(GameType.Snake);
ultraGames.add(GameType.SneakyAssassins);
ultraGames.add(GameType.TurfWars);
ultraGames.add(GameType.Spleef);
//Hero Games
heroGames.add(GameType.ChampionsDominate);
@ -207,7 +211,7 @@ public class GameHostManager implements Listener
private void openMenu(Player player)
{
_shop.attemptShopOpen(_host);
_shop.attemptShopOpen(player);
}
public boolean isAdmin(Player player)
@ -321,6 +325,26 @@ public class GameHostManager implements Listener
Manager.GetGame().Announce(C.cGreen + C.Bold + _host.getName() + " has stopped the game.");
}
public boolean hasRank(Rank rank)
{
//TODO
return true;
}
public List<GameType> getAvailableGames()
{
List<GameType> games = new ArrayList<GameType>();
if (hasRank(Rank.ULTRA))
games.addAll(ultraGames);
if (hasRank(Rank.HERO))
games.addAll(heroGames);
if (hasRank(Rank.MODERATOR))
games.addAll(legendGames);
return games;
}
public void ban(Player player)
{
_blacklist.add(player.getName());
@ -330,6 +354,7 @@ public class GameHostManager implements Listener
public void giveAdmin(Player player)
{
_adminList.add(player.getName());
_onlineAdmins.add(player);
UtilPlayer.message(player, F.main("Server", "You were given admin privileges for this private server"));
}
}