From cf515036f7da04c195c77a3c736f8707a32e7b0e Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 5 Jan 2018 22:48:39 -0500 Subject: [PATCH] Add the ability for support to reset ranks to default --- .../ui/rank/SupportRankListPage.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/rank/SupportRankListPage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/rank/SupportRankListPage.java index e3fe30ccc..c293b5cf9 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/rank/SupportRankListPage.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/rank/SupportRankListPage.java @@ -28,7 +28,7 @@ import mineplex.staffServer.ui.SupportShop; public class SupportRankListPage extends SupportPage { - private static int _rowOffset = 2; + private static int _rowOffset = 1; private Map>> _rankBonusItems; @@ -63,9 +63,14 @@ public class SupportRankListPage extends SupportPage buildPage(); } + private ItemStack getIconItem(PermissionGroup group, String[] lore) + { + return new ShopItem(Material.WOOL, UtilColor.chatColorToWoolData(group.getColor()), group.getDisplay(true, true, true, true).toUpperCase(), lore, 1, true, true); + } + private ItemStack getIconItem(PermissionGroup group) { - return new ShopItem(Material.WOOL, UtilColor.chatColorToWoolData(group.getColor()), group.getDisplay(true, true, true, true).toUpperCase(), new String[0], 1, true, true); + return getIconItem(group, new String[0]); } private ItemStack getApplyItem(PermissionGroup group) @@ -94,16 +99,20 @@ public class SupportRankListPage extends SupportPage return builder.build(); } + private void handleGroupSet(PermissionGroup group) + { + getPlugin().getClientManager().setPrimaryGroup(_target.getAccountId(), group, () -> { + message("You have applied the rank " + group.getDisplay(true, true, true, true).toUpperCase() + C.mBody + " to " + C.cYellow + _target.getName()); + _target.setPrimaryGroup(group); + refresh(); + }); + } + private void addRank(int column, PermissionGroup group) { addItem(getSlotIndex(_rowOffset, column), getIconItem(group)); - addButton(getSlotIndex(_rowOffset + 1, column), getApplyItem(group), (p, c) -> - getPlugin().getClientManager().setPrimaryGroup(_target.getAccountId(), group, () -> { - message("You have applied the rank " + group.getDisplay(true, true, true, true).toUpperCase() + C.mBody + " to " + C.cYellow + _target.getName()); - _target.setPrimaryGroup(group); - refresh(); - })); + addButton(getSlotIndex(_rowOffset + 1, column), getApplyItem(group), (p, c) -> handleGroupSet(group)); addButton(getSlotIndex(_rowOffset + 2, column), getBonusItem(group), (p, c) -> { @@ -138,5 +147,11 @@ public class SupportRankListPage extends SupportPage col += 2; } + + addButton(getSlotIndex(5, 4), getIconItem(PermissionGroup.PLAYER, new String[] { + C.mBody + "Click to reset", + C.mBody + "the player's rank", + C.mBody + "to default." + }), (p, c) -> handleGroupSet(PermissionGroup.PLAYER)); } }