More tweaks

This commit is contained in:
Shaun Bennett 2015-01-29 22:41:54 -05:00
parent 1cc0879ce9
commit 79a60db15d
3 changed files with 3 additions and 113 deletions

View File

@ -1,44 +0,0 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
public class TreasureButton implements IButton
{
private Menu _menu;
private boolean _hasEnoughChests;
private boolean _hasEnoughKeys;
private boolean _canPurchaseKey;
public TreasureButton(Menu menu, boolean hasEnoughChests, boolean hasEnoughKeys, boolean canPurchaseKey)
{
_menu = menu;
_hasEnoughChests = hasEnoughChests;
_hasEnoughKeys = hasEnoughKeys;
_canPurchaseKey = canPurchaseKey;
}
public void onClick(Player player, ClickType clickType)
{
if (clickType.isLeftClick())
{
if (_hasEnoughChests && _hasEnoughKeys)
{
_menu.openTreasure(player);
player.closeInventory();
}
else if (_hasEnoughChests && _canPurchaseKey)
{
_menu.attemptPurchaseKey(player);
}
}
else if (clickType.isRightClick())
{
if (_canPurchaseKey)
_menu.attemptPurchaseKey(player);
}
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Creature;
@ -12,8 +10,6 @@ import org.bukkit.event.inventory.ClickType;
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.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.OpenCostumes;
@ -23,7 +19,6 @@ import mineplex.core.cosmetic.ui.button.OpenMounts;
import mineplex.core.cosmetic.ui.button.OpenMusic;
import mineplex.core.cosmetic.ui.button.OpenParticles;
import mineplex.core.cosmetic.ui.button.OpenPets;
import mineplex.core.cosmetic.ui.button.TreasureButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -33,7 +28,6 @@ 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.TreasureManager;
public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
@ -47,7 +41,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
@Override
protected void BuildPage()
{
AddItem(2, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", new String[]
AddItem(4, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", new String[]
{
" ",
ChatColor.RESET + C.cYellow + "Purchase Coins",
@ -60,54 +54,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
ChatColor.RESET + "Receives 15000 Coins per Month",
}, 1, false));
int treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
int treasureKeyCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Key");
boolean canPurchaseKey = DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= 1000;
ArrayList<String> lore = new ArrayList<String>();
lore.add(ChatColor.RESET + "You can find all kinds of rare");
lore.add(ChatColor.RESET + "and exciting loot inside!");
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Treasure Chests: " + ChatColor.RESET + treasureChestCount);
lore.add(ChatColor.RESET + C.cYellow + "Treasure Keys: " + ChatColor.RESET + treasureKeyCount);
lore.add(" ");
if (treasureChestCount > 0 && treasureKeyCount > 0)
{
lore.add(ChatColor.RESET + C.cGreen + "Left-Click to open Treasure Chest");
lore.add(ChatColor.RESET + " Uses 1 Treasure Chest");
lore.add(ChatColor.RESET + " Uses 1 Treasure Key");
}
else if (treasureChestCount > 0)
{
lore.add(ChatColor.RESET + C.cRed + "Left-Click to open Treasure Chest");
lore.add(ChatColor.RESET + " This requires 1 Treasure Key");
lore.add(ChatColor.RESET + " You do not have any Treasure Keys");
}
else
{
lore.add(ChatColor.RESET + C.cRed + "Left-Click to open Treasure Chest");
lore.add(ChatColor.RESET + " This requires 1 Treasure Chest");
lore.add(ChatColor.RESET + " Find Treasure Chests by playing games");
}
lore.add(" ");
if (canPurchaseKey)
{
lore.add(ChatColor.RESET + C.cGreen + "Right-Click to purchase Treasure Key");
lore.add(ChatColor.RESET + " Costs 1000 Coins");
}
else
{
lore.add(ChatColor.RESET + C.cRed + "Right-Click to purchase Treasure Key");
lore.add(ChatColor.RESET + " Costs 1000 Coins");
lore.add(ChatColor.RESET + " You cannot afford a Treasure Key");
}
AddButton(4, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGreen + C.Bold + "Treasure Chest", lore.toArray(new String[0]), 1, false), new TreasureButton(this, treasureChestCount > 0, treasureKeyCount > 0, canPurchaseKey));
AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
@ -212,19 +158,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
Shop.OpenPageForPlayer(player, new MusicPage(Plugin, Shop, ClientManager, DonationManager, "Music", player));
}
public void openTreasure(Player player)
{
TreasureManager treasureManager = Plugin.getTreasureManager();
if (treasureManager == null)
{
UtilPlayer.message(player, F.main("Treasure", "You cannot open Treasure Chests on this server"));
}
else
{
// treasureManager.attemptOpenTreasure(player);
}
}
public void attemptPurchaseKey(Player player)
{
Shop.OpenPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()

View File

@ -98,7 +98,8 @@ public class TreasureLocation implements Listener
setHoloChestVisible(false);
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
if (treasureType == TreasureType.HEROIC || treasureType == TreasureType.LEGENDARY)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardType());
Treasure treasure = new Treasure(player, rewards, _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager);