Update item count when giving items to players in GiveItemPage
This commit is contained in:
parent
b1f6e5c06c
commit
f470071ca0
@ -165,6 +165,11 @@ public class SupportPage extends ShopPageBase<CustomerSupport, SupportShop>
|
|||||||
message("Unable to give " + C.cYellow + amount + " " + itemName + C.mBody + " to " + C.cYellow + _target.getName() + C.mBody + ", please try again later.");
|
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, Consumer<Boolean>callback)
|
protected void giveUnknownSalesPackage(int amount, String itemName, boolean isItem, Consumer<Boolean>callback)
|
||||||
{
|
{
|
||||||
getPlugin().getDonationManager().purchaseUnknownSalesPackage(_target, (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false, response ->
|
getPlugin().getDonationManager().purchaseUnknownSalesPackage(_target, (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false, response ->
|
||||||
@ -172,7 +177,7 @@ public class SupportPage extends ShopPageBase<CustomerSupport, SupportShop>
|
|||||||
if (response == TransactionResponse.Failed || response == TransactionResponse.InsufficientFunds)
|
if (response == TransactionResponse.Failed || response == TransactionResponse.InsufficientFunds)
|
||||||
{
|
{
|
||||||
giveFailed(amount, itemName);
|
giveFailed(amount, itemName);
|
||||||
callback.accept(true);
|
callback.accept(false);
|
||||||
}
|
}
|
||||||
else if (response == TransactionResponse.Success)
|
else if (response == TransactionResponse.Success)
|
||||||
{
|
{
|
||||||
@ -183,6 +188,7 @@ public class SupportPage extends ShopPageBase<CustomerSupport, SupportShop>
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
giveSuccess(amount, itemName);
|
giveSuccess(amount, itemName);
|
||||||
|
addItemsToClient(amount, itemName);
|
||||||
callback.accept(true);
|
callback.accept(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -195,6 +201,7 @@ public class SupportPage extends ShopPageBase<CustomerSupport, SupportShop>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
giveSuccess(amount, itemName);
|
giveSuccess(amount, itemName);
|
||||||
|
addItemsToClient(amount, itemName);
|
||||||
callback.accept(true);
|
callback.accept(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,11 @@ public abstract class SupportGiveItemPage extends SupportPage
|
|||||||
protected void addSubmitButton()
|
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) -> {
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user