Clans gui work

This commit is contained in:
Shaun Bennett 2015-11-07 19:58:03 -05:00
parent addde570bb
commit af1d91913b
5 changed files with 224 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.gui.page.ClansMainPage;
import mineplex.game.clans.clans.gui.page.ClansPage;
public class ClansCommandShop extends ShopBase<ClansManager>
{
@ -20,6 +21,6 @@ public class ClansCommandShop extends ShopBase<ClansManager>
@Override
protected ShopPageBase<ClansManager, ? extends ShopBase<ClansManager>> buildPagesFor(Player player)
{
return new ClansMainPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
return new ClansPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
}
}

View File

@ -2,6 +2,7 @@ package mineplex.game.clans.clans.gui.button;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.shop.item.IButton;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
@ -41,4 +42,20 @@ public abstract class ClanButton implements IButton
{
return _clanRole;
}
protected void displayText(String header, String message)
{
UtilTextMiddle.display(header, message, _player);
}
protected void displayClan(String header, String message, boolean displayForClicker)
{
for (Player player : _clanInfo.getOnlinePlayers())
{
if (displayForClicker || !player.equals(getPlayer()))
UtilTextMiddle.display(header, message, player);
}
_clansManager.messageClan(_clanInfo, message);
}
}

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.clans.gui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
public class ClanEnergyButton extends ClanButton
{
public ClanEnergyButton(ClansManager clansManager, Player player, ClanInfo clanInfo, ClanRole clanRole)
{
super(clansManager, player, clanInfo, clanRole);
}
@Override
public void onClick(Player player, ClickType clickType)
{
}
}

View File

@ -1,8 +1,51 @@
package mineplex.game.clans.clans.gui.button;
/**
* Created by phina on 10/31/2015.
*/
public class ClanTerritoryButton
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.shop.item.IButton;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
public class ClanTerritoryButton extends ClanButton
{
public ClanTerritoryButton(ClansManager clansManager, Player player, ClanInfo clanInfo, ClanRole clanRole)
{
super(clansManager, player, clanInfo, clanRole);
}
@Override
public void onClick(Player player, ClickType clickType)
{
if (clickType == ClickType.LEFT)
{
player.closeInventory();
Chunk chunk = player.getLocation().getChunk();
String chunkName = UtilWorld.chunkToStrClean(chunk);
displayText(C.cGreen + "Territory", "You claimed the chunk " + chunkName);
displayClan(C.cGreen + "Territory", C.cYellow + getPlayer().getName() + ChatColor.RESET + " claimed the chunk " + chunkName, false);
}
else if (clickType == ClickType.SHIFT_LEFT)
{
player.closeInventory();
Chunk chunk = player.getLocation().getChunk();
String chunkName = UtilWorld.chunkToStrClean(chunk);
displayText(C.cGreen + "Territory", "You unclaimed the chunk " + chunkName);
displayClan(C.cGreen + "Territory", C.cYellow + getPlayer().getName() + ChatColor.RESET + " unclaimed the chunk " + chunkName, false);
}
else if (clickType == ClickType.SHIFT_RIGHT)
{
player.closeInventory();
displayText(C.cGreen + "Territory", "You unclaimed all chunks");
displayClan(C.cGreen + "Territory", C.cYellow + getPlayer().getName() + ChatColor.RESET + " unclaimed all chunks", false);
}
}
}

View File

@ -0,0 +1,136 @@
package mineplex.game.clans.clans.gui.page;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.gui.ClansCommandShop;
import mineplex.game.clans.clans.gui.button.ClanCreateButton;
import mineplex.game.clans.clans.gui.button.ClanEnergyButton;
import mineplex.game.clans.clans.gui.button.ClanInviteButton;
import mineplex.game.clans.clans.gui.button.ClanLeaveButton;
import mineplex.game.clans.clans.gui.button.ClanTerritoryButton;
import mineplex.game.clans.clans.gui.button.ClanWhoButton;
public class ClansPage extends ClansCommandPageBase
{
private boolean _useResourceIcons;
public ClansPage(ClansManager plugin, ClansCommandShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Manage Clan", player, 54);
_useResourceIcons = false;
}
@Override
public void buildNoClan()
{
// Clan Create
ShopItem clanCreate = new ShopItem(Material.BOOK_AND_QUILL, "Create Clan", new String[] {}, 1, false, false);
addButton(2, clanCreate, new ClanCreateButton());
// Clan Join
ShopItem clanJoin = new ShopItem(Material.BOOK, "Join Clan", new String[] {}, 1, false, false);
addButton(4, clanJoin, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new ClansJoinPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
}
});
// Clan Who
ShopItem clanWho = new ShopItem(Material.MAP, "Lookup Clan", new String[] {}, 1, false, false);
addButton(6, clanWho, new ClanWhoButton());
}
@Override
public void buildClan(ClanInfo clanInfo, ClanRole clanRole)
{
// Invites
{
String inviteName = "Invites";
Material inviteMaterial = _useResourceIcons ? Material.MONSTER_EGG : Material.RED_ROSE;
byte inviteDate = _useResourceIcons ? (byte) 0 : 0;
ArrayList<String> inviteLore = new ArrayList<String>();
inviteLore.add("Text about inviting players");
inviteLore.add(" ");
inviteLore.add("Click to Invite Player");
ShopItem inviteItem = new ShopItem(inviteMaterial, inviteDate, inviteName, inviteLore.toArray(new String[0]), 1, false, false);
ClanInviteButton inviteButton = new ClanInviteButton(getPlayer());
addButton(0, inviteItem, inviteButton);
}
// Territory
{
String territoryName = "Territory";
Material territoryMaterial = _useResourceIcons ? Material.MONSTER_EGG : Material.GRASS;
byte territoryData = _useResourceIcons ? (byte) 0 : 0;
ArrayList<String> territoryLore = new ArrayList<String>();
territoryLore.add("Territory Information");
territoryLore.add(" ");
territoryLore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Claim Land");
territoryLore.add(ChatColor.RESET + C.cGray + "Shift-Left Click " + C.cWhite + "Unclaim Land");
territoryLore.add(ChatColor.RESET + C.cGray + "Shift-Right Click " + C.cWhite + "Unclaim All Land");
ShopItem territoryItem = new ShopItem(territoryMaterial, territoryData, territoryName, territoryLore.toArray(new String[0]), 1, false, false);
ClanTerritoryButton territoryButton = new ClanTerritoryButton(getPlugin(), getPlayer(), clanInfo, clanRole);
addButton(2, territoryItem, territoryButton);
}
// Energy
{
String energyName = "Energy";
Material energyMaterial = _useResourceIcons ? Material.MONSTER_EGG : Material.GOLD_BLOCK;
byte energyData = _useResourceIcons ? (byte) 0 : 0;
ArrayList<String> energyLore = new ArrayList<String>();
ShopItem energyItem = new ShopItem(energyMaterial, energyData, energyName, energyLore.toArray(new String[0]), 1, false, false);
ClanEnergyButton energyButton = new ClanEnergyButton(getPlugin(), getPlayer(), clanInfo, clanRole);
addButton(4, energyItem, energyButton);
}
// Leave
{
String leaveName = "Leave";
Material leaveMaterial = _useResourceIcons ? Material.MONSTER_EGG : Material.TNT;
byte leaveData = _useResourceIcons ? (byte) 0 : 0;
ArrayList<String> leaveLore = new ArrayList<String>();
ShopItem leaveItem = new ShopItem(leaveMaterial, leaveData, leaveName, leaveLore.toArray(new String[0]), 1, false, false);
ClanLeaveButton leaveButton = new ClanLeaveButton(getPlugin(), getPlayer(), clanInfo, clanRole);
addButton(6, leaveItem, leaveButton);
}
// Commands
{
String commandsName = "Commands";
Material commandsMaterial = _useResourceIcons ? Material.MONSTER_EGG : Material.PAPER;
byte commandsData = _useResourceIcons ? (byte) 0 : 0;
ArrayList<String> commandsLore = new ArrayList<String>();
ShopItem commandsItem = new ShopItem(commandsMaterial, commandsData, commandsName, commandsLore.toArray(new String[0]), 1, false, false);
setItem(8, commandsItem);
}
// Players
// Allies
// Wars
}
}