Temporary un-finished changes for adding in team/solo UI pages and allowing players to select.

This commit is contained in:
Ty Sayers 2015-08-02 19:19:40 -04:00
parent fa2bcf7f69
commit 4852e69991
5 changed files with 144 additions and 13 deletions

View File

@ -324,7 +324,7 @@ public class ServerManager extends MiniPlugin
// TODO: Determine whether server group is team based or not
boolean teamBased = false;
_serverNpcShopMap.put(serverNpcName, new ServerNpcShop(this, _clientManager, _donationManager, serverNpcName, teamBased));
_serverNpcShopMap.put(serverNpcName, new ServerNpcShop(this, _clientManager, _donationManager, null));
}
public void RemoveServerNpc(String serverNpcName)

View File

@ -17,6 +17,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.game.GameDisplay;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
@ -41,7 +42,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverNpcKey)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
super(plugin, shop, clientManager, donationManager, name, player, 27);
_serverNpcKey = serverNpcKey;
@ -51,6 +52,21 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
@Override
protected void buildPage()
{
setItem(12, ItemStackFactory.Instance.CreateStack(Material.SKULL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Play Solo " + C.cGray + getName(), new String[]
{
ChatColor.RESET + "Solo Mode",
ChatColor.RESET + "",
ChatColor.RESET + "Click to play!",
ChatColor.RESET + "",
ChatColor.RESET + "Teaming in Solo Mode is bannable!",
}));
setItem(14, ItemStackFactory.Instance.CreateStack(Material.SKULL.getId(), (byte)0, 2, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Play Team " + C.cGray + getName(), new String[]
{
ChatColor.RESET + "Team Mode",
ChatColor.RESET + "",
ChatColor.RESET + "Click to play!"
}));
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().GetServerList(_serverNpcKey));
int slotsNeeded = 1;

View File

@ -11,22 +11,23 @@ import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerManager;
import mineplex.serverdata.data.ServerGroup;
public class ServerNpcShop extends ShopBase<ServerManager>
{
private boolean _teamBased; // Whether this server type has a team/solo based component
private ServerGroup _serverGroup;
public ServerNpcShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name, boolean teamBased)
public ServerNpcShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager, ServerGroup serverGroup)
{
super(plugin, clientManager, donationManager, name);
super(plugin, clientManager, donationManager, serverGroup.getName());
_teamBased = teamBased;
_serverGroup = serverGroup;
}
@Override
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> buildPagesFor(Player player)
{
return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), getName(), player, getName());
return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
}
@Override
@ -73,15 +74,12 @@ public class ServerNpcShop extends ShopBase<ServerManager>
@Override
public boolean attemptShopOpen(Player player)
{
if (!_teamBased) // Check this isn't a team/solo gametype shop
if (true) // TODO: Check to see if _serverGroup's teamKey field is null
{
getPlugin().selectServer(player, getName());
return false;
}
else
{
// TODO: Open up team/solo selection menu and then select appropriate server
return super.attemptShopOpen(player);
}
return super.attemptShopOpen(player);
}
}

View File

@ -0,0 +1,89 @@
package mineplex.hub.server.ui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementCategory;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.game.GameDisplay;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.hub.server.ServerInfo;
import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ServerSorter;
import mineplex.hub.server.ui.button.JoinServerButton;
import mineplex.hub.server.ui.button.SelectBRButton;
import mineplex.hub.server.ui.button.SelectTypeButton;
import mineplex.serverdata.data.ServerGroup;
public class ServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
{
private ServerGroup _serverGroup;
public ServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager,
Player player, ServerGroup serverGroup)
{
super(plugin, shop, clientManager, donationManager, serverGroup.getName(), player, 27);
_serverGroup = serverGroup;
buildPage();
}
@Override
protected void buildPage()
{
String name = _serverGroup.getName();
setItem(12, ItemStackFactory.Instance.CreateStack(Material.SKULL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Play Solo " + C.cGray + name, new String[]
{
ChatColor.RESET + "Solo Mode",
ChatColor.RESET + "",
ChatColor.RESET + "Click to play!",
ChatColor.RESET + "",
ChatColor.RESET + "Teaming in Solo Mode is bannable!",
}));
setItem(14, ItemStackFactory.Instance.CreateStack(Material.SKULL.getId(), (byte)0, 2, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Play Team " + C.cGray + name, new String[]
{
ChatColor.RESET + "Team Mode",
ChatColor.RESET + "",
ChatColor.RESET + "Click to play!"
}));
getButtonMap().put(12, new SelectTypeButton(this, false));
getButtonMap().put(14, new SelectTypeButton(this, true));
}
public void Update()
{
getButtonMap().clear();
buildPage();
}
public void selectServer(Player player, boolean team)
{
if (team)
{
getPlugin().selectServer(player, _serverGroup.getPrefix()); // TODO: Grab the team-key instead of regular game key
}
else
{
getPlugin().selectServer(player, _serverGroup.getPrefix());
}
}
}

View File

@ -0,0 +1,28 @@
package mineplex.hub.server.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.hub.server.ServerInfo;
import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ui.IServerPage;
import mineplex.hub.server.ui.ServerTypePage;
public class SelectTypeButton implements IButton
{
private ServerTypePage _page;
private boolean _teamBased;
public SelectTypeButton(ServerTypePage page, boolean teamBased)
{
_page = page;
_teamBased = teamBased;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_page.selectServer(player, _teamBased);
}
}