Party UI work.
This commit is contained in:
parent
a49e815765
commit
b75e87753d
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,16 +22,16 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
{
|
||||
|
||||
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 <player> - Invite a player to your party." + C.cRed + " Must be the owner.",
|
||||
C.cGray + "/party accept <party> - Accept an invite to a player's party.",
|
||||
C.cGray + "/party deny <party> - Deny an invite to a player's party.",
|
||||
C.cGray + "/party leave - Leave your current party.",
|
||||
C.cGray + "/party kick/remove <player> - 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 <player>", "Invite a player to your party." + C.cRed + " Must be the leader."),
|
||||
help("accept <party>", "Accept an invite to a player's party."),
|
||||
help("deny <party>", "Deny an invite to a player's party."),
|
||||
help("leave", "Leave your current party"),
|
||||
help("kick/remove <player>", "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 + "#<message> " + C.cGray + "- Send a message to the players in your party."
|
||||
};
|
||||
|
||||
public PartyCommand(PartyManager plugin)
|
||||
@ -56,7 +56,6 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
return;
|
||||
}
|
||||
new PartyViewMenu(party, Plugin).open(caller);
|
||||
//Show UI
|
||||
return;
|
||||
}
|
||||
String argument = args[0];
|
||||
@ -210,5 +209,10 @@ public class PartyCommand extends CommandBase<PartyManager>
|
||||
Plugin.removeParty(party);
|
||||
}
|
||||
|
||||
private String help(String command, String description)
|
||||
{
|
||||
return C.cBlue + "Party> " + C.cWhite + "/party " + command + C.cGray + " - " + description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.invite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class BackButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.invite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DenyAllButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.invite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FilterButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.invite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class InviteButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.invite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NextPageButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.invite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PrevPageButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.main;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class InvitePlayerButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.main;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ViewInvitesButton
|
||||
{
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.owner;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DisbandPartyButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.owner;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class KickPlayerButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.owner;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SelectServerButton
|
||||
{
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.party.ui.button.tools.owner;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TransferOwnerButton
|
||||
{
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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];
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user