From f470071ca0a1e354117c9baacf3c971381633781 Mon Sep 17 00:00:00 2001 From: ArcticZeroo Date: Sun, 7 Jan 2018 13:47:48 -0500 Subject: [PATCH] Update item count when giving items to players in GiveItemPage --- .../src/mineplex/staffServer/ui/SupportPage.java | 9 ++++++++- .../staffServer/ui/item/SupportGiveItemPage.java | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportPage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportPage.java index c2820f5cf..07cc1c914 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportPage.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/SupportPage.java @@ -165,6 +165,11 @@ public class SupportPage extends ShopPageBase message("Unable to give " + C.cYellow + amount + " " + itemName + C.mBody + " to " + C.cYellow + _target.getName() + C.mBody + ", please try again later."); } + private void addItemsToClient(int amount, String itemName) + { + getPlugin().getInventoryManager().Get(_target.getUniqueId()).getClientItem(itemName).Count += amount; + } + protected void giveUnknownSalesPackage(int amount, String itemName, boolean isItem, Consumercallback) { getPlugin().getDonationManager().purchaseUnknownSalesPackage(_target, (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false, response -> @@ -172,7 +177,7 @@ public class SupportPage extends ShopPageBase if (response == TransactionResponse.Failed || response == TransactionResponse.InsufficientFunds) { giveFailed(amount, itemName); - callback.accept(true); + callback.accept(false); } else if (response == TransactionResponse.Success) { @@ -183,6 +188,7 @@ public class SupportPage extends ShopPageBase if (success) { giveSuccess(amount, itemName); + addItemsToClient(amount, itemName); callback.accept(true); } else @@ -195,6 +201,7 @@ public class SupportPage extends ShopPageBase else { giveSuccess(amount, itemName); + addItemsToClient(amount, itemName); callback.accept(true); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/item/SupportGiveItemPage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/item/SupportGiveItemPage.java index d8642ee56..933f488a9 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/item/SupportGiveItemPage.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/item/SupportGiveItemPage.java @@ -75,7 +75,11 @@ public abstract class SupportGiveItemPage extends SupportPage protected void addSubmitButton() { addButton(_submitButtonSlot, new ShopItem(_count > 0 ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK, "Give " + getItemName(), new String[0], 1, false, true), (p, c) -> { - giveUnknownSalesPackage(_count, getItemName(), true, (success) -> goBack()); + giveUnknownSalesPackage(_count, getItemName(), true, (success) -> + { + _previousPage.refresh(); + goBack(); + }); }); }