diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java index f2fbd5714..f10aba701 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java @@ -28,9 +28,14 @@ public class Currency return _plural; } + public String getString(int amount, boolean color) + { + return (color ? _color : "") + amount + " " + (amount == 1 ? _singular : _plural); + } + public String getString(int amount) { - return _color + amount + " " + (amount == 1 ? _singular : _plural); + return getString(amount, true); } public String getColor() diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportCurrencyPage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportCurrencyPage.java new file mode 100644 index 000000000..7592a2f95 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportCurrencyPage.java @@ -0,0 +1,60 @@ +package mineplex.staffServer.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClient; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.shop.item.ShopItem; +import mineplex.staffServer.customerSupport.CustomerSupport; + +public class SupportCurrencyPage extends SupportPage +{ + private static final int[] CURRENCY_DEMONINATIONS = new int[] { 5000, 15000, 25000, 75000 }; + + public SupportCurrencyPage(CustomerSupport plugin, SupportShop shop, Player player, CoreClient target, SupportPage previousPage) + { + super(plugin, shop, player, target, previousPage, "Currency"); + + buildPage(); + } + + private void buildCurrency(GlobalCurrency currency, int rowOffset) + { + int slot = getSlotIndex(rowOffset, 1); + + for (int i = 0; i < 4; i++) + { + int amount = CURRENCY_DEMONINATIONS[i]; + + addButton(slot, + new ShopItem(currency.getDisplayMaterial(), currency.getColor() + C.Bold + currency.getString(amount, false), new String[] {C.mBody + "Click to award", currency.getString(amount) }, 1, false, true), + (p, c) -> getPlugin().getDonationManager().rewardCurrency(currency, _target, "Support - " + getPlayer().getName(), amount, true, (success) -> { + if (success) + { + playSuccess(); + message("You awarded " + currency.getString(amount) + C.mBody + " to " + C.cYellow + _target.getName()); + + // Update their counts in the player skull + refresh(); + } + else + { + playFail(); + message("Unable to award currency at this time. Please try again later."); + } + })); + + slot += 2; + } + } + + @Override + protected void buildPage() + { + super.buildPage(); + + buildCurrency(GlobalCurrency.GEM, 2); + buildCurrency(GlobalCurrency.TREASURE_SHARD, 4); + } +}