From b75e87753dc178d2ea417671348079a2d575a6b8 Mon Sep 17 00:00:00 2001 From: TadahTech Date: Mon, 20 Jun 2016 22:45:53 -0500 Subject: [PATCH] Party UI work. --- .../src/mineplex/core/party/PartyManager.java | 2 + .../core/party/command/PartyCommand.java | 26 ++++++----- .../party/manager/PartyInviteManager.java | 3 +- .../core/party/manager/PartyRedisManager.java | 4 +- .../core/party/ui/button/PartyMemberIcon.java | 38 ++++------------ .../ui/button/tools/LeavePartyButton.java | 6 +-- .../ui/button/tools/invite/BackButton.java | 8 ++++ .../ui/button/tools/invite/DenyAllButton.java | 8 ++++ .../ui/button/tools/invite/Filterbutton.java | 8 ++++ .../ui/button/tools/invite/InviteButton.java | 8 ++++ .../button/tools/invite/NextPageButton.java | 8 ++++ .../button/tools/invite/PrevPageButton.java | 8 ++++ .../button/tools/main/InvitePlayerButton.java | 8 ++++ .../button/tools/main/ViewInvitesButton.java | 8 ++++ .../tools/{ => owner}/AddPlayerButton.java | 8 ++-- .../tools/owner/DisbandPartyButton.java | 8 ++++ .../button/tools/owner/KickPlayerButton.java | 8 ++++ .../tools/owner/SelectServerButton.java | 8 ++++ .../tools/owner/TransferOwnerButton.java | 8 ++++ .../tools/view/SuggestPlayerButton.java | 35 +++++++++++++++ .../core/party/ui/menus/PartyInvitesMenu.java | 24 +++++++++++ .../core/party/ui/menus/PartyOwnerMenu.java | 23 +++++++--- .../core/party/ui/menus/PartyViewMenu.java | 14 ++++-- ...yerMenu.java => PlayerNameActionMenu.java} | 29 +++++++------ .../ui/menus/input/PartyInvitePlayerMenu.java | 35 +++++++++++++++ .../menus/input/PlayerSuggestPlayerMenu.java | 43 +++++++++++++++++++ 26 files changed, 313 insertions(+), 73 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/Filterbutton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java rename Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/{ => owner}/AddPlayerButton.java (68%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/view/SuggestPlayerButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java rename Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/{InvitePlayerMenu.java => PlayerNameActionMenu.java} (87%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PartyInvitePlayerMenu.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PlayerSuggestPlayerMenu.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 6ff8d01bc..77d010ea4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -7,6 +7,7 @@ import mineplex.core.party.command.PartyCommand; import mineplex.core.party.manager.PartyInviteManager; import mineplex.core.party.manager.PartyJoinManager; import mineplex.core.party.manager.PartyRedisManager; +import mineplex.core.party.ui.MenuListener; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.serverdata.Utility; @@ -45,6 +46,7 @@ public class PartyManager extends MiniPlugin _inviteManager = new PartyInviteManager(this, _redisManager); _joinManager = new PartyJoinManager(this); addCommand(new PartyCommand(this)); + getPluginManager().registerEvents(new MenuListener(), getPlugin()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java index 086ab5b0b..ea99269d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java @@ -22,16 +22,16 @@ public class PartyCommand extends CommandBase { private final String[] HELP = { - C.cDGreenB + C.Strike + "================================", - C.cGray + "/party help - Shows this help screen.", - C.cGray + "/party - Brings up the Party GUI.", - C.cGray + "/party invite - Invite a player to your party." + C.cRed + " Must be the owner.", - C.cGray + "/party accept - Accept an invite to a player's party.", - C.cGray + "/party deny - Deny an invite to a player's party.", - C.cGray + "/party leave - Leave your current party.", - C.cGray + "/party kick/remove - Remove a player from your party." + C.cRed + " Must be the owner.", - C.cGray + "/party disband - Disband your party." + C.cRed + " Must be the owner.", - C.cDGreenB + C.Strike + "================================", + F.main("Party", "Party Commands"), + help("help", "Shows this help screen"), + help("", "Brings up the Party GUI"), + help("invite ", "Invite a player to your party." + C.cRed + " Must be the leader."), + help("accept ", "Accept an invite to a player's party."), + help("deny ", "Deny an invite to a player's party."), + help("leave", "Leave your current party"), + help("kick/remove ", "Remove a player from your party. " + C.cRed + "Must be the leader."), + help("disband", "Disband your party. " + C.cRed + "Must be the leader."), + C.cBlue + "Party> " + C.cWhite + "# " + C.cGray + "- Send a message to the players in your party." }; public PartyCommand(PartyManager plugin) @@ -56,7 +56,6 @@ public class PartyCommand extends CommandBase return; } new PartyViewMenu(party, Plugin).open(caller); - //Show UI return; } String argument = args[0]; @@ -210,5 +209,10 @@ public class PartyCommand extends CommandBase Plugin.removeParty(party); } + private String help(String command, String description) + { + return C.cBlue + "Party> " + C.cWhite + "/party " + command + C.cGray + " - " + description; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index 16813ec79..82150b8a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -64,7 +64,7 @@ public class PartyInviteManager public void respondToInvite(Player player, String party, boolean accept) { - Player possible = Bukkit.getPlayer(party); + Player possible = Bukkit.getPlayerExact(party); remove(party, player.getUniqueId()); @@ -79,7 +79,6 @@ public class PartyInviteManager if (newParty == null) { player.sendMessage(message); - player.sendMessage(F.main("Party", "Party not created.")); return; } newParty.sendMessage(message); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index 04114fcb6..9a345660c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -121,13 +121,13 @@ public class PartyRedisManager @Override public void run() { - Player senderPlayer = Bukkit.getPlayer(sender); + TASKS.remove(player); + Player senderPlayer = Bukkit.getPlayerExact(sender); if(senderPlayer == null) { return; } senderPlayer.sendMessage(F.main("Party", "Could not locate " + F.elem(player))); - TASKS.remove(player); } }.runTaskLater(_plugin.getPlugin(), 20L * 4)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/PartyMemberIcon.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/PartyMemberIcon.java index f01c58870..27dd7ac34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/PartyMemberIcon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/PartyMemberIcon.java @@ -14,41 +14,21 @@ import org.bukkit.inventory.ItemStack; /** * The button representing a Party member. */ -public class PartyMemberIcon extends Button +public class PartyMemberIcon extends IconButton { - private final ItemStack DEFAULT = ItemStackFactory.Instance.CreateStack(Material.INK_SACK, DyeColor.GRAY.getDyeData(), 1, "Locating..."); - - private ItemStack _itemStack; - private String _target; - - public PartyMemberIcon(String player, PartyManager plugin) + public PartyMemberIcon(String player, boolean owner) { - super(null, plugin); - - _target = player; - - String[] lore = { - - }; - - ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3); - builder.setTitle(C.cYellow + player); - builder.setLore(lore); - builder.setPlayerHead(player); - - _itemStack = builder.build(); - + super(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3) + .setTitle(C.cYellow + player) + .setGlow(owner) + .setPlayerHead(player).build(), null); } - @Override - public void onClick(Player player, ClickType clickType) + public PartyMemberIcon(String player) { + this(player, false); } - @Override - public ItemStack getItemStack() - { - return _itemStack; - } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java index c3ef5d12d..2bfa1353f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java @@ -15,13 +15,13 @@ import org.bukkit.inventory.ItemStack; public class LeavePartyButton extends Button { - private static final ItemStack ITEM = new ItemBuilder(Material.BARRIER) + private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK) .setTitle(C.cYellow + "Leave Party") .build(); - public LeavePartyButton(PartyManager plugin) + public LeavePartyButton() { - super(ITEM, plugin); + super(ITEM, null); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java new file mode 100644 index 000000000..fadaa503e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.invite; + +/** + * + */ +public class BackButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java new file mode 100644 index 000000000..b725893d8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.invite; + +/** + * + */ +public class DenyAllButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/Filterbutton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/Filterbutton.java new file mode 100644 index 000000000..48ae67294 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/Filterbutton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.invite; + +/** + * + */ +public class FilterButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java new file mode 100644 index 000000000..e80a8433d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.invite; + +/** + * + */ +public class InviteButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java new file mode 100644 index 000000000..b857b5163 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.invite; + +/** + * + */ +public class NextPageButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java new file mode 100644 index 000000000..05e5a0b4a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.invite; + +/** + * + */ +public class PrevPageButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java new file mode 100644 index 000000000..48068ea98 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.main; + +/** + * + */ +public class InvitePlayerButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java new file mode 100644 index 000000000..b5dfbbd74 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.main; + +/** + * + */ +public class ViewInvitesButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/AddPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java similarity index 68% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/AddPlayerButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java index e525f6777..0a236ce9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/AddPlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java @@ -1,10 +1,12 @@ -package mineplex.core.party.ui.button.tools; +package mineplex.core.party.ui.button.tools.owner; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.menus.InvitePlayerMenu; +import mineplex.core.party.ui.button.tools.PartyButton; +import mineplex.core.party.ui.menus.PlayerNameActionMenu; +import mineplex.core.party.ui.menus.input.PartyInvitePlayerMenu; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -28,7 +30,7 @@ public class AddPlayerButton extends PartyButton @Override public void onClick(Player player, ClickType clickType) { - new InvitePlayerMenu(getPlugin(), player, getParty()).openInventory(); + new PartyInvitePlayerMenu(getPlugin(), player, getParty()).openInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java new file mode 100644 index 000000000..53b893c7e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.owner; + +/** + * + */ +public class DisbandPartyButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java new file mode 100644 index 000000000..0f15e00b5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.owner; + +/** + * + */ +public class KickPlayerButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java new file mode 100644 index 000000000..82d476ae6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.owner; + +/** + * + */ +public class SelectServerButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java new file mode 100644 index 000000000..e9aacadc0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java @@ -0,0 +1,8 @@ +package mineplex.core.party.ui.button.tools.owner; + +/** + * + */ +public class TransferOwnerButton +{ +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/view/SuggestPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/view/SuggestPlayerButton.java new file mode 100644 index 000000000..3c8fa6ce5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/view/SuggestPlayerButton.java @@ -0,0 +1,35 @@ +package mineplex.core.party.ui.button.tools.view; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.party.ui.button.tools.PartyButton; +import mineplex.core.party.ui.menus.input.PlayerSuggestPlayerMenu; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class SuggestPlayerButton extends PartyButton +{ + + private static final ItemStack ITEM = new ItemBuilder(Material.BOOK_AND_QUILL) + .setTitle(C.cYellow + "Suggest Player") + .setLore(" ", C.cWhite + "Suggest a player for the owner to invite") + .build(); + + public SuggestPlayerButton(Party party, PartyManager plugin) + { + super(ITEM, party, plugin); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + new PlayerSuggestPlayerMenu(getPlugin(), player, getParty()).openInventory(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java new file mode 100644 index 000000000..0e53b7f08 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java @@ -0,0 +1,24 @@ +package mineplex.core.party.ui.menus; + +import mineplex.core.party.PartyManager; +import mineplex.core.party.ui.Button; +import mineplex.core.party.ui.Menu; +import org.bukkit.entity.Player; + +/** + * + */ +public class PartyInvitesMenu extends Menu +{ + + public PartyInvitesMenu(PartyManager plugin) + { + super("Invites", plugin); + } + + @Override + protected Button[] setUp(Player player) + { + return new Button[0]; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java index cd818b98b..e9b9204e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java @@ -5,7 +5,8 @@ import mineplex.core.party.PartyManager; import mineplex.core.party.ui.Button; import mineplex.core.party.ui.Menu; import mineplex.core.party.ui.button.PartyMemberIcon; -import mineplex.core.party.ui.button.tools.AddPlayerButton; +import mineplex.core.party.ui.button.tools.owner.AddPlayerButton; +import mineplex.core.party.ui.button.tools.LeavePartyButton; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -31,16 +32,26 @@ public class PartyOwnerMenu extends Menu //Tools buttons[1] = new AddPlayerButton(_plugin, _party); + //Kick player buttons[4] = create(new ItemStack(Material.IRON_AXE)); - buttons[7] = create(new ItemStack(Material.BARRIER)); + //Transfer ownership + buttons[7] = create(new ItemStack(Material.BOOK_AND_QUILL)); + //Go to server buttons[46] = create(new ItemStack(Material.COMPASS)); - buttons[49] = create(new ItemStack(Material.EMERALD_BLOCK)); - buttons[52] = create(new ItemStack(Material.BOOK_AND_QUILL)); + //Leave party + buttons[49] = new LeavePartyButton(); + //Disband + buttons[52] = create(new ItemStack(Material.BARRIER)); + int slot = 20; //Players - for(int i = 18; i < _party.getMembers().size(); i++) + for(int i = 0; i < _party.getMembers().size(); i++) { - buttons[i] = new PartyMemberIcon(_party.getMembers().get(i), _plugin); + if(slot == 25) + { + slot = 29; + } + buttons[slot++] = new PartyMemberIcon(_party.getMembers().get(i)); } return buttons; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java index 654598c61..4f7d36b00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java @@ -6,6 +6,7 @@ import mineplex.core.party.ui.Button; import mineplex.core.party.ui.Menu; import mineplex.core.party.ui.button.PartyMemberIcon; import mineplex.core.party.ui.button.tools.LeavePartyButton; +import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton; import org.bukkit.entity.Player; /** @@ -25,14 +26,21 @@ public class PartyViewMenu extends Menu @Override protected Button[] setUp(Player player) { - Button[] buttons = new Button[54]; + Button[] buttons = new Button[36]; //Tools - buttons[4] = new LeavePartyButton(_plugin); + buttons[1] = new LeavePartyButton(); + //Suggest Player + buttons[4] = new SuggestPlayerButton(_party, _plugin); + int slot = 20; //Players for(int i = 0; i < _party.getMembers().size(); i++) { - buttons[i + 18] = new PartyMemberIcon(_party.getMembers().get(i), _plugin); + if(slot == 25) + { + slot = 29; + } + buttons[slot++] = new PartyMemberIcon(_party.getMembers().get(i)); } return buttons; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/InvitePlayerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PlayerNameActionMenu.java similarity index 87% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/InvitePlayerMenu.java rename to Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PlayerNameActionMenu.java index 631abc475..d4f00a3f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/InvitePlayerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PlayerNameActionMenu.java @@ -20,19 +20,19 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; /** - * + * This class handles creating inventory GUIs that need a players input to finalize */ -public class InvitePlayerMenu implements Listener +public abstract class PlayerNameActionMenu implements Listener { - private PartyManager _partyManager; - private Player _player; - private Inventory _currentInventory; - private String _itemName = ""; - private boolean _searching; - private Party _party; + protected PartyManager _partyManager; + protected Player _player; + protected Inventory _currentInventory; + protected String _itemName = ""; + protected boolean _searching; + protected Party _party; - public InvitePlayerMenu(PartyManager partyManager, Player player, Party party) + public PlayerNameActionMenu(PartyManager partyManager, Player player, Party party) { _player = player; _partyManager = partyManager; @@ -42,6 +42,10 @@ public class InvitePlayerMenu implements Listener _partyManager.registerEvents(this); } + public abstract void onSuccess(String name); + + public abstract void onFail(String name); + @EventHandler public void onInventoryClose(InventoryCloseEvent event) { @@ -84,14 +88,11 @@ public class InvitePlayerMenu implements Listener if (result != null) { - _partyManager.getRedisManager().findAndInvite(name, _player.getName()); - _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); - + onSuccess(name); unregisterListener(); - _player.closeInventory(); - new PartyOwnerMenu(_party, _partyManager).open(_player); } else { + onFail(name); _currentInventory.setItem(2, new ItemBuilder(Material.PAPER) .setTitle(C.cYellow + "0" + C.cGray + " matches for [" + C.cYellow + name + C.cGray + "]") .build()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PartyInvitePlayerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PartyInvitePlayerMenu.java new file mode 100644 index 000000000..b4d480e20 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PartyInvitePlayerMenu.java @@ -0,0 +1,35 @@ +package mineplex.core.party.ui.menus.input; + +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.party.ui.menus.PartyOwnerMenu; +import mineplex.core.party.ui.menus.PlayerNameActionMenu; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +/** + * + */ +public class PartyInvitePlayerMenu extends PlayerNameActionMenu +{ + + public PartyInvitePlayerMenu(PartyManager partyManager, Player player, Party party) + { + super(partyManager, player, party); + } + + @Override + public void onSuccess(String name) + { + _partyManager.getRedisManager().findAndInvite(name, _player.getName()); + _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); + _player.closeInventory(); + new PartyOwnerMenu(_party, _partyManager).open(_player); + } + + @Override + public void onFail(String name) + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PlayerSuggestPlayerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PlayerSuggestPlayerMenu.java new file mode 100644 index 000000000..3dff2ecf2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/input/PlayerSuggestPlayerMenu.java @@ -0,0 +1,43 @@ +package mineplex.core.party.ui.menus.input; + +import mineplex.core.common.jsonchat.ChildJsonMessage; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.HoverEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import mineplex.core.party.ui.menus.PlayerNameActionMenu; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +/** + * + */ +public class PlayerSuggestPlayerMenu extends PlayerNameActionMenu +{ + + public PlayerSuggestPlayerMenu(PartyManager partyManager, Player player, Party party) + { + super(partyManager, player, party); + } + + @Override + public void onSuccess(String name) + { + Player player = Bukkit.getPlayerExact(_party.getOwner()); + _party.sendMessage(C.mHead + "Party> " + F.name(player.getName()) + " has suggested " + F.name(name) + " be invited."); + ChildJsonMessage message = new ChildJsonMessage("").extra(F.main("Party", "Type or click ")); + message.add(F.link("/party invite " + name)) + .hover(HoverEvent.SHOW_TEXT, C.cGreen + "Clicking this will invite " + C.cYellow + name + C.cGreen + " to the party") + .click(ClickEvent.RUN_COMMAND, "/party invite " + name); + message.add(C.mBody + " to invite them"); + message.sendToPlayer(player); + } + + @Override + public void onFail(String name) + { + + } +}