add giveUnkownSalesPackage method to SupportPage
This commit is contained in:
parent
3ca0adfeda
commit
468930a35e
@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilText;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.donation.Donor;
|
import mineplex.core.donation.Donor;
|
||||||
import mineplex.core.donation.repository.token.TransactionToken;
|
import mineplex.core.donation.repository.token.TransactionToken;
|
||||||
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.staffServer.customerSupport.CustomerSupport;
|
import mineplex.staffServer.customerSupport.CustomerSupport;
|
||||||
@ -156,6 +157,62 @@ public class SupportPage extends ShopPageBase<CustomerSupport, SupportShop>
|
|||||||
_player.sendMessage(F.main(getPlugin().getName(), message));
|
_player.sendMessage(F.main(getPlugin().getName(), message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void giveSuccess(int amount, String itemName)
|
||||||
|
{
|
||||||
|
message("Gave " + C.cYellow + amount + " " + itemName + C.mBody + " to " + C.cYellow + _target.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void giveFailed(int amount, String itemName)
|
||||||
|
{
|
||||||
|
message("Unable to give " + C.cYellow + amount + " " + itemName + C.mBody + " to " + C.cYellow + _target.getName() + C.mBody + ", please try again later.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void giveUnknownSalesPackage(int amount, String itemName, boolean isItem)
|
||||||
|
{
|
||||||
|
getPlugin().getDonationManager().purchaseUnknownSalesPackage(_target, (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false, response ->
|
||||||
|
{
|
||||||
|
if (response == TransactionResponse.Failed || response == TransactionResponse.InsufficientFunds)
|
||||||
|
{
|
||||||
|
giveFailed(amount, itemName);
|
||||||
|
}
|
||||||
|
else if (response == TransactionResponse.Success)
|
||||||
|
{
|
||||||
|
if (isItem)
|
||||||
|
{
|
||||||
|
getPlugin().getInventoryManager().addItemToInventoryForOffline(success ->
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
giveSuccess(amount, itemName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
giveFailed(amount, itemName);
|
||||||
|
}
|
||||||
|
}, _target.getAccountId(), itemName, amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
giveSuccess(amount, itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (response == TransactionResponse.AlreadyOwns)
|
||||||
|
{
|
||||||
|
message(C.cYellow + _target.getName() + C.mBody + " already owns " + C.cYellow + itemName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void giveUnknownSalesPackage(String itemName, boolean isItem)
|
||||||
|
{
|
||||||
|
giveUnknownSalesPackage(1, itemName, isItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void giveUnknownSalesPackage(String itemName)
|
||||||
|
{
|
||||||
|
giveUnknownSalesPackage(itemName, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user