Add player head button

This commit is contained in:
Shaun Bennett 2014-12-22 23:20:20 -06:00
parent befc2cff7c
commit 1957db25d9
4 changed files with 79 additions and 4 deletions

View File

@ -247,7 +247,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
} }
} }
AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 1 : yellowCount, false), new IButton() AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 64 : yellowCount, false), new IButton()
{ {
@Override @Override
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)

View File

@ -0,0 +1,37 @@
package nautilus.game.arcade.gui.privateServer.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.privateServer.page.MenuPage;
public class PlayerHeadButton implements IButton
{
private ArcadeManager _arcadeManager;
private MenuPage _menuPage;
public PlayerHeadButton(ArcadeManager arcadeManager, MenuPage menuPage)
{
_arcadeManager = arcadeManager;
_menuPage = menuPage;
}
@Override
public void onClick(Player player, ClickType clickType)
{
int maxPlayers = _arcadeManager.GetServerConfig().MaxPlayers;
int newMax;
int maxCap = _arcadeManager.GetGameHostManager().getMaxPlayerCap();
if (clickType.isLeftClick())
newMax = ++maxPlayers > maxCap ? maxCap : maxPlayers;
else
newMax = --maxPlayers < 2 ? 2 : maxPlayers;
_arcadeManager.GetServerConfig().MaxPlayers = newMax;
_menuPage.Refresh();
}
}

View File

@ -1,11 +1,15 @@
package nautilus.game.arcade.gui.privateServer.page; package nautilus.game.arcade.gui.privateServer.page;
import java.util.ArrayList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.ShopItem;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
@ -13,6 +17,7 @@ import nautilus.game.arcade.gui.privateServer.button.BanButton;
import nautilus.game.arcade.gui.privateServer.button.EditRotationButton; import nautilus.game.arcade.gui.privateServer.button.EditRotationButton;
import nautilus.game.arcade.gui.privateServer.button.GiveAdminButton; import nautilus.game.arcade.gui.privateServer.button.GiveAdminButton;
import nautilus.game.arcade.gui.privateServer.button.KillButton; import nautilus.game.arcade.gui.privateServer.button.KillButton;
import nautilus.game.arcade.gui.privateServer.button.PlayerHeadButton;
import nautilus.game.arcade.gui.privateServer.button.RemoveAdminButton; import nautilus.game.arcade.gui.privateServer.button.RemoveAdminButton;
import nautilus.game.arcade.gui.privateServer.button.SetGameButton; import nautilus.game.arcade.gui.privateServer.button.SetGameButton;
import nautilus.game.arcade.gui.privateServer.button.OptionsButton; import nautilus.game.arcade.gui.privateServer.button.OptionsButton;
@ -32,7 +37,7 @@ public class MenuPage extends BasePage
protected void BuildPage() protected void BuildPage()
{ {
ItemStack ownerHead = getOwnerHead(); ItemStack ownerHead = getOwnerHead();
setItem(4, ownerHead); AddButton(4, getOwnerHead(), new PlayerHeadButton(Plugin, this));
boolean host = _manager.isHost(Player); boolean host = _manager.isHost(Player);
@ -71,8 +76,22 @@ public class MenuPage extends BasePage
AddButton(host ? 6 + 18 : 7 + 18, new ShopItem(Material.WATER_BUCKET, "Un-Remove Player", new String[] {}, 1, false), unbanButton); AddButton(host ? 6 + 18 : 7 + 18, new ShopItem(Material.WATER_BUCKET, "Un-Remove Player", new String[] {}, 1, false), unbanButton);
} }
private ItemStack getOwnerHead() private ShopItem getOwnerHead()
{ {
return getPlayerHead(Plugin.GetHost(), ChatColor.RESET + "Host: " + ChatColor.YELLOW + Plugin.GetHost()); String title = C.cGreen + C.Bold + Plugin.GetHost() + "'s Mineplex Private Server";
ItemStack head = getPlayerHead(Plugin.GetHost(), ChatColor.RESET + title);
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Server Name: " + C.cWhite + Plugin.GetPlugin().getConfig().getString("serverstatus.name"));
lore.add(ChatColor.RESET + C.cYellow + "Players Online: " + C.cWhite + UtilServer.getPlayers().length);
lore.add(ChatColor.RESET + C.cYellow + "Players Max: " + C.cWhite + Plugin.GetServerConfig().MaxPlayers);
lore.add(" ");
lore.add(ChatColor.RESET + "Left-Click to increase Max Players");
lore.add(ChatColor.RESET + "Right-Click to decrease Max Players");
ItemMeta meta = head.getItemMeta();
meta.setLore(lore);
head.setItemMeta(meta);
return new ShopItem(head, title, title, 1, false, false);
} }
} }

View File

@ -21,6 +21,7 @@ import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -403,6 +404,16 @@ public class GameHostManager implements Listener
Manager.GetServerConfig().TeamForceBalance = true; Manager.GetServerConfig().TeamForceBalance = true;
} }
public int getMaxPlayerCap()
{
if (hasRank(Rank.LEGEND))
return 40;
else if (hasRank(Rank.HERO))
return 12;
else
return 4;
}
@EventHandler @EventHandler
public void setHostDebug(PlayerCommandPreprocessEvent event) public void setHostDebug(PlayerCommandPreprocessEvent event)
{ {
@ -424,4 +435,12 @@ public class GameHostManager implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler
public void playerJoin(PlayerJoinEvent event)
{
String serverName = Manager.GetPlugin().getConfig().getString("serverstatus.name");
UtilPlayer.message(event.getPlayer(), ChatColor.BOLD + "Welcome to Mineplex Private Servers!");
UtilPlayer.message(event.getPlayer(), C.Bold + "Friends can connect with " + C.cGreen + C.Bold + "/server " + serverName);
}
} }