From 6bbf9bd321bbd14ba6a7a6f4baa07b7ece7e12be Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Tue, 10 Feb 2015 12:23:11 +1300 Subject: [PATCH] Ability to purchase old chests --- .../src/mineplex/core/treasure/OldChest.java | 25 ++++++++++++++ .../treasure/gui/BuyBasicChestButton.java | 33 ++++++++++++------- .../core/treasure/gui/TreasurePage.java | 7 +++- 3 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/treasure/OldChest.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/OldChest.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/OldChest.java new file mode 100644 index 000000000..98a0f4f6d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/OldChest.java @@ -0,0 +1,25 @@ +package mineplex.core.treasure; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.CurrencyType; +import mineplex.core.shop.item.SalesPackageBase; + +public class OldChest extends SalesPackageBase +{ + public OldChest() + { + super("Old Chest", Material.CHEST, (byte) 0, new String[] { ChatColor.RESET + "Old Chest" }, 1000); + + KnownPackage = false; + OneTimePurchaseOnly = false; + } + + @Override + public void Sold(Player player, CurrencyType currencyType) + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyBasicChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyBasicChestButton.java index 97b0a335f..3bcf384b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyBasicChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyBasicChestButton.java @@ -3,8 +3,14 @@ package mineplex.core.treasure.gui; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.CurrencyType; +import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ConfirmationPage; +import mineplex.core.treasure.OldChest; +import mineplex.core.treasure.TreasureManager; public class BuyBasicChestButton implements IButton { @@ -12,26 +18,29 @@ public class BuyBasicChestButton implements IButton private InventoryManager _inventoryManager; - public BuyBasicChestButton(Player player, InventoryManager inventoryManager) + private TreasurePage _page; + + public BuyBasicChestButton(Player player, InventoryManager inventoryManager, TreasurePage page) { _player = player; _inventoryManager = inventoryManager; + + _page = page; } @Override - public void onClick(Player player, ClickType clickType) + public void onClick(final Player player, ClickType clickType) { //need to do this :o -// Shop.OpenPageForPlayer(player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() -// { -// public void run() -// { -// _inventoryManager.addItemToInventory(player, "Item", "Old Chest", 1); -// Refresh(); -// } -// }, this, new TreasureKey(), CurrencyType.Coins, Player)); - - _inventoryManager.addItemToInventory(player, "Item", "Old Chest", 1); + _page.getShop().OpenPageForPlayer(player, new ConfirmationPage( + _page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable() + { + public void run() + { + _inventoryManager.addItemToInventory(player, "Item", "Old Chest", 1); + _page.Refresh(); + } + }, _page, new OldChest(), CurrencyType.Coins, player)); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 014c514c1..b47e34a4b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -8,12 +8,17 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.treasure.TreasureKey; import mineplex.core.treasure.TreasureLocation; import mineplex.core.treasure.TreasureManager; import mineplex.core.treasure.TreasureType; @@ -74,7 +79,7 @@ public class TreasurePage extends ShopPageBase if (basicCount > 0) AddButton(2, basic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.OLD)); else - AddButton(2, basic, new BuyBasicChestButton(Player, _inventoryManager)); + AddButton(2, basic, new BuyBasicChestButton(Player, _inventoryManager, this)); AddButton(4, heroic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.ANCIENT)); AddButton(6, legendary, new OpenTreasureButton(Player, _treasureLocation, TreasureType.MYTHICAL)); }