Refactor out legacy ConfirmationPage
This commit is contained in:
parent
3d0cc2a5fd
commit
3cddf35d12
@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
||||||
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -21,6 +22,9 @@ public class BoosterProcessor implements ConfirmationProcessor
|
|||||||
_player = player;
|
_player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Inventory inventory) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(ConfirmationCallback callback)
|
public void process(ConfirmationCallback callback)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,6 @@ import mineplex.core.account.CoreClientManager;
|
|||||||
import mineplex.core.boosters.Booster;
|
import mineplex.core.boosters.Booster;
|
||||||
import mineplex.core.boosters.BoosterManager;
|
import mineplex.core.boosters.BoosterManager;
|
||||||
import mineplex.core.boosters.BoosterProcessor;
|
import mineplex.core.boosters.BoosterProcessor;
|
||||||
import mineplex.core.common.Pair;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
@ -115,8 +114,7 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
|
|||||||
ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false);
|
ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false);
|
||||||
|
|
||||||
BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer());
|
BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer());
|
||||||
ConfirmationPage<BoosterManager, BoosterShop> page = new ConfirmationPage<>(getPlugin(), getShop(),
|
ConfirmationPage<BoosterManager, BoosterShop> page = new ConfirmationPage<>(getPlayer(), this, processor, booster);
|
||||||
getClientManager(), getDonationManager(), getPlayer(), this, processor, booster);
|
|
||||||
getShop().openPageForPlayer(getPlayer(), page);
|
getShop().openPageForPlayer(getPlayer(), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package mineplex.core.brawl.fountain.gui.button;
|
package mineplex.core.brawl.fountain.gui.button;
|
||||||
|
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
|
||||||
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
|
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
|
||||||
import mineplex.core.brawl.fountain.gui.FountainPage;
|
import mineplex.core.brawl.fountain.gui.FountainPage;
|
||||||
import mineplex.core.brawl.fountain.gui.FountainShop;
|
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
@ -30,13 +29,10 @@ public class FountainAddButton implements IButton
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<FountainManager, FountainShop>(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, _salesPackage, _page.getDonationManager(), () ->
|
||||||
{
|
{
|
||||||
public void run()
|
_page.getPlugin().getGemFountain().increment(player, _gems, null);
|
||||||
{
|
_page.refresh();
|
||||||
_page.getPlugin().getGemFountain().increment(player, _gems, null);
|
}), _salesPackage.buildIcon()));
|
||||||
_page.refresh();
|
|
||||||
}
|
|
||||||
}, _page, _salesPackage, GlobalCurrency.GEM, player));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
|
||||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
|
||||||
import mineplex.core.cosmetic.ui.page.MountPage;
|
import mineplex.core.cosmetic.ui.page.MountPage;
|
||||||
import mineplex.core.mount.Mount;
|
import mineplex.core.mount.Mount;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
@ -24,13 +23,10 @@ public class MountButton implements IButton
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(final Player player, ClickType clickType)
|
public void onClick(final Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, _mount, _page.getDonationManager(), () ->
|
||||||
{
|
{
|
||||||
public void run()
|
_page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1);
|
||||||
{
|
_page.refresh();
|
||||||
_page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1);
|
}), _mount.buildIcon()));
|
||||||
_page.refresh();
|
|
||||||
}
|
|
||||||
}, _page, _mount, GlobalCurrency.TREASURE_SHARD, player));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,10 @@ import mineplex.core.gadget.types.Gadget;
|
|||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.gadget.types.HatGadget;
|
import mineplex.core.gadget.types.HatGadget;
|
||||||
import mineplex.core.gadget.types.ItemGadget;
|
import mineplex.core.gadget.types.ItemGadget;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -371,14 +372,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, gadget, getDonationManager(), () ->
|
||||||
{
|
{
|
||||||
public void run()
|
getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity()));
|
||||||
{
|
refresh();
|
||||||
getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity()));
|
}), gadget.buildIcon()));
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
}, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), GlobalCurrency.TREASURE_SHARD, getPlayer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activateGadget(Player player, Gadget gadget)
|
public void activateGadget(Player player, Gadget gadget)
|
||||||
|
@ -15,7 +15,9 @@ import mineplex.core.pet.Pet;
|
|||||||
import mineplex.core.pet.PetExtra;
|
import mineplex.core.pet.PetExtra;
|
||||||
import mineplex.core.pet.repository.token.PetChangeToken;
|
import mineplex.core.pet.repository.token.PetChangeToken;
|
||||||
import mineplex.core.pet.repository.token.PetToken;
|
import mineplex.core.pet.repository.token.PetToken;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_8_R3.Items;
|
import net.minecraft.server.v1_8_R3.Items;
|
||||||
@ -92,44 +94,42 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
}
|
}
|
||||||
|
|
||||||
PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100);
|
PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100);
|
||||||
|
final SalesPackageBase salesPackage = _petPurchase ? _pet : tag;
|
||||||
|
|
||||||
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
|
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
|
||||||
|
|
||||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () ->
|
||||||
{
|
{
|
||||||
public void run()
|
PetChangeToken token = new PetChangeToken();
|
||||||
|
|
||||||
|
if (getClientManager().Get(getPlayer()) != null)
|
||||||
|
token.AccountId = getClientManager().Get(getPlayer()).getAccountId();
|
||||||
|
else
|
||||||
|
token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId();
|
||||||
|
|
||||||
|
token.Name = getPlayer().getName();
|
||||||
|
token.PetType = _pet.getPetType().toString();
|
||||||
|
token.PetId = _pet.getPetType().ordinal();
|
||||||
|
token.PetName = _tagName;
|
||||||
|
|
||||||
|
PetToken petToken = new PetToken();
|
||||||
|
petToken.PetType = token.PetType;
|
||||||
|
|
||||||
|
if (_petPurchase)
|
||||||
{
|
{
|
||||||
PetChangeToken token = new PetChangeToken();
|
getPlugin().getPetManager().getRepository().AddPet(token);
|
||||||
|
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType());
|
||||||
if (getClientManager().Get(getPlayer()) != null)
|
|
||||||
token.AccountId = getClientManager().Get(getPlayer()).getAccountId();
|
|
||||||
else
|
|
||||||
token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId();
|
|
||||||
|
|
||||||
token.Name = getPlayer().getName();
|
|
||||||
token.PetType = _pet.getPetType().toString();
|
|
||||||
token.PetId = _pet.getPetType().ordinal();
|
|
||||||
token.PetName = _tagName;
|
|
||||||
|
|
||||||
PetToken petToken = new PetToken();
|
|
||||||
petToken.PetType = token.PetType;
|
|
||||||
|
|
||||||
if (_petPurchase)
|
|
||||||
{
|
|
||||||
getPlugin().getPetManager().getRepository().AddPet(token);
|
|
||||||
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getPlugin().getPetManager().getRepository().UpdatePet(token);
|
|
||||||
getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName);
|
|
||||||
|
|
||||||
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
|
|
||||||
}
|
}
|
||||||
}, null, _petPurchase ? _pet : tag, GlobalCurrency.TREASURE_SHARD, getPlayer()));
|
else
|
||||||
|
{
|
||||||
|
getPlugin().getPetManager().getRepository().UpdatePet(token);
|
||||||
|
getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName);
|
||||||
|
|
||||||
|
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
|
||||||
|
}), salesPackage.buildIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTagName(String tagName)
|
public void SetTagName(String tagName)
|
||||||
|
@ -112,6 +112,28 @@ public class DonationManager extends MiniClientPlugin<Donor>
|
|||||||
}, name, accountId, packageName, currencyType, cost);
|
}, name, accountId, packageName, currencyType, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, final String name, final UUID uuid, final int cost, final int salesPackageId)
|
||||||
|
{
|
||||||
|
_repository.PurchaseKnownSalesPackage(new Callback<TransactionResponse>()
|
||||||
|
{
|
||||||
|
public void run(TransactionResponse response)
|
||||||
|
{
|
||||||
|
if (response == TransactionResponse.Success)
|
||||||
|
{
|
||||||
|
Donor donor = Get(name);
|
||||||
|
|
||||||
|
if (donor != null)
|
||||||
|
{
|
||||||
|
donor.AddSalesPackagesOwned(salesPackageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback != null)
|
||||||
|
callback.run(response);
|
||||||
|
}
|
||||||
|
}, name, uuid.toString(), cost, salesPackageId);
|
||||||
|
}
|
||||||
|
|
||||||
public void RewardGems(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
|
public void RewardGems(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
|
||||||
{
|
{
|
||||||
RewardGems(callback, caller, name, uuid, amount, true);
|
RewardGems(callback, caller, name, uuid, amount, true);
|
||||||
|
@ -31,11 +31,21 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
|||||||
private ConfirmationProcessor _processor;
|
private ConfirmationProcessor _processor;
|
||||||
private boolean _processing;
|
private boolean _processing;
|
||||||
|
|
||||||
public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ShopPageBase<PluginType, ShopType> returnPage, ConfirmationProcessor processor, ItemStack displayItem)
|
public ConfirmationPage(Player player, ShopPageBase<PluginType, ShopType> returnPage, ConfirmationProcessor processor, ItemStack displayItem)
|
||||||
|
{
|
||||||
|
super(returnPage.getPlugin(), returnPage.getShop(), returnPage.getClientManager(), returnPage.getDonationManager(), "Confirmation", player);
|
||||||
|
|
||||||
|
_returnPage = returnPage;
|
||||||
|
_displayItem = displayItem;
|
||||||
|
_processor = processor;
|
||||||
|
|
||||||
|
buildPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfirmationPage(Player player, PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, ConfirmationProcessor processor, ItemStack displayItem)
|
||||||
{
|
{
|
||||||
super(plugin, shop, clientManager, donationManager, "Confirmation", player);
|
super(plugin, shop, clientManager, donationManager, "Confirmation", player);
|
||||||
|
|
||||||
_returnPage = returnPage;
|
|
||||||
_displayItem = displayItem;
|
_displayItem = displayItem;
|
||||||
_processor = processor;
|
_processor = processor;
|
||||||
|
|
||||||
@ -49,6 +59,8 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
|||||||
|
|
||||||
buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), this::okClicked);
|
buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), this::okClicked);
|
||||||
buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), this::cancelClicked);
|
buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), this::cancelClicked);
|
||||||
|
|
||||||
|
_processor.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void okClicked(Player player, ClickType clickType)
|
protected void okClicked(Player player, ClickType clickType)
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package mineplex.core.shop.confirmation;
|
package mineplex.core.shop.confirmation;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
*/
|
*/
|
||||||
public interface ConfirmationProcessor
|
public interface ConfirmationProcessor
|
||||||
{
|
{
|
||||||
|
public void init(Inventory inventory);
|
||||||
public void process(ConfirmationCallback callback);
|
public void process(ConfirmationCallback callback);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package mineplex.core.shop.item;
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
import mineplex.core.common.currency.Currency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.donation.repository.GameSalesPackageToken;
|
import mineplex.core.donation.repository.GameSalesPackageToken;
|
||||||
|
|
||||||
public interface ICurrencyPackage
|
public interface ICurrencyPackage
|
||||||
{
|
{
|
||||||
int getSalesPackageId();
|
int getSalesPackageId();
|
||||||
int getCost(Currency currencytype);
|
int getCost(GlobalCurrency currencytype);
|
||||||
boolean isFree();
|
boolean isFree();
|
||||||
void update(GameSalesPackageToken token);
|
void update(GameSalesPackageToken token);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package mineplex.core.shop.item;
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
|
|
||||||
import mineplex.core.common.currency.Currency;
|
|
||||||
import mineplex.core.common.currency.GlobalCurrency;
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.donation.repository.GameSalesPackageToken;
|
import mineplex.core.donation.repository.GameSalesPackageToken;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPackage
|
public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPackage
|
||||||
{
|
{
|
||||||
@ -19,7 +20,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
|||||||
|
|
||||||
protected int SalesPackageId;
|
protected int SalesPackageId;
|
||||||
protected boolean Free;
|
protected boolean Free;
|
||||||
protected NautHashMap<Currency, Integer> CurrencyCostMap;
|
protected NautHashMap<GlobalCurrency, Integer> CurrencyCostMap;
|
||||||
protected boolean KnownPackage = true;
|
protected boolean KnownPackage = true;
|
||||||
protected boolean OneTimePurchaseOnly = true;
|
protected boolean OneTimePurchaseOnly = true;
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCost(Currency currencyType)
|
public int getCost(GlobalCurrency currencyType)
|
||||||
{
|
{
|
||||||
return CurrencyCostMap.containsKey(currencyType) ? CurrencyCostMap.get(currencyType) : 0;
|
return CurrencyCostMap.containsKey(currencyType) ? CurrencyCostMap.get(currencyType) : 0;
|
||||||
}
|
}
|
||||||
@ -130,4 +131,9 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
|||||||
{
|
{
|
||||||
DisplayName = name;
|
DisplayName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack buildIcon()
|
||||||
|
{
|
||||||
|
return new ItemBuilder(_displayMaterial).setData(_displayData).setTitle(DisplayName).addLore(Description).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
package mineplex.core.shop.item;
|
||||||
|
|
||||||
|
import mineplex.core.common.currency.GlobalCurrency;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
public class SalesPackageProcessor implements ConfirmationProcessor {
|
||||||
|
/*
|
||||||
|
int goldCount = _donationManager.Get(_player).getGold();
|
||||||
|
int cost = _salesItem.getCost(_currencyType);
|
||||||
|
|
||||||
|
if (cost > goldCount)
|
||||||
|
showResultsPage(TransactionResponse.InsufficientFunds);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_donationManager.rewardGold(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run(Boolean data)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
showResultsPage(TransactionResponse.Success);
|
||||||
|
_player.playSound(_player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showResultsPage(TransactionResponse.Failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "Energy Purchase", _player.getName(), getClientManager().Get(_player).getAccountId(), -cost);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
private final GlobalCurrency _currencyType;
|
||||||
|
private final SalesPackageBase _salesItem;
|
||||||
|
private final DonationManager _donationManager;
|
||||||
|
private final Player _player;
|
||||||
|
private final Runnable _runAfterPurchase;
|
||||||
|
|
||||||
|
public SalesPackageProcessor(Player player, GlobalCurrency currencyType, SalesPackageBase salesItem, DonationManager donationManager, Runnable runAfterPurchase)
|
||||||
|
{
|
||||||
|
_currencyType = currencyType;
|
||||||
|
_salesItem = salesItem;
|
||||||
|
_donationManager = donationManager;
|
||||||
|
_player = player;
|
||||||
|
_runAfterPurchase = runAfterPurchase;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Inventory inventory)
|
||||||
|
{
|
||||||
|
inventory.setItem(4, new ItemBuilder(_currencyType.getDisplayMaterial()).setTitle(_currencyType.getPrefix()).addLore(C.cGray + _salesItem.getCost(_currencyType) + " " + _currencyType.getPrefix() + " will be", C.cGray + "deducted from your account balance").build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ConfirmationCallback callback)
|
||||||
|
{
|
||||||
|
if (_salesItem.isKnown())
|
||||||
|
{
|
||||||
|
_donationManager.PurchaseKnownSalesPackage(response -> showResults(callback, response), _player.getName(), _player.getUniqueId(), _salesItem.getCost(_currencyType), _salesItem.getSalesPackageId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_donationManager.PurchaseUnknownSalesPackage(response -> showResults(callback, response), _player.getName(), _donationManager.getClientManager().Get(_player).getAccountId(), _salesItem.getName(), _currencyType, _salesItem.getCost(_currencyType), _salesItem.oneTimePurchase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showResults(ConfirmationCallback callback, TransactionResponse response)
|
||||||
|
{
|
||||||
|
switch (response)
|
||||||
|
{
|
||||||
|
case Failed:
|
||||||
|
callback.reject("There was an error processing your request.");
|
||||||
|
break;
|
||||||
|
case AlreadyOwns:
|
||||||
|
callback.reject("You already own this package.");
|
||||||
|
break;
|
||||||
|
case InsufficientFunds:
|
||||||
|
callback.reject("Your account has insufficient funds.");
|
||||||
|
break;
|
||||||
|
case Success:
|
||||||
|
callback.resolve("Your purchase was successful.");
|
||||||
|
|
||||||
|
if (_runAfterPurchase != null)
|
||||||
|
_runAfterPurchase.run();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,324 +0,0 @@
|
|||||||
package mineplex.core.shop.page;
|
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.currency.Currency;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.server.util.TransactionResponse;
|
|
||||||
import mineplex.core.shop.ShopBase;
|
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
|
||||||
import mineplex.core.shop.item.ShopItem;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
|
|
||||||
public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends ShopPageBase<PluginType, ShopType> implements Runnable
|
|
||||||
{
|
|
||||||
private Runnable _runnable;
|
|
||||||
private ShopPageBase<PluginType, ShopType> _returnPage;
|
|
||||||
private SalesPackageBase _salesItem;
|
|
||||||
private int _okSquareSlotStart;
|
|
||||||
private boolean _processing;
|
|
||||||
private int _progressCount;
|
|
||||||
private ShopItem _progressItem;
|
|
||||||
private int _taskId;
|
|
||||||
private final Currency _currencyType;
|
|
||||||
|
|
||||||
public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Runnable runnable, ShopPageBase<PluginType, ShopType> returnPage, SalesPackageBase salesItem, Currency currencyType, Player player)
|
|
||||||
{
|
|
||||||
super(plugin, shop, clientManager, donationManager, " Confirmation", player);
|
|
||||||
|
|
||||||
_runnable = runnable;
|
|
||||||
_returnPage = returnPage;
|
|
||||||
_salesItem = salesItem;
|
|
||||||
_progressItem = new ShopItem(Material.LAPIS_BLOCK, (byte)11, ChatColor.BLUE + "Processing", null, 1, false, true);
|
|
||||||
_okSquareSlotStart = 27;
|
|
||||||
_currencyType = currencyType;
|
|
||||||
|
|
||||||
if (getShop().canPlayerAttemptPurchase(player))
|
|
||||||
{
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buildErrorPage(new String[]{ChatColor.RED + "You have attempted too many invalid transactions.", ChatColor.RED + "Please wait 10 seconds before retrying."});
|
|
||||||
_taskId = plugin.getScheduler().scheduleSyncRepeatingTask(plugin.getPlugin(), this, 2L, 2L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void buildPage()
|
|
||||||
{
|
|
||||||
this.getInventory().setItem(22, new ShopItem(_salesItem.getDisplayMaterial(), (byte)0, _salesItem.getDisplayName(), _salesItem.getDescription(), 1, false, true).getHandle());
|
|
||||||
|
|
||||||
IButton okClicked = new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
okClicked(player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
IButton cancelClicked = new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
cancelClicked(player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), okClicked);
|
|
||||||
buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), cancelClicked);
|
|
||||||
|
|
||||||
this.getInventory().setItem(4, new ShopItem(_currencyType.getDisplayMaterial(), (byte)0, _currencyType.getPrefix(), new String[] { C.cGray + _salesItem.getCost(_currencyType) + " " + _currencyType.getPrefix() + " will be", C.cGray + "deducted from your account balance." }, 1, false, true).getHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void okClicked(Player player)
|
|
||||||
{
|
|
||||||
processTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void cancelClicked(Player player)
|
|
||||||
{
|
|
||||||
getPlugin().getScheduler().cancelTask(_taskId);
|
|
||||||
|
|
||||||
if (_returnPage != null)
|
|
||||||
getShop().openPageForPlayer(player, _returnPage);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSquareAt(int slot, ShopItem item, IButton button)
|
|
||||||
{
|
|
||||||
addButton(slot, item, button);
|
|
||||||
addButton(slot + 1, item, button);
|
|
||||||
addButton(slot + 2, item, button);
|
|
||||||
|
|
||||||
slot += 9;
|
|
||||||
|
|
||||||
addButton(slot, item, button);
|
|
||||||
addButton(slot + 1, item, button);
|
|
||||||
addButton(slot + 2, item, button);
|
|
||||||
|
|
||||||
slot += 9;
|
|
||||||
|
|
||||||
addButton(slot, item, button);
|
|
||||||
addButton(slot + 1, item, button);
|
|
||||||
addButton(slot + 2, item, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processTransaction()
|
|
||||||
{
|
|
||||||
for (int i=_okSquareSlotStart; i < 54; i++)
|
|
||||||
{
|
|
||||||
getButtonMap().remove(i);
|
|
||||||
clear(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*_processing = true;
|
|
||||||
|
|
||||||
if (_currencyType == GlobalCurrency.GOLD)
|
|
||||||
{
|
|
||||||
int goldCount = getDonationManager().Get(getPlayer()).getGold();
|
|
||||||
int cost = _salesItem.getCost(_currencyType);
|
|
||||||
|
|
||||||
if (cost > goldCount)
|
|
||||||
showResultsPage(TransactionResponse.InsufficientFunds);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getDonationManager().rewardGold(new Callback<Boolean>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run(Boolean data)
|
|
||||||
{
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
showResultsPage(TransactionResponse.Success);
|
|
||||||
getPlayer().playSound(getPlayer().getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
showResultsPage(TransactionResponse.Failed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "Energy Purchase", getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), -cost);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_salesItem.isKnown())
|
|
||||||
{
|
|
||||||
getDonationManager().PurchaseKnownSalesPackage(new Callback<TransactionResponse>()
|
|
||||||
{
|
|
||||||
public void run(TransactionResponse response)
|
|
||||||
{
|
|
||||||
showResultsPage(response);
|
|
||||||
}
|
|
||||||
}, getPlayer().getName(), getPlayer().getUniqueId(), _salesItem.getCost(_currencyType), _salesItem.getSalesPackageId());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getDonationManager().PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
|
||||||
{
|
|
||||||
public void run(TransactionResponse response)
|
|
||||||
{
|
|
||||||
showResultsPage(response);
|
|
||||||
}
|
|
||||||
}, getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), _salesItem.getName(), _currencyType, _salesItem.getCost(_currencyType), _salesItem.oneTimePurchase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_taskId = getPlugin().getScheduler().scheduleSyncRepeatingTask(getPlugin().getPlugin(), this, 2L, 2L);*/
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showResultsPage(TransactionResponse response)
|
|
||||||
{
|
|
||||||
_processing = false;
|
|
||||||
|
|
||||||
switch (response)
|
|
||||||
{
|
|
||||||
case Failed:
|
|
||||||
buildErrorPage(ChatColor.RED + "There was an error processing your request.");
|
|
||||||
getShop().addPlayerProcessError(getPlayer());
|
|
||||||
break;
|
|
||||||
case AlreadyOwns:
|
|
||||||
buildErrorPage(ChatColor.RED + "You already own this package.");
|
|
||||||
getShop().addPlayerProcessError(getPlayer());
|
|
||||||
break;
|
|
||||||
case InsufficientFunds:
|
|
||||||
buildErrorPage(ChatColor.RED + "Your account has insufficient funds.");
|
|
||||||
getShop().addPlayerProcessError(getPlayer());
|
|
||||||
break;
|
|
||||||
case Success:
|
|
||||||
buildSuccessPage("Your purchase was successful.");
|
|
||||||
|
|
||||||
if (_runnable != null)
|
|
||||||
_runnable.run();
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_progressCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildErrorPage(String... message)
|
|
||||||
{
|
|
||||||
IButton returnButton = new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
cancelClicked(player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ShopItem item = new ShopItem(Material.REDSTONE_BLOCK, (byte)0, ChatColor.RED + "" + ChatColor.UNDERLINE + "ERROR", message, 1, false, true);
|
|
||||||
for (int i = 0; i < this.getSize(); i++)
|
|
||||||
{
|
|
||||||
addButton(i, item, returnButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlayer().playSound(getPlayer().getLocation(), Sound.BLAZE_DEATH, 1, .1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSuccessPage(String message)
|
|
||||||
{
|
|
||||||
IButton returnButton = new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
cancelClicked(player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ShopItem item = new ShopItem(Material.EMERALD_BLOCK, (byte)0, ChatColor.GREEN + message, null, 1, false, true);
|
|
||||||
for (int i = 0; i < this.getSize(); i++)
|
|
||||||
{
|
|
||||||
addButton(i, item, returnButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, .9f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerClosed()
|
|
||||||
{
|
|
||||||
super.playerClosed();
|
|
||||||
|
|
||||||
Bukkit.getScheduler().cancelTask(_taskId);
|
|
||||||
|
|
||||||
if (_returnPage != null && getShop() != null)
|
|
||||||
getShop().setCurrentPageForPlayer(getPlayer(), _returnPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (_processing)
|
|
||||||
{
|
|
||||||
if (_progressCount == 9)
|
|
||||||
{
|
|
||||||
for (int i=45; i < 54; i++)
|
|
||||||
{
|
|
||||||
clear(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
_progressCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
setItem(45 + _progressCount, _progressItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_progressCount >= 20)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Bukkit.getScheduler().cancelTask(_taskId);
|
|
||||||
|
|
||||||
if (_returnPage != null && getShop() != null)
|
|
||||||
{
|
|
||||||
getShop().openPageForPlayer(getPlayer(), _returnPage);
|
|
||||||
}
|
|
||||||
else if (getPlayer() != null)
|
|
||||||
{
|
|
||||||
getPlayer().closeInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_progressCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
super.dispose();
|
|
||||||
|
|
||||||
Bukkit.getScheduler().cancelTask(_taskId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,8 +4,10 @@ import mineplex.core.common.currency.GlobalCurrency;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
|
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import mineplex.core.treasure.ChestPackage;
|
import mineplex.core.treasure.ChestPackage;
|
||||||
import mineplex.core.treasure.TreasureType;
|
import mineplex.core.treasure.TreasureType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -63,10 +65,11 @@ public class BuyChestButton implements IButton
|
|||||||
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(
|
SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost);
|
||||||
_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), () -> {
|
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () ->
|
||||||
_inventoryManager.addItemToInventory(player, _chestName, 1);
|
{
|
||||||
_page.refresh();
|
_inventoryManager.addItemToInventory(player, _chestName, 1);
|
||||||
}, _page, new ChestPackage(_chestName, _chestMat, _chestCost), GlobalCurrency.TREASURE_SHARD, player));
|
_page.refresh();
|
||||||
|
}), salesPackage.buildIcon()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package mineplex.game.clans.shop.energy;
|
|
||||||
|
|
||||||
import mineplex.core.shop.item.SalesPackageBase;
|
|
||||||
import mineplex.game.clans.economy.ClansCurrency;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
public class EnergyPackage extends SalesPackageBase
|
|
||||||
{
|
|
||||||
public EnergyPackage(String name, int cost)
|
|
||||||
{
|
|
||||||
super(name, Material.REDSTONE, " ", ChatColor.RESET + "Clan Energy");
|
|
||||||
CurrencyCostMap.put(ClansCurrency.GOLD, cost);
|
|
||||||
KnownPackage = false;
|
|
||||||
OneTimePurchaseOnly = false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +1,10 @@
|
|||||||
package mineplex.game.clans.shop.energy;
|
package mineplex.game.clans.shop.energy;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
|
||||||
import mineplex.game.clans.clans.ClanEnergyManager;
|
import mineplex.game.clans.clans.ClanEnergyManager;
|
||||||
import mineplex.game.clans.clans.ClanInfo;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
||||||
import mineplex.game.clans.economy.ClansCurrency;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
@ -35,8 +32,8 @@ public class EnergyShopButton implements IButton
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<ClanEnergyManager, EnergyShop>(
|
/*_page.getShop().openPageForPlayer(player, new ConfirmationPage<ClanEnergyManager, EnergyShop>(
|
||||||
_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -56,7 +53,8 @@ public class EnergyShopButton implements IButton
|
|||||||
// Notify
|
// Notify
|
||||||
_energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan"));
|
_energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan"));
|
||||||
}
|
}
|
||||||
}, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), ClansCurrency.GOLD, player));
|
}, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), ClansCurrency.GOLD, player));*/
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,9 @@ import mineplex.core.common.currency.GlobalCurrency;
|
|||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
||||||
@ -387,13 +388,8 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
|
|||||||
|
|
||||||
public void PurchaseSkill(Player player, ISkill skill)
|
public void PurchaseSkill(Player player, ISkill skill)
|
||||||
{
|
{
|
||||||
getShop().openPageForPlayer(player, new ConfirmationPage<ClassShopManager, ClassCombatShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
SalesPackageBase salesPackage = new SkillSalesPackage(skill);
|
||||||
{
|
getShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, getDonationManager(), this::buildPage), salesPackage.buildIcon()));
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
}, this, new SkillSalesPackage(skill), GlobalCurrency.GEM, player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSkillLocked(ISkill skill)
|
private boolean isSkillLocked(ISkill skill)
|
||||||
@ -414,13 +410,8 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
|
|||||||
|
|
||||||
public void PurchaseItem(Player player, Item item)
|
public void PurchaseItem(Player player, Item item)
|
||||||
{
|
{
|
||||||
getShop().openPageForPlayer(player, new ConfirmationPage<ClassShopManager, ClassCombatShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
SalesPackageBase salesPackage = new ItemSalesPackage(item);
|
||||||
{
|
getShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, getDonationManager(), this::buildPage), salesPackage.buildIcon()));
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
}, this, new ItemSalesPackage(item), GlobalCurrency.GEM, player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectItem(Player player, Item item)
|
public void SelectItem(Player player, Item item)
|
||||||
|
@ -14,7 +14,8 @@ import mineplex.core.progression.data.PlayerKit;
|
|||||||
import mineplex.core.progression.data.PlayerKitDataManager;
|
import mineplex.core.progression.data.PlayerKitDataManager;
|
||||||
import mineplex.core.progression.gui.Menu;
|
import mineplex.core.progression.gui.Menu;
|
||||||
import mineplex.core.progression.math.Calculations;
|
import mineplex.core.progression.math.Calculations;
|
||||||
import mineplex.core.shop.page.ConfirmationPage;
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
|
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.game.games.evolution.Evolution;
|
import nautilus.game.arcade.game.games.evolution.Evolution;
|
||||||
@ -300,13 +301,14 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
|
|||||||
}
|
}
|
||||||
else if (this.GetAvailability() == KitAvailability.Gem && donor.getBalance(GlobalCurrency.GEM) >= this.GetCost())
|
else if (this.GetAvailability() == KitAvailability.Gem && donor.getBalance(GlobalCurrency.GEM) >= this.GetCost())
|
||||||
{
|
{
|
||||||
Manager.GetShop().openPageForPlayer(player, new ConfirmationPage<>(
|
SalesPackageBase salesPackage = new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this);
|
||||||
Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), () -> {
|
Manager.GetShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, Manager.GetDonation(), () ->
|
||||||
|
{
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
Manager.GetGame().SetKit(player, this, true);
|
Manager.GetGame().SetKit(player, this, true);
|
||||||
}
|
}
|
||||||
}, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), GlobalCurrency.GEM, player));
|
}), salesPackage.buildIcon()));
|
||||||
}
|
}
|
||||||
else if (this.GetAvailability() == KitAvailability.Achievement)
|
else if (this.GetAvailability() == KitAvailability.Achievement)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user