Add the ability for support to reset ranks to default

This commit is contained in:
Spencer 2018-01-05 22:48:39 -05:00 committed by Alexander Meech
parent 17a11a63b6
commit cf515036f7

View File

@ -28,7 +28,7 @@ import mineplex.staffServer.ui.SupportShop;
public class SupportRankListPage extends SupportPage public class SupportRankListPage extends SupportPage
{ {
private static int _rowOffset = 2; private static int _rowOffset = 1;
private Map<PermissionGroup, List<Pair<TreasureType, Integer>>> _rankBonusItems; private Map<PermissionGroup, List<Pair<TreasureType, Integer>>> _rankBonusItems;
@ -63,9 +63,14 @@ public class SupportRankListPage extends SupportPage
buildPage(); 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) 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) private ItemStack getApplyItem(PermissionGroup group)
@ -94,16 +99,20 @@ public class SupportRankListPage extends SupportPage
return builder.build(); return builder.build();
} }
private void addRank(int column, PermissionGroup group) private void handleGroupSet(PermissionGroup group)
{ {
addItem(getSlotIndex(_rowOffset, column), getIconItem(group));
addButton(getSlotIndex(_rowOffset + 1, column), getApplyItem(group), (p, c) ->
getPlugin().getClientManager().setPrimaryGroup(_target.getAccountId(), 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()); message("You have applied the rank " + group.getDisplay(true, true, true, true).toUpperCase() + C.mBody + " to " + C.cYellow + _target.getName());
_target.setPrimaryGroup(group); _target.setPrimaryGroup(group);
refresh(); refresh();
})); });
}
private void addRank(int column, PermissionGroup group)
{
addItem(getSlotIndex(_rowOffset, column), getIconItem(group));
addButton(getSlotIndex(_rowOffset + 1, column), getApplyItem(group), (p, c) -> handleGroupSet(group));
addButton(getSlotIndex(_rowOffset + 2, column), getBonusItem(group), (p, c) -> addButton(getSlotIndex(_rowOffset + 2, column), getBonusItem(group), (p, c) ->
{ {
@ -138,5 +147,11 @@ public class SupportRankListPage extends SupportPage
col += 2; 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));
} }
} }