diff --git a/build.gradle b/build.gradle index 3f412f711..1cb571a35 100644 --- a/build.gradle +++ b/build.gradle @@ -1 +1 @@ -allprojects { apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' group = 'be.isach' version = '2.5.0-RELEASE' compileJava.options.encoding = 'UTF-8' sourceCompatibility = 1.8 targetCompatibility = 1.8 configurations { shaded compile.extendsFrom shaded } afterEvaluate { jar { dependsOn configurations.shaded from configurations.shaded.collect { it.isDirectory() ? it : zipTree(it) } } } } boolean local = false if (local) libsDirName = '/Users/sacha/Documents/Development/Java/UC_1_11/testserver/plugins' dependencies { subprojects.each { p -> shaded(p) { transitive false } } } subprojects { repositories { mavenLocal() mavenCentral() // Vault maven { url 'http://nexus.hc.to/content/repositories/pub_releases' } // Lib's Disguises maven { url 'http://repo.md-5.net/content/groups/public/' } maven { url 'https://repo.isach.be' } // BungeeCord maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // PlaceholderAPI maven { url 'http://repo.extendedclip.com/content/repositories/placeholderapi/' } } } \ No newline at end of file +allprojects { apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' group = 'be.isach' version = '2.5.0' compileJava.options.encoding = 'UTF-8' sourceCompatibility = 1.8 targetCompatibility = 1.8 configurations { shaded compile.extendsFrom shaded } afterEvaluate { jar { dependsOn configurations.shaded from configurations.shaded.collect { it.isDirectory() ? it : zipTree(it) } } } } boolean local = false if (local) libsDirName = '/Users/sacha/Documents/Development/Java/UC_1_11/testserver/plugins' dependencies { subprojects.each { p -> shaded(p) { transitive false } } } subprojects { repositories { mavenLocal() mavenCentral() // Vault maven { url 'http://nexus.hc.to/content/repositories/pub_releases' } // Lib's Disguises maven { url 'http://repo.md-5.net/content/groups/public/' } maven { url 'https://repo.isach.be' } // BungeeCord maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // PlaceholderAPI maven { url 'http://repo.extendedclip.com/content/repositories/placeholderapi/' } // PlayerPoints maven { url 'https://repo.dakanilabs.com/repository/public/' } } } \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index eada6c3ef..5504ee5e7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -8,6 +8,7 @@ dependencies { exclude group: 'org.bukkit' } compile 'me.clip:placeholderapi:2.8.2' + compile 'org.black_ixx:PlayerPoints:2.1.3' } processResources { diff --git a/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java b/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java index 08987eba2..29a78e763 100755 --- a/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java +++ b/core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java @@ -4,6 +4,8 @@ import be.isach.ultracosmetics.config.MessageManager; import be.isach.ultracosmetics.config.SettingsManager; import be.isach.ultracosmetics.config.TreasureManager; +import be.isach.ultracosmetics.economy.EconomyHandler; +import be.isach.ultracosmetics.economy.EconomyHook; import be.isach.ultracosmetics.listeners.MainListener; import be.isach.ultracosmetics.listeners.PlayerListener; import be.isach.ultracosmetics.listeners.v1_9.PlayerSwapItemListener; @@ -15,6 +17,7 @@ import be.isach.ultracosmetics.placeholderapi.PlaceholderHook; import be.isach.ultracosmetics.player.UltraPlayer; import be.isach.ultracosmetics.player.UltraPlayerManager; +import be.isach.ultracosmetics.economy.PlayerPointsHook; import be.isach.ultracosmetics.run.FallDamageManager; import be.isach.ultracosmetics.run.InvalidWorldChecker; import be.isach.ultracosmetics.run.MovingChecker; @@ -46,7 +49,6 @@ * @since 08-03-2015 */ public class UltraCosmetics extends JavaPlugin { - /** * Manages sub commands. */ @@ -62,11 +64,6 @@ public class UltraCosmetics extends JavaPlugin { */ private File file; - /** - * Economy, used only if Vault is enabled. - */ - private Economy economy = null; - /** * Player Manager instance. */ @@ -101,9 +98,9 @@ public class UltraCosmetics extends JavaPlugin { * Manages armor stands. */ private ArmorStandManager armorStandManager; - - private boolean vaultLoaded = false; - + + + private EconomyHandler economyHandler; /** * Called when plugin is enabled. */ @@ -254,27 +251,11 @@ private void registerListeners() { } /** - * Sets Vault up. + * Sets the economy up. */ private void setupEconomy() { + economyHandler = new EconomyHandler(this, getConfig().getString("Economy")); UltraCosmeticsData.get().checkTreasureChests(); - if (!(UltraCosmeticsData.get().isAmmoEnabled() - || (SettingsManager.getConfig().getBoolean("Pets-Rename.Enabled") && SettingsManager.getConfig().getBoolean("Pets-Rename.Requires-Money.Enabled")) - || UltraCosmeticsData.get().areTreasureChestsEnabled())) { - return; - } - - if (!Bukkit.getPluginManager().isPluginEnabled("Vault")) { - return; - } - - RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); - if (economyProvider != null) { - economy = economyProvider.getProvider(); - UltraCosmeticsData.get().setUsingVaultEconomy(true); - } - - vaultLoaded = true; } private void setUpConfig() { @@ -383,13 +364,6 @@ public SmartLogger getSmartLogger() { return smartLogger; } - /** - * @return Vault Economy. - */ - public Economy getEconomy() { - return economy; - } - /** * @return The Update CheckerC. */ @@ -422,10 +396,6 @@ public ArmorStandManager getArmorStandManager() { return armorStandManager; } - public boolean isVaultLoaded() { - return vaultLoaded; - } - public void openMainMenu(UltraPlayer ultraPlayer) { if (getConfig().getBoolean("Categories.Back-To-Main-Menu-Custom-Command.Enabled")) { String command = getConfig().getString("Categories.Back-To-Main-Menu-Custom-Command.Command").replace("/", "").replace("{player}", ultraPlayer.getBukkitPlayer().getName()).replace("{playeruuid}", ultraPlayer.getUuid().toString()); @@ -434,4 +404,8 @@ public void openMainMenu(UltraPlayer ultraPlayer) { getMenus().getMainMenu().open(ultraPlayer); } } + + public EconomyHandler getEconomyHandler() { + return economyHandler; + } } diff --git a/core/src/main/java/be/isach/ultracosmetics/UltraCosmeticsData.java b/core/src/main/java/be/isach/ultracosmetics/UltraCosmeticsData.java index b999f9bae..5d0c31b14 100644 --- a/core/src/main/java/be/isach/ultracosmetics/UltraCosmeticsData.java +++ b/core/src/main/java/be/isach/ultracosmetics/UltraCosmeticsData.java @@ -57,11 +57,6 @@ public static UltraCosmeticsData get() { */ private boolean moneyTreasureLoot; - /** - * If a Vault economy is being used. - */ - private boolean usingVaultEconomy; - /** * Determines if Gadget Cooldown should be shown in action bar. */ @@ -116,13 +111,8 @@ void checkTreasureChests() { moneyTreasureLoot = SettingsManager.getConfig().getBoolean("TreasureChests.Loots.Money.Enabled"); if (SettingsManager.getConfig().getBoolean("TreasureChests.Enabled")) { treasureChests = true; - if (!Bukkit.getPluginManager().isPluginEnabled("Vault") - && (boolean) SettingsManager.getConfig().get("TreasureChests.Loots.Money.Enabled")) { - ultraCosmetics.getSmartLogger().write("-------------------------"); - ultraCosmetics.getSmartLogger().write("Treasure Chests' Money Loot requires Vault!"); - ultraCosmetics.getSmartLogger().write("Money Loot is turned off!"); - ultraCosmetics.getSmartLogger().write("-------------------------"); - moneyTreasureLoot = false; + if ((boolean) SettingsManager.getConfig().get("TreasureChests.Loots.Money.Enabled")) { + moneyTreasureLoot = true; } } } @@ -248,14 +238,6 @@ public void setServerVersion(ServerVersion serverVersion) { this.serverVersion = serverVersion; } - public void setUsingVaultEconomy(boolean usingVaultEconomy) { - this.usingVaultEconomy = usingVaultEconomy; - } - - public boolean isUsingVaultEconomy() { - return this.usingVaultEconomy; - } - public final String getItemNoPickupString() { return this.itemNoPickupString; } diff --git a/core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/Gadget.java b/core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/Gadget.java index eb16a32fb..2820d25e2 100755 --- a/core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/Gadget.java +++ b/core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/Gadget.java @@ -17,6 +17,10 @@ import be.isach.ultracosmetics.util.SoundUtil; import be.isach.ultracosmetics.util.Sounds; import be.isach.ultracosmetics.util.TextUtil; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -38,11 +42,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; -import java.util.UUID; - /** * Represents an instance of a Gadget summoned by a player. * @@ -329,7 +328,7 @@ public void onInventoryClickAmmo(final InventoryClickEvent event) { if (displayName.equals(purchase)) { if (getUltraCosmetics().getPlayerManager().getUltraPlayer((Player) event.getWhoClicked()) .getBalance() >= getPrice()) { - getUltraCosmetics().getEconomy().withdrawPlayer((Player) event.getWhoClicked(), getPrice()); + getUltraCosmetics().getEconomyHandler().withdraw((Player) event.getWhoClicked(), getPrice()); getUltraCosmetics().getPlayerManager().getUltraPlayer((Player) event.getWhoClicked()) .addAmmo(getType().toString().toLowerCase(), getResultAmmoAmount()); event.getWhoClicked().sendMessage(MessageManager.getMessage("Successful-Purchase")); diff --git a/core/src/main/java/be/isach/ultracosmetics/economy/EconomyHandler.java b/core/src/main/java/be/isach/ultracosmetics/economy/EconomyHandler.java new file mode 100644 index 000000000..3f8a742b3 --- /dev/null +++ b/core/src/main/java/be/isach/ultracosmetics/economy/EconomyHandler.java @@ -0,0 +1,47 @@ +package be.isach.ultracosmetics.economy; + +import be.isach.ultracosmetics.UltraCosmetics; +import org.bukkit.entity.Player; + +/** + * Handles the current economy being used. + * + * @author RadBuilder + * @since 2.5 + */ +public class EconomyHandler { + private UltraCosmetics ultraCosmetics; + private EconomyHook economyHook; + private boolean usingEconomy; + + public EconomyHandler(UltraCosmetics ultraCosmetics, String economy) { + this.ultraCosmetics = ultraCosmetics; + if (economy.equalsIgnoreCase("vault")) { + economyHook = new VaultHook(ultraCosmetics); + } else if (economy.equalsIgnoreCase("playerpoints")) { + economyHook = new PlayerPointsHook(ultraCosmetics); + } else { + usingEconomy = false; + } + } + + public void withdraw(Player player, int amount) { + economyHook.withdraw(player, amount); + } + + public void deposit(Player player, int amount) { + economyHook.deposit(player, amount); + } + + public double balance(Player player) { + return economyHook.balance(player); + } + + public String getName() { + return economyHook.getName(); + } + + public boolean isUsingEconomy() { + return usingEconomy && economyHook.economyEnabled(); + } +} diff --git a/core/src/main/java/be/isach/ultracosmetics/economy/EconomyHook.java b/core/src/main/java/be/isach/ultracosmetics/economy/EconomyHook.java new file mode 100644 index 000000000..a48548ee4 --- /dev/null +++ b/core/src/main/java/be/isach/ultracosmetics/economy/EconomyHook.java @@ -0,0 +1,49 @@ +package be.isach.ultracosmetics.economy; + +import org.bukkit.entity.Player; + +/** + * Economy hook interface. + * + * @author RadBuilder + * @since 2.5 + */ +public interface EconomyHook { + /** + * Withdraws the specified amount of money from the specified player. + * + * @param player The player to withdraw money from. + * @param amount The amount to withdraw from the player. + */ + void withdraw(Player player, int amount); + + /** + * Gives the specified amount of money to the specified player. + * + * @param player The player to give money to. + * @param amount The amount to give to the player. + */ + void deposit(Player player, int amount); + + /** + * Gets the balance of the specified player. + * + * @param player The player to get the balance of. + * @return The player's balance. + */ + double balance(Player player); + + /** + * Gets the name of the economy being used. + * + * @return The name of the economy being used. + */ + String getName(); + + /** + * Gets if the economy is enabled and functioning. + * + * @return True if the economy is enabled and functioning, false otherwise. + */ + boolean economyEnabled(); +} diff --git a/core/src/main/java/be/isach/ultracosmetics/economy/PlayerPointsHook.java b/core/src/main/java/be/isach/ultracosmetics/economy/PlayerPointsHook.java new file mode 100644 index 000000000..041830eec --- /dev/null +++ b/core/src/main/java/be/isach/ultracosmetics/economy/PlayerPointsHook.java @@ -0,0 +1,69 @@ +package be.isach.ultracosmetics.economy; + +import be.isach.ultracosmetics.UltraCosmetics; +import org.black_ixx.playerpoints.PlayerPoints; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +/** + * PlayerPoints economy hook. + * + * @author RadBuilder + * @since 2.5 + */ +public class PlayerPointsHook implements EconomyHook { + private UltraCosmetics ultraCosmetics; + private PlayerPoints playerPoints; + private boolean economyEnabled; + + public PlayerPointsHook(UltraCosmetics ultraCosmetics) { + this.ultraCosmetics = ultraCosmetics; + if (hookPlayerPoints()) { + ultraCosmetics.getSmartLogger().write(""); + ultraCosmetics.getSmartLogger().write("Hooked into PlayerPoints for economy."); + ultraCosmetics.getSmartLogger().write(""); + economyEnabled = true; + } else { + ultraCosmetics.getSmartLogger().write(""); + ultraCosmetics.getSmartLogger().write("Something happened while hooking into PlayerPoints for economy."); + ultraCosmetics.getSmartLogger().write(""); + economyEnabled = false; + } + } + + /** + * Validate that there's access to PlayerPoints. + * + * @return True if there is access to PlayerPoints, otherwise false. + */ + private boolean hookPlayerPoints() { + final Plugin plugin = ultraCosmetics.getServer().getPluginManager().getPlugin("PlayerPoints"); + playerPoints = PlayerPoints.class.cast(plugin); + return playerPoints != null; + } + + @Override + public void withdraw(Player player, int amount) { + playerPoints.getAPI().take(player.getUniqueId(), amount); + } + + @Override + public void deposit(Player player, int amount) { + playerPoints.getAPI().give(player.getUniqueId(), amount); + } + + @Override + public double balance(Player player) { + return playerPoints.getAPI().look(player.getUniqueId()); + } + + @Override + public String getName() { + return "PlayerPoints"; + } + + @Override + public boolean economyEnabled() { + return economyEnabled; + } +} diff --git a/core/src/main/java/be/isach/ultracosmetics/economy/VaultHook.java b/core/src/main/java/be/isach/ultracosmetics/economy/VaultHook.java new file mode 100644 index 000000000..20d0e9058 --- /dev/null +++ b/core/src/main/java/be/isach/ultracosmetics/economy/VaultHook.java @@ -0,0 +1,58 @@ +package be.isach.ultracosmetics.economy; + +import be.isach.ultracosmetics.UltraCosmetics; +import net.milkbowl.vault.economy.Economy; +import org.bukkit.entity.Player; +import org.bukkit.plugin.RegisteredServiceProvider; + +/** + * Vault economy hook. + * + * @author RadBuilder + * @since 2.5 + */ +public class VaultHook implements EconomyHook { + private Economy economy = null; + private boolean economyEnabled; + + public VaultHook(UltraCosmetics ultraCosmetics) { + RegisteredServiceProvider economyProvider = ultraCosmetics.getServer().getServicesManager().getRegistration(Economy.class); + if (economyProvider != null) { + economy = economyProvider.getProvider(); + ultraCosmetics.getSmartLogger().write(""); + ultraCosmetics.getSmartLogger().write("Hooked into Vault for economy: " + economy.getName()); + ultraCosmetics.getSmartLogger().write(""); + economyEnabled = true; + } else { + ultraCosmetics.getSmartLogger().write(""); + ultraCosmetics.getSmartLogger().write("Something happened while hooking into Vault for economy."); + ultraCosmetics.getSmartLogger().write(""); + economyEnabled = false; + } + } + + @Override + public void withdraw(Player player, int amount) { + economy.withdrawPlayer(player, amount); + } + + @Override + public void deposit(Player player, int amount) { + economy.depositPlayer(player, amount); + } + + @Override + public double balance(Player player) { + return economy.getBalance(player); + } + + @Override + public String getName() { + return "Vault:" + economy.getName(); + } + + @Override + public boolean economyEnabled() { + return false; + } +} diff --git a/core/src/main/java/be/isach/ultracosmetics/manager/TreasureChestManager.java b/core/src/main/java/be/isach/ultracosmetics/manager/TreasureChestManager.java index 77f9920ed..067c971a6 100644 --- a/core/src/main/java/be/isach/ultracosmetics/manager/TreasureChestManager.java +++ b/core/src/main/java/be/isach/ultracosmetics/manager/TreasureChestManager.java @@ -82,7 +82,7 @@ public void buyKeyConfirm(InventoryClickEvent event) { && event.getCurrentItem().getItemMeta().hasDisplayName()) { if (event.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase(MessageManager.getMessage("Purchase"))) { if (UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer((Player) event.getWhoClicked()).getBalance() >= (int) SettingsManager.getConfig().get("TreasureChests.Key-Price")) { - UltraCosmeticsData.get().getPlugin().getEconomy().withdrawPlayer((Player) event.getWhoClicked(), (int) SettingsManager.getConfig().get("TreasureChests.Key-Price")); + ultraCosmetics.getEconomyHandler().withdraw((Player) event.getWhoClicked(), (int) SettingsManager.getConfig().get("TreasureChests.Key-Price")); UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer((Player) event.getWhoClicked()).addKey(); event.getWhoClicked().sendMessage(MessageManager.getMessage("Successful-Purchase")); event.getWhoClicked().closeInventory(); diff --git a/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuMain.java b/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuMain.java index 005cbfb78..19ebee5c7 100644 --- a/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuMain.java +++ b/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuMain.java @@ -95,17 +95,17 @@ protected void putItems(Inventory inventory, UltraPlayer player) { String msgChests = MessageManager.getMessage("Treasure-Chests"); if (player.getKeys() == 0) { - chest = ItemFactory.create(Material.CHEST, (byte) 0x0, msgChests, "", MessageManager.getMessage("Dont-Have-Key"), getUltraCosmetics().isVaultLoaded() ? - "" : null, getUltraCosmetics().isVaultLoaded() ? MessageManager.getMessage("Click-Buy-Key") : null, getUltraCosmetics().isVaultLoaded() ? "" : null); + chest = ItemFactory.create(Material.CHEST, (byte) 0x0, msgChests, "", MessageManager.getMessage("Dont-Have-Key"), getUltraCosmetics().getEconomyHandler().isUsingEconomy() ? + "" : null, getUltraCosmetics().getEconomyHandler().isUsingEconomy() ? MessageManager.getMessage("Click-Buy-Key") : null, getUltraCosmetics().getEconomyHandler().isUsingEconomy() ? "" : null); } else { chest = ItemFactory.create(Material.CHEST, (byte) 0x0, msgChests, "", MessageManager.getMessage("Click-Open-Chest"), ""); } ItemStack keys = ItemFactory.create(Material.TRIPWIRE_HOOK, (byte) 0x0, MessageManager.getMessage("Treasure-Keys"), "", - MessageManager.getMessage("Your-Keys").replace("%keys%", player.getKeys() + ""), getUltraCosmetics().isVaultLoaded() ? - "" : null, getUltraCosmetics().isVaultLoaded() ? MessageManager.getMessage("Click-Buy-Key") : null, getUltraCosmetics().isVaultLoaded() ? "" : null); + MessageManager.getMessage("Your-Keys").replace("%keys%", player.getKeys() + ""), getUltraCosmetics().getEconomyHandler().isUsingEconomy() ? + "" : null, getUltraCosmetics().getEconomyHandler().isUsingEconomy() ? MessageManager.getMessage("Click-Buy-Key") : null, getUltraCosmetics().getEconomyHandler().isUsingEconomy() ? "" : null); putItem(inventory, 5, keys, (data) -> { - if (!getUltraCosmetics().isVaultLoaded() && player.getKeys() == 0) { + if (!getUltraCosmetics().getEconomyHandler().isUsingEconomy() && player.getKeys() == 0) { SoundUtil.playSound(player.getBukkitPlayer().getLocation(), Sounds.ANVIL_LAND, 0.2f, 1.2f); return; } @@ -114,7 +114,7 @@ protected void putItems(Inventory inventory, UltraPlayer player) { }); putItem(inventory, 3, chest, (data) -> { - if (!getUltraCosmetics().isVaultLoaded() && player.getKeys() == 0) { + if (!getUltraCosmetics().getEconomyHandler().isUsingEconomy() && player.getKeys() == 0) { SoundUtil.playSound(player.getBukkitPlayer().getLocation(), Sounds.ANVIL_LAND, 0.2f, 1.2f); return; } diff --git a/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPets.java b/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPets.java index 18eb9129f..d7b5e59fe 100644 --- a/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPets.java +++ b/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPets.java @@ -83,7 +83,7 @@ public void renamePet(final UltraPlayer ultraPlayer) { if (event.getName() == null) { return; } - if (SettingsManager.getConfig().getBoolean("Pets-Rename.Requires-Money.Enabled") && UltraCosmeticsData.get().isUsingVaultEconomy()) { + if (SettingsManager.getConfig().getBoolean("Pets-Rename.Requires-Money.Enabled") && ultraCosmetics.getEconomyHandler().isUsingEconomy()) { event.setWillClose(false); event.setWillDestroy(false); buyRenamePet(ultraPlayer, event.getName()); diff --git a/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPurchase.java b/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPurchase.java index 8cf610001..976711f98 100644 --- a/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPurchase.java +++ b/core/src/main/java/be/isach/ultracosmetics/menu/menus/MenuPurchase.java @@ -33,7 +33,7 @@ protected void putItems(Inventory inventory, UltraPlayer player) { // Purchase Item ItemStack purchaseItem = ItemFactory.create(Material.EMERALD_BLOCK, MessageManager.getMessage("Purchase")); ClickRunnable purchaseClickRunnable = data -> { - getUltraCosmetics().getEconomy().withdrawPlayer(player.getBukkitPlayer(), purchaseData.getPrice()); + getUltraCosmetics().getEconomyHandler().withdraw(player.getBukkitPlayer(), purchaseData.getPrice()); purchaseData.getOnPurchase().run(); player.getBukkitPlayer().closeInventory(); }; diff --git a/core/src/main/java/be/isach/ultracosmetics/player/UltraPlayer.java b/core/src/main/java/be/isach/ultracosmetics/player/UltraPlayer.java index 5457c4256..dbcb9fe95 100755 --- a/core/src/main/java/be/isach/ultracosmetics/player/UltraPlayer.java +++ b/core/src/main/java/be/isach/ultracosmetics/player/UltraPlayer.java @@ -284,8 +284,8 @@ public void removeSuit(ArmorSlot armorSlot) { public double getBalance() { try { - if (ultraCosmetics.getEconomy() != null) { - return ultraCosmetics.getEconomy().getBalance(getBukkitPlayer()); + if (ultraCosmetics.getEconomyHandler().isUsingEconomy()) { + return ultraCosmetics.getEconomyHandler().balance(getBukkitPlayer()); } } catch (Exception exc) { ultraCosmetics.getSmartLogger().write("Error happened while getting a player's balance."); @@ -385,11 +385,7 @@ public T getCosmetic(Category category) { * Opens the Key Purchase Menu. */ public void openKeyPurchaseMenu() { - if (ultraCosmetics.getEconomy() == null) { - return; - } - - if (!ultraCosmetics.isVaultLoaded()) { + if (!ultraCosmetics.getEconomyHandler().isUsingEconomy()) { return; } diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/ChestType.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/ChestType.java deleted file mode 100644 index d464cad18..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/ChestType.java +++ /dev/null @@ -1,22 +0,0 @@ -package be.isach.ultracosmetics.tempchests; - -import org.bukkit.Material; - -/** - * Created by Sacha on 11/11/15. - */ -public enum ChestType { - - NORMAL(Material.CHEST), - ENDER(Material.ENDER_CHEST); - - private Material type; - - ChestType(Material type) { - this.type = type; - } - - public Material getType() { - return type; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureChest.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureChest.java deleted file mode 100755 index bc9b9ca3f..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureChest.java +++ /dev/null @@ -1,23 +0,0 @@ -//package be.isach.ultracosmetics.tempchests; -// -//import be.isach.ultracosmetics.UltraCosmetics; -//import be.isach.ultracosmetics.player.UltraPlayer; -//import org.apache.commons.lang.Validate; -//import org.bukkit.event.Listener; -// -//public class TreasureChest implements Listener { -// private TreasurePlacer treasurePlacer; -// -// public TreasureChest(UltraPlayer owner, final TreasureChestDesign design, UltraCosmetics ultraCosmetics) { -// Validate.notNull(owner); -// Validate.notNull(design); -// Validate.notNull(ultraCosmetics); -// -// this.treasurePlacer = new TreasurePlacer(new TreasureRandomizer(owner, owner.getBukkitPlayer().getLocation(), ultraCosmetics), owner, design, ultraCosmetics, this); -// treasurePlacer.start(); -// } -// -// public TreasurePlacer getTreasurePlacer() { -// return treasurePlacer; -// } -//} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureChestDesign.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureChestDesign.java deleted file mode 100644 index c555fc4b0..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureChestDesign.java +++ /dev/null @@ -1,81 +0,0 @@ -package be.isach.ultracosmetics.tempchests; - -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.util.Particles; -import org.bukkit.material.MaterialData; - -/** - * Created by Sacha on 11/11/15. - */ -public class TreasureChestDesign { - - private MaterialData center; - private MaterialData blocks2; - private MaterialData blocks3; - private MaterialData belowChests; - private MaterialData barriers; - private ChestType chestType; - private Particles effect; - - public TreasureChestDesign(String path) { - String center = g(path + ".center-block"), - blocks2 = g(path + ".around-center"), - blocks3 = g(path + ".third-blocks"), - belowChest = g(path + ".below-chests"), - barriers = g(path + ".barriers"), - chestType = g(path + ".chest-type"), - effect = g(path + ".effect"); - this.center = initMData(center); - this.blocks2 = initMData(blocks2); - this.blocks3 = initMData(blocks3); - this.belowChests = initMData(belowChest); - this.barriers = initMData(barriers); - try { - this.chestType = ChestType.valueOf(chestType.toUpperCase()); - } catch (Exception exc) { - this.chestType = ChestType.NORMAL; - } - try { - this.effect = Particles.valueOf(effect); - } catch (Exception exc) { - this.effect = Particles.FLAME; - } - } - - private MaterialData initMData(String name) { - return new MaterialData(Integer.parseInt(name.split(":")[0]), - (name.split(":").length > 1 ? (byte) Integer.parseInt(name.split(":")[1]) : (byte) 0)); - } - - private String g(String s) { - return TreasureManager.getDesignFile().getString("Designs." + s); - } - - public ChestType getChestType() { - return chestType; - } - - public MaterialData getCenter() { - return center; - } - - public MaterialData getBlocks2() { - return blocks2; - } - - public MaterialData getBlocks3() { - return blocks3; - } - - public MaterialData getBarriers() { - return barriers; - } - - public MaterialData getBelowChests() { - return belowChests; - } - - public Particles getEffect() { - return effect; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasurePlacer.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasurePlacer.java deleted file mode 100644 index 1014c19af..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasurePlacer.java +++ /dev/null @@ -1,528 +0,0 @@ -//package be.isach.ultracosmetics.tempchests; -// -//import java.util.ArrayList; -//import java.util.HashMap; -//import java.util.List; -//import java.util.Map; -//import java.util.UUID; -// -//import org.bukkit.Bukkit; -//import org.bukkit.Location; -//import org.bukkit.Material; -//import org.bukkit.block.Block; -//import org.bukkit.block.BlockFace; -//import org.bukkit.block.BlockState; -//import org.bukkit.entity.ArmorStand; -//import org.bukkit.entity.Entity; -//import org.bukkit.entity.EntityType; -//import org.bukkit.entity.Player; -//import org.bukkit.event.EventHandler; -//import org.bukkit.event.Listener; -//import org.bukkit.event.block.BlockBreakEvent; -//import org.bukkit.event.player.PlayerInteractEvent; -//import org.bukkit.event.player.PlayerKickEvent; -//import org.bukkit.event.player.PlayerMoveEvent; -//import org.bukkit.inventory.meta.ItemMeta; -//import org.bukkit.material.Chest; -//import org.bukkit.material.EnderChest; -//import org.bukkit.metadata.FixedMetadataValue; -//import org.bukkit.scheduler.BukkitRunnable; -//import org.bukkit.util.Vector; -// -//import be.isach.ultracosmetics.UltraCosmetics; -//import be.isach.ultracosmetics.UltraCosmeticsData; -//import be.isach.ultracosmetics.config.MessageManager; -//import be.isach.ultracosmetics.player.UltraPlayer; -//import be.isach.ultracosmetics.util.BlockUtils; -//import be.isach.ultracosmetics.util.MathUtils; -//import be.isach.ultracosmetics.util.Particles; -//import be.isach.ultracosmetics.util.ServerVersion; -//import be.isach.ultracosmetics.util.SoundUtil; -//import be.isach.ultracosmetics.util.Sounds; -//import be.isach.ultracosmetics.util.UtilParticles; -// -///** -// * Manages the real treasure chests in the world. -// * -// * @author RadBuilder -// * @since 01-14-2016 -// * -// * TODO Cleanup -// */ -//@SuppressWarnings("deprecation") -//public class TreasurePlacer implements Listener { -// private Map oldMaterials = new HashMap<>(); -// private Map oldDatas = new HashMap<>(); -// private ArrayList blocksToRestore = new ArrayList<>(); -// private ArrayList chests = new ArrayList<>(); -// private ArrayList chestsToRemove = new ArrayList<>(); -// private final BukkitRunnable[] runnables = new BukkitRunnable[2]; -// private TreasureChest instance; -// private TreasureRandomizer randomGenerator; -// private Location center; -// private Particles particleEffect; -// private int chestsLeft = 4; -// private UltraPlayer player; -// private List items = new ArrayList<>(); -// private List holograms = new ArrayList<>(); -// private boolean stopping; -// private boolean cooldown = false; -// private TreasureChestDesign design; -// private UltraCosmetics ultraCosmetics; -// -// public TreasurePlacer(TreasureRandomizer randomGenerator, UltraPlayer owner, TreasureChestDesign design2, -// UltraCosmetics ultraCosmetics, TreasureChest treasureChest) { -// this.randomGenerator = randomGenerator; -// this.instance = treasureChest; -// this.ultraCosmetics = ultraCosmetics; -// this.player = owner; -// Bukkit.getPluginManager().registerEvents(this, ultraCosmetics); -// if (owner.getCurrentMorph() != null) { -// owner.setSeeSelfMorph(false); -// } -// } -// -// public void start() { -// BukkitRunnable runnable = new BukkitRunnable() { -// int i = 5; -// public void run() { -// if (getPlayer() == null || getOwner().getCurrentTreasureChest() != instance) { -// cancel(); -// return; -// } -// -// try { -// if (this.i == 0) { -// runnables[0] = new BukkitRunnable() { -// int i = 4; -// -// public void run() { -// if (i <= 0) { -// cancel(); -// return; -// } -// if (getPlayer() == null || getOwner().getCurrentTreasureChest() != instance) { -// cancel(); -// return; -// } -// UtilParticles.playHelix(getChestLocation(this.i, center.clone()), 0.0F, particleEffect); -// UtilParticles.playHelix(getChestLocation(this.i, center.clone()), 3.5F, particleEffect); -// runnables[1] = new BukkitRunnable() { -// public void run() { -// try { -// Block b = getChestLocation(i, center.clone()).getBlock(); -// b.setType(design.getChestType().getType()); -// SoundUtil.playSound(getPlayer(), Sounds.ANVIL_LAND, 1.4f, 1.5f); -// UtilParticles.display(Particles.SMOKE_LARGE, b.getLocation(), 5); -// UtilParticles.display(Particles.LAVA, b.getLocation(), 5); -// BlockFace blockFace = BlockFace.SOUTH; -// switch (i) { -// case 4: -// blockFace = BlockFace.SOUTH; -// break; -// case 3: -// blockFace = BlockFace.NORTH; -// break; -// case 2: -// blockFace = BlockFace.EAST; -// break; -// case 1: -// blockFace = BlockFace.WEST; -// break; -// } -// -// BlockState blockState = b.getState(); -// if (design.getChestType() == ChestType.ENDER) { -// EnderChest enderChest = (EnderChest) b.getState().getData(); -// enderChest.setFacingDirection(blockFace); -// blockState.setData(enderChest); -// } else { -// Chest chest = (Chest) b.getState().getData(); -// chest.setFacingDirection(blockFace); -// blockState.setData(chest); -// } -// blockState.update(); -// -// chests.add(b); -// i--; -// } catch (Exception exc) { -// clear(); -// exc.printStackTrace(); -// cancel(); -// } -// } -// }; -// runnables[1].runTaskLater(ultraCosmetics, 30L); -// } -// }; -// runnables[0].runTaskTimer(ultraCosmetics, 0L, 50L); -// } -// -// Block lampBlock; -// switch (this.i) { -// case 5: -// lampBlock = getPlayer().getPlayer().getLocation().add(0.0D, -1.0D, 0.0D).getBlock(); -// center = lampBlock.getLocation().add(0.5D, 1.0D, 0.5D); -// oldMaterials.put(lampBlock.getLocation(), lampBlock.getType()); -// oldDatas.put(lampBlock.getLocation(), Byte.valueOf(lampBlock.getData())); -// blocksToRestore.add(lampBlock); -// lampBlock.setType(design.getCenter().getItemType()); -// lampBlock.setData(design.getCenter().getData()); -// break; -// case 4: -// for (Block b : getSurroundingBlocks(center.clone().add(0.0D, -1.0D, 0.0D).getBlock())) { -// oldMaterials.put(b.getLocation(), b.getType()); -// oldDatas.put(b.getLocation(), b.getData()); -// blocksToRestore.add(b); -// BlockUtils.treasureBlocks.add(b); -// b.setType(design.getBlocks2().getItemType()); -// b.setData(design.getBlocks2().getData()); -// } -// break; -// case 3: -// for (Block b : getSurroundingSurrounding(center.clone().add(0.0D, -1.0D, 0.0D).getBlock())) { -// oldMaterials.put(b.getLocation(), b.getType()); -// oldDatas.put(b.getLocation(), Byte.valueOf(b.getData())); -// blocksToRestore.add(b); -// BlockUtils.treasureBlocks.add(b); -// b.setType(design.getBlocks3().getItemType()); -// b.setData(design.getBlocks3().getData()); -// } -// break; -// case 2: -// for (Block b : getBlock3(center.clone().add(0.0D, -1.0D, 0.0D).getBlock())) { -// oldMaterials.put(b.getLocation(), b.getType()); -// oldDatas.put(b.getLocation(), Byte.valueOf(b.getData())); -// blocksToRestore.add(b); -// BlockUtils.treasureBlocks.add(b); -// BlockUtils.treasureBlocks.add(b); -// b.setType(design.getBelowChests().getItemType()); -// b.setData(design.getBelowChests().getData()); -// } -// break; -// case 1: -// for (Block b : getSurroundingSurrounding(center.getBlock())) { -// oldMaterials.put(b.getLocation(), b.getType()); -// oldDatas.put(b.getLocation(), Byte.valueOf(b.getData())); -// blocksToRestore.add(b); -// BlockUtils.treasureBlocks.add(b); -// b.setType(design.getBarriers().getItemType()); -// b.setData(design.getBarriers().getData()); -// } -// break; -// default: -// break; -// } -// this.i -= 1; -// } catch (Exception exc) { -// cancel(); -// exc.printStackTrace(); -// forceOpen(0); -// } -// } -// }; -// runnable.runTaskTimer(ultraCosmetics, 0L, 12L); -// -// Bukkit.getScheduler().runTaskLater(ultraCosmetics, new Runnable() { -// public void run() { -// if (getOwner().getCurrentTreasureChest() == instance) -// forceOpen(45); -// } -// }, 1200L); -// -// getOwner().setCurrentTreasureChest(instance); -// -// new BukkitRunnable() { -// public void run() { -// if (getPlayer() == null || getPlayer() == null || getOwner().getCurrentTreasureChest() != instance) { -// holograms.forEach(Entity::remove); -// cancel(); -// return; -// } -// if (!getPlayer().getWorld().getName().equals(center.getWorld().getName())) -// getPlayer().teleport(center); -// if (getPlayer().getLocation().distance(center) > 1.5D) -// getPlayer().teleport(center); -// getPlayer().getNearbyEntities(2.0D, 2.0D, 2.0D).stream() -// .filter(ent -> (getOwner().getCurrentPet() == null) || ((ent != getOwner().getCurrentPet()) -// && (!getOwner().getCurrentPet().items.contains(ent)))) -// .filter(ent -> (!items.contains(ent)) && (ent != getPlayer()) && (!holograms.contains(ent))) -// .forEachOrdered(ent -> { -// Vector v = ent.getLocation().toVector().subtract(getPlayer().getLocation().toVector()) -// .multiply(0.5D).add(new Vector(0.0D, 1.5D, 0.0D)); -// v.setY(0); -// v.add(new Vector(0, 1, 0)); -// MathUtils.applyVelocity(ent, v.add(MathUtils.getRandomCircleVector().multiply(0.2D))); -// }); -// } -// }.runTaskTimer(ultraCosmetics, 0L, 1L); -// } -// -// public UltraPlayer getOwner() { -// return player; -// } -// -// public Player getPlayer() { -// return player.getBukkitPlayer(); -// } -// -// public void clear() { -// for (Block b : this.blocksToRestore) { -// b.setType(this.oldMaterials.get(b.getLocation())); -// b.setData(this.oldDatas.get(b.getLocation()).byteValue()); -// BlockUtils.treasureBlocks.remove(b); -// } -// if (!this.stopping) { -// Bukkit.getScheduler().runTaskLater(ultraCosmetics, new Runnable() { -// public void run() { -// for (Entity hologram : holograms) -// hologram.remove(); -// for (Block b : chestsToRemove) { -// b.setType(Material.AIR); -// } -// for (Block b : chests) { -// b.setType(Material.AIR); -// } -// if (items != null) -// for (Entity ent : items) -// ent.remove(); -// if (runnables[0] != null) -// runnables[0].cancel(); -// if (runnables[1] != null) -// runnables[1].cancel(); -// if (items != null) -// items.clear(); -// if (chests != null) -// chests.clear(); -// if (holograms != null) -// holograms.clear(); -// if (chestsToRemove != null) -// chestsToRemove.clear(); -// if (blocksToRestore != null) -// blocksToRestore.clear(); -// if (ultraCosmetics.getPlayerManager().getUltraPlayer(getPlayer()) != null) -// ultraCosmetics.getPlayerManager().getUltraPlayer(getPlayer()).setCurrentTreasureChest(null); -// player = null; -// if (randomGenerator != null) -// randomGenerator.clear(); -// } -// }, 30L); -// } else { -// for (Entity hologram : this.holograms) -// hologram.remove(); -// for (Block b : this.chestsToRemove) { -// b.setType(Material.AIR); -// } -// for (Block b : this.chests) { -// b.setType(Material.AIR); -// } -// for (Entity ent : this.items) -// ent.remove(); -// this.runnables[0].cancel(); -// this.runnables[1].cancel(); -// this.items.clear(); -// this.chests.clear(); -// this.holograms.clear(); -// this.chestsToRemove.clear(); -// this.blocksToRestore.clear(); -// if (getPlayer() != null) { -// getOwner().setCurrentTreasureChest(null); -// } -// this.player = null; -// if (this.randomGenerator != null) -// this.randomGenerator.clear(); -// this.randomGenerator = null; -// } -// } -// -// public List getSurroundingBlocks(Block b) { -// List blocks = new ArrayList(); -// blocks.add(b.getRelative(BlockFace.EAST)); -// blocks.add(b.getRelative(BlockFace.WEST)); -// blocks.add(b.getRelative(BlockFace.NORTH)); -// blocks.add(b.getRelative(BlockFace.SOUTH)); -// blocks.add(b.getRelative(1, 0, 1)); -// blocks.add(b.getRelative(-1, 0, -1)); -// blocks.add(b.getRelative(1, 0, -1)); -// blocks.add(b.getRelative(-1, 0, 1)); -// return blocks; -// } -// -// @EventHandler -// public void onMove(PlayerMoveEvent event) { -// if ((event.getPlayer() == getPlayer()) && ((event.getFrom().getBlockX() != event.getTo().getBlockX()) -// || (event.getFrom().getBlockY() != event.getTo().getBlockY()) -// || (event.getFrom().getBlockZ() != event.getTo().getBlockZ()))) { -// event.setCancelled(true); -// event.getPlayer().teleport(event.getFrom()); -// } -// } -// -// public void forceOpen(int delay) { -// int i; -// if (delay == 0) { -// this.stopping = true; -// for (i = 0; i < this.chestsLeft; i++) { -// this.randomGenerator.getRandomThing(); -// getPlayer().sendMessage(MessageManager.getMessage("You-Won-Treasure-Chests").replace("%name%", -// this.randomGenerator.getName())); -// } -// } else { -// for (final Block b : this.chests) { -// UltraCosmeticsData.get().getVersionManager().getEntityUtil().playChestAnimation(b, true, design); -// this.randomGenerator.getRandomThing(); -// org.bukkit.inventory.ItemStack is = this.randomGenerator.getReward().getItemStack(); -// ItemMeta itemMeta = is.getItemMeta(); -// itemMeta.setDisplayName(UUID.randomUUID().toString()); -// is.setItemMeta(itemMeta); -// -// Entity entity = UltraCosmeticsData.get().getVersionManager().getEntityUtil().spawnItem(is, -// b.getLocation()); -// -// this.items.add(entity); -// final String nameas = this.randomGenerator.getName(); -// Bukkit.getScheduler().runTaskLater(ultraCosmetics, new Runnable() { -// public void run() { -// spawnHologram(b.getLocation().clone().add(0.5D, -// UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_9_R1 ? -0.7 : 0.3D, -// 0.5D), nameas); -// } -// }, 15L); -// -// this.chestsLeft -= 1; -// this.chestsToRemove.add(b); -// } -// this.chests.clear(); -// -// Bukkit.getScheduler().runTaskLater(ultraCosmetics, new Runnable() { -// public void run() { -// clear(); -// } -// }, delay); -// } -// } -// -// public List getSurroundingSurrounding(Block b) { -// List blocks = new ArrayList(); -// blocks.add(b.getRelative(2, 0, 1)); -// blocks.add(b.getRelative(2, 0, -1)); -// blocks.add(b.getRelative(2, 0, 2)); -// blocks.add(b.getRelative(2, 0, -2)); -// blocks.add(b.getRelative(1, 0, -2)); -// blocks.add(b.getRelative(1, 0, 2)); -// blocks.add(b.getRelative(-1, 0, -2)); -// blocks.add(b.getRelative(-1, 0, 2)); -// blocks.add(b.getRelative(-2, 0, 1)); -// blocks.add(b.getRelative(-2, 0, -1)); -// blocks.add(b.getRelative(-2, 0, 2)); -// blocks.add(b.getRelative(-2, 0, -2)); -// return blocks; -// } -// -// public List getBlock3(Block b) { -// List blocks = new ArrayList(); -// blocks.add(b.getRelative(-2, 0, 0)); -// blocks.add(b.getRelative(2, 0, 0)); -// blocks.add(b.getRelative(0, 0, 2)); -// blocks.add(b.getRelative(0, 0, -2)); -// return blocks; -// } -// -// @EventHandler -// public void onBreakBlock(BlockBreakEvent event) { -// if (this.blocksToRestore.contains(event.getBlock())) { -// event.setCancelled(true); -// return; -// } -// } -// -// private void spawnHologram(Location location, String s) { -// if (UltraCosmeticsData.get().getServerVersion().compareTo(ServerVersion.v1_9_R1) > 0) { -// location.setY(location.getY() - 1); -// } -// ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND); -// armorStand.setSmall(true); -// armorStand.setVisible(false); -// armorStand.setGravity(false); -// armorStand.setBasePlate(false); -// armorStand.setCustomName(s); -// armorStand.setCustomNameVisible(true); -// armorStand.setMetadata("C_AD_ArmorStand", new FixedMetadataValue(ultraCosmetics, "C_AD_ArmorStand")); -// this.holograms.add(armorStand); -// } -// -// @EventHandler -// public void onInter(final PlayerInteractEvent event) { -// if ((event.getClickedBlock() != null) -// && (event.getClickedBlock().getType() == Material.CHEST -// || event.getClickedBlock().getType() == Material.ENDER_CHEST -// || event.getClickedBlock().getType() == Material.TRAPPED_CHEST) -// && (this.chests.contains(event.getClickedBlock())) && (!this.cooldown)) { -// if (event.getPlayer() == getPlayer()) { -// UltraCosmeticsData.get().getVersionManager().getEntityUtil().playChestAnimation(event.getClickedBlock(), -// true, design); -// this.randomGenerator.getRandomThing(); -// -// this.cooldown = true; -// Bukkit.getScheduler().runTaskLaterAsynchronously(ultraCosmetics, new Runnable() { -// public void run() { -// cooldown = false; -// } -// }, 3L); -// -// org.bukkit.inventory.ItemStack is = this.randomGenerator.getReward().getItemStack(); -// ItemMeta itemMeta = is.getItemMeta(); -// itemMeta.setDisplayName(UUID.randomUUID().toString()); -// is.setItemMeta(itemMeta); -// -// Entity itemEntity = UltraCosmeticsData.get().getVersionManager().getEntityUtil().spawnItem(is, -// event.getClickedBlock().getLocation()); -// -// this.items.add(itemEntity); -// final String nameas = this.randomGenerator.getName(); -// Bukkit.getScheduler().runTaskLater(ultraCosmetics, new Runnable() { -// public void run() { -// spawnHologram(event.getClickedBlock().getLocation().add(0.5D, -// UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_9_R1 ? -0.7 : 0.3D, -// 0.5D), nameas); -// } -// }, 15L); -// -// this.chestsLeft -= 1; -// this.chests.remove(event.getClickedBlock()); -// this.chestsToRemove.add(event.getClickedBlock()); -// if (this.chestsLeft == 0) -// Bukkit.getScheduler().runTaskLater(ultraCosmetics, this::clear, 50L); -// } -// } -// } -// -// @EventHandler -// public void onKick(PlayerKickEvent event) { -// if ((event.getPlayer() == getPlayer()) && (event.getReason().contains("Fly"))) { -// event.setCancelled(true); -// event.getPlayer().teleport(this.center); -// } -// } -// -// public Location getChestLocation(int i, Location loc) { -// Location chestLocation = this.center.clone(); -// chestLocation.setX(loc.getBlockX() + 0.5D); -// chestLocation.setY(loc.getBlockY()); -// chestLocation.setZ(loc.getBlockZ() + 0.5D); -// switch (i) { -// case 1: -// chestLocation.add(2.0D, 0.0D, 0.0D); -// break; -// case 2: -// chestLocation.add(-2.0D, 0.0D, 0.0D); -// break; -// case 3: -// chestLocation.add(0.0D, 0.0D, 2.0D); -// break; -// case 4: -// chestLocation.add(0.0D, 0.0D, -2.0D); -// } -// return chestLocation; -// } -//} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureRandomizer.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureRandomizer.java deleted file mode 100755 index 099fa6355..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/TreasureRandomizer.java +++ /dev/null @@ -1,121 +0,0 @@ -package be.isach.ultracosmetics.tempchests; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.player.UltraPlayer; -import be.isach.ultracosmetics.tempchests.reward.AmmoReward; -import be.isach.ultracosmetics.tempchests.reward.BootReward; -import be.isach.ultracosmetics.tempchests.reward.ChestplateReward; -import be.isach.ultracosmetics.tempchests.reward.EmoteReward; -import be.isach.ultracosmetics.tempchests.reward.GadgetReward; -import be.isach.ultracosmetics.tempchests.reward.HatReward; -import be.isach.ultracosmetics.tempchests.reward.HelmetReward; -import be.isach.ultracosmetics.tempchests.reward.LeggingReward; -import be.isach.ultracosmetics.tempchests.reward.MoneyReward; -import be.isach.ultracosmetics.tempchests.reward.MorphReward; -import be.isach.ultracosmetics.tempchests.reward.MountReward; -import be.isach.ultracosmetics.tempchests.reward.NothingReward; -import be.isach.ultracosmetics.tempchests.reward.ParticleEffectReward; -import be.isach.ultracosmetics.tempchests.reward.PermissionReward; -import be.isach.ultracosmetics.tempchests.reward.PetReward; -import be.isach.ultracosmetics.tempchests.reward.Reward; -import org.bukkit.Location; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Treasure Chest Randomizer - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class TreasureRandomizer { - private List chance; - private List customRewards; - private UltraPlayer owner; - private UltraCosmetics ultraCosmetics; - private List rewards; - private Reward reward; - - public TreasureRandomizer(UltraPlayer owner, Location location, UltraCosmetics ultraCosmetics) { - chance = new ArrayList<>(); - customRewards = new ArrayList<>(); - for (String key : TreasureManager.getRewardFile().getConfigurationSection("CustomRewards").getKeys(false)) - if (TreasureManager.getRewardFile().getBoolean("CustomRewards." + key + ".enabled")) - customRewards.add(new PermissionReward(key, owner, ultraCosmetics)); - - this.owner = owner; - this.ultraCosmetics = ultraCosmetics; - - this.rewards = new ArrayList<>(); - rewards.add(new AmmoReward(owner, ultraCosmetics)); - rewards.add(new BootReward(owner, ultraCosmetics)); - rewards.add(new ChestplateReward(owner, ultraCosmetics)); - rewards.add(new EmoteReward(owner, ultraCosmetics)); - rewards.add(new GadgetReward(owner, ultraCosmetics)); - rewards.add(new HatReward(owner, ultraCosmetics)); - rewards.add(new HelmetReward(owner, ultraCosmetics)); - rewards.add(new LeggingReward(owner, ultraCosmetics)); - rewards.add(new MoneyReward(owner, ultraCosmetics)); - rewards.add(new MorphReward(owner, ultraCosmetics)); - rewards.add(new MountReward(owner, ultraCosmetics)); - rewards.add(new ParticleEffectReward(owner, ultraCosmetics)); - rewards.add(new PetReward(owner, ultraCosmetics)); - - calculateChances(); - } - - private void calculateChances() { - for (Reward r : rewards) { - if (r.canEarn()) { - int c = r.getType().getChance(); - for (int i = 0; i < c; i++) { - chance.add(r); - } - } - } - if (!customRewards.isEmpty()) { - for (PermissionReward r : customRewards) { - if (r.canEarn()) { - int c = r.getChance(); - for (int i = 0; i < c; i++) { - chance.add(r); - } - } - } - } - } - - public Reward getRandomThing() { - Reward reward = null; - if (chance.isEmpty()) { - if (!rewards.get(9).canEarn()) - return new NothingReward(owner, ultraCosmetics); - else - reward = rewards.get(9); - } else { - List random = new ArrayList<>(chance); - Collections.shuffle(random); - reward = random.get(0); - } - this.reward = reward; - return reward; - } - - public Reward getReward() { - return reward; - } - - public void clear() { - for (Reward r : rewards) { - r.clear(); - } - chance.clear(); - } - - public String getName() { - return reward.getName(); - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/AmmoReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/AmmoReward.java deleted file mode 100644 index e5d0667be..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/AmmoReward.java +++ /dev/null @@ -1,78 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.UltraCosmeticsData; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.GadgetType; -import be.isach.ultracosmetics.player.UltraPlayer; -import be.isach.ultracosmetics.util.MathUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * An ammo reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class AmmoReward extends Reward { - private String name; - private ItemStack itemStack; - private List ammoList; - private UltraPlayer ultraPlayer; - - public AmmoReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.AMMO, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - ammoList.clear(); - } - - @Override - public boolean canEarn() { - ammoList = new ArrayList<>(); - if (UltraCosmeticsData.get().isAmmoEnabled()) - for (GadgetType type : GadgetType.values()) - if (type.isEnabled() - && ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.requiresAmmo() - && type.canBeFound()) - ammoList.add(type); - return ammoList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(ammoList.size()); - GadgetType g = ammoList.get(i); - int ammo = MathUtils.randomRangeInt(TreasureManager.getRewardFile().getInt("UcRewards.gadget-ammo.min"), TreasureManager.getRewardFile().getInt("UcRewards.gadget-ammo.max")); - name = MessageManager.getMessage("Treasure-Chests-Loot.Ammo").replace("%name%", g.getName()).replace("%ammo%", ammo + ""); - ultraPlayer.addAmmo(g.toString().toLowerCase(), ammo); - itemStack = new MaterialData(g.getMaterial(), g.getData()).toItemStack(1); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.gadget-ammo.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.gadget-ammo.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.gadget-ammo.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.gadget-ammo.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%ammo%", ammo + "").replace("%gadget%", g.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/BootReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/BootReward.java deleted file mode 100644 index bf61cefba..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/BootReward.java +++ /dev/null @@ -1,74 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot; -import be.isach.ultracosmetics.cosmetics.type.SuitType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A boot reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class BootReward extends Reward { - private String name; - private ItemStack itemStack; - private List bootList; - private UltraPlayer ultraPlayer; - - public BootReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.BOOTS, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - bootList.clear(); - } - - @Override - public boolean canEarn() { - bootList = new ArrayList<>(); - for (SuitType type : SuitType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission(ArmorSlot.BOOTS)) - && type.canBeFound()) - bootList.add(type); - return bootList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(bootList.size()); - SuitType s = bootList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Suit").replace("%suit%", s.getName()); - itemStack = new MaterialData(s.getMaterial(), s.getData()).toItemStack(1); - givePermission(s.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.suit.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.suit.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%suit%", s.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/ChestplateReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/ChestplateReward.java deleted file mode 100644 index f0efb6558..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/ChestplateReward.java +++ /dev/null @@ -1,75 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot; -import be.isach.ultracosmetics.cosmetics.type.SuitType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A chestplate reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class ChestplateReward extends Reward { - private String name; - private ItemStack itemStack; - private List chestplateList; - private UltraPlayer ultraPlayer; - - - public ChestplateReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.CHESTPLATE, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - chestplateList.clear(); - } - - @Override - public boolean canEarn() { - chestplateList = new ArrayList<>(); - for (SuitType type : SuitType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission(ArmorSlot.CHESTPLATE)) - && type.canBeFound()) - chestplateList.add(type); - return chestplateList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(chestplateList.size()); - SuitType s = chestplateList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Suit").replace("%suit%", s.getName()); - itemStack = new MaterialData(s.getMaterial(), s.getData()).toItemStack(1); - givePermission(s.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.suit.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.suit.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%suit%", s.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/EmoteReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/EmoteReward.java deleted file mode 100644 index 00769dca1..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/EmoteReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.EmoteType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A gadget reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class EmoteReward extends Reward { - private String name; - private ItemStack itemStack; - private List emoteList; - private UltraPlayer ultraPlayer; - - public EmoteReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.EMOTE, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - emoteList.clear(); - } - - @Override - public boolean canEarn() { - emoteList = new ArrayList<>(); - for (EmoteType type : EmoteType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - emoteList.add(type); - return emoteList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(emoteList.size()); - EmoteType e = emoteList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Emote").replace("%emote%", e.getName()); - itemStack = new MaterialData(e.getMaterial(), e.getData()).toItemStack(1); - givePermission(e.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.emote.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.emote.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.emote.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.emote.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%emote%", e.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/GadgetReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/GadgetReward.java deleted file mode 100644 index c51b595c7..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/GadgetReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.GadgetType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A gadget reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class GadgetReward extends Reward { - private String name; - private ItemStack itemStack; - private List gadgetList; - private UltraPlayer ultraPlayer; - - public GadgetReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.GADGET, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - gadgetList.clear(); - } - - @Override - public boolean canEarn() { - gadgetList = new ArrayList<>(); - for (GadgetType type : GadgetType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - gadgetList.add(type); - return gadgetList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(gadgetList.size()); - GadgetType g = gadgetList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Gadget").replace("%gadget%", g.getName()); - itemStack = new MaterialData(g.getMaterial(), g.getData()).toItemStack(1); - givePermission(g.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.gadget.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.gadget.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.gadget.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.gadget.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%gadget%", g.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/HatReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/HatReward.java deleted file mode 100644 index 9c2cfc2dd..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/HatReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.HatType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A hat reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class HatReward extends Reward { - private String name; - private ItemStack itemStack; - private List hatList; - private UltraPlayer ultraPlayer; - - public HatReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.HAT, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - hatList.clear(); - } - - @Override - public boolean canEarn() { - hatList = new ArrayList<>(); - for (HatType type : HatType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - hatList.add(type); - return hatList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(hatList.size()); - HatType h = hatList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Hat").replace("%hat%", h.getName()); - itemStack = new MaterialData(h.getMaterial(), h.getData()).toItemStack(1); - givePermission(h.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.hat.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.hat.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.hat.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.hat.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%hat%", h.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/HelmetReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/HelmetReward.java deleted file mode 100644 index e5a3b382b..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/HelmetReward.java +++ /dev/null @@ -1,74 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot; -import be.isach.ultracosmetics.cosmetics.type.SuitType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A helmet reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class HelmetReward extends Reward { - private String name; - private ItemStack itemStack; - private List helmetList; - private UltraPlayer ultraPlayer; - - public HelmetReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.HELMET, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - helmetList.clear(); - } - - @Override - public boolean canEarn() { - helmetList = new ArrayList<>(); - for (SuitType type : SuitType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission(ArmorSlot.HELMET)) - && type.canBeFound()) - helmetList.add(type); - return helmetList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(helmetList.size()); - SuitType s = helmetList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Suit").replace("%suit%", s.getName()); - itemStack = new MaterialData(s.getMaterial(), s.getData()).toItemStack(1); - givePermission(s.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.suit.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.suit.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%suit%", s.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/LeggingReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/LeggingReward.java deleted file mode 100644 index 9f304baf3..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/LeggingReward.java +++ /dev/null @@ -1,74 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot; -import be.isach.ultracosmetics.cosmetics.type.SuitType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A legging reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class LeggingReward extends Reward { - private String name; - private ItemStack itemStack; - private List leggingList; - private UltraPlayer ultraPlayer; - - public LeggingReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.LEGGINGS, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - leggingList.clear(); - } - - @Override - public boolean canEarn() { - leggingList = new ArrayList<>(); - for (SuitType type : SuitType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission(ArmorSlot.LEGGINGS)) - && type.canBeFound()) - leggingList.add(type); - return leggingList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(leggingList.size()); - SuitType s = leggingList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Suit").replace("%suit%", s.getName()); - itemStack = new MaterialData(s.getMaterial(), s.getData()).toItemStack(1); - givePermission(s.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.suit.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.suit.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.suit.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%suit%", s.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MoneyReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MoneyReward.java deleted file mode 100644 index 6406b281a..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MoneyReward.java +++ /dev/null @@ -1,68 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.SettingsManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.player.UltraPlayer; -import be.isach.ultracosmetics.util.MathUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - - -/** - * A money reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class MoneyReward extends Reward { - private String name; - private ItemStack itemStack; - private UltraPlayer ultraPlayer; - private UltraCosmetics ultraCosmetics; - - public MoneyReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.MONEY, ultraCosmetics); - this.ultraCosmetics = ultraCosmetics; - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - } - - @Override - public boolean canEarn() { - return ultraCosmetics.getEconomy() != null; - } - - @Override - public void give() { - if (ultraCosmetics.getEconomy() == null) { - name = MessageManager.getMessage("Treasure-Chests-Loot.Nothing"); - itemStack = new ItemStack(Material.BARRIER); - return; - } - int money = MathUtils.randomRangeInt(20, (int) SettingsManager.getConfig().get("TreasureChests.Loots.Money.Max")); - name = MessageManager.getMessage("Treasure-Chests-Loot.Money").replace("%money%", money + ""); - ultraCosmetics.getEconomy().depositPlayer(ultraPlayer.getBukkitPlayer(), money); - itemStack = new ItemStack(Material.DOUBLE_PLANT); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.money.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.money.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.money.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.money.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%money%", money + "")); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MorphReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MorphReward.java deleted file mode 100644 index 389393b2e..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MorphReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.MorphType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A morph reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class MorphReward extends Reward { - private String name; - private ItemStack itemStack; - private List morphList; - private UltraPlayer ultraPlayer; - - public MorphReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.MORPH, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - morphList.clear(); - } - - @Override - public boolean canEarn() { - morphList = new ArrayList<>(); - for (MorphType type : MorphType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - morphList.add(type); - return morphList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(morphList.size()); - MorphType m = morphList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Morph").replace("%morph%", m.getName()); - itemStack = new MaterialData(m.getMaterial(), m.getData()).toItemStack(1); - givePermission(m.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.morph.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.morph.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.morph.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.morph.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%morph%", m.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MountReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MountReward.java deleted file mode 100644 index c55453d50..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/MountReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.MountType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A mount reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class MountReward extends Reward { - private String name; - private ItemStack itemStack; - private List mountList; - private UltraPlayer ultraPlayer; - - public MountReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.MOUNT, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - mountList.clear(); - } - - @Override - public boolean canEarn() { - mountList = new ArrayList<>(); - for (MountType type : MountType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - mountList.add(type); - return mountList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(mountList.size()); - MountType m = mountList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Mount").replace("%mount%", m.getName()); - itemStack = new MaterialData(m.getMaterial(), m.getData()).toItemStack(1); - givePermission(m.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.mount.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.mount.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.mount.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.mount.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%mount%", m.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/NothingReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/NothingReward.java deleted file mode 100644 index 8637212fd..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/NothingReward.java +++ /dev/null @@ -1,47 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -/** - * A "nothing" reward. - * - * @author RadBuilder - * @since 01-16-2017 - */ -public class NothingReward extends Reward { - private String name; - private ItemStack itemStack; - - public NothingReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.NOTHING, ultraCosmetics); - } - - @Override - public void clear() { - } - - @Override - public boolean canEarn() { - return true; - } - - @Override - public void give() { - name = MessageManager.getMessage("Treasure-Chests-Loot.Nothing"); - itemStack = new ItemStack(Material.BARRIER); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/ParticleEffectReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/ParticleEffectReward.java deleted file mode 100644 index e1b984afe..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/ParticleEffectReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.ParticleEffectType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A particle effect reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class ParticleEffectReward extends Reward { - private String name; - private ItemStack itemStack; - private List particleList; - private UltraPlayer ultraPlayer; - - public ParticleEffectReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.EFFECT, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - particleList.clear(); - } - - @Override - public boolean canEarn() { - particleList = new ArrayList<>(); - for (ParticleEffectType type : ParticleEffectType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - particleList.add(type); - return particleList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(particleList.size()); - ParticleEffectType p = particleList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Effect").replace("%effect%", p.getName()); - itemStack = new MaterialData(p.getMaterial(), p.getData()).toItemStack(1); - givePermission(p.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.effect.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.effect.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.effect.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.effect.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%effect%", p.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/PermissionReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/PermissionReward.java deleted file mode 100644 index e4f0de0bc..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/PermissionReward.java +++ /dev/null @@ -1,119 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -/** - * A permission reward. - * - * @author RadBuilder - * @since 01-16-2017 - */ -public class PermissionReward extends Reward { - private int chance; - private boolean chatMessage; - private String message; - private boolean permDisable; - private String disablePerm; - private boolean firework; - private String fireworkColor; - private List rewardCommands; - private boolean sound; - private String soundEffect; - private String name; - private UltraPlayer ultraPlayer; - - public PermissionReward(String key, UltraPlayer player, UltraCosmetics ultraCosmetics) { - super(player, RewardType.PERMISSION, ultraCosmetics); - this.name = key; - this.ultraPlayer = player; - key = "CustomRewards." + key; - chance = f().getInt(key + ".chance"); - chatMessage = f().getBoolean(key + ".chat-message.enabled"); - message = f().getString(key + ".chat-message.message"); - permDisable = f().getBoolean(key + ".disable-if-permission.enabled"); - disablePerm = f().getString(key + ".disable-if-permission.permission"); - firework = f().getBoolean(key + ".firework-effect.enabled"); - fireworkColor = f().getString(key + ".firework-effect.color"); - rewardCommands = f().getStringList(key + ".reward-commands"); - sound = f().getBoolean(key + ".sound.enabled"); - soundEffect = f().getString(key + ".sound.sound-effect"); - } - - public int getChance() { - return chance; - } - - public boolean displayChatMessage() { - return chatMessage; - } - - public String getChatMessage() { - return message; - } - - public boolean disableWithPerm() { - return permDisable; - } - - public String getDisablePerm() { - return disablePerm; - } - - public boolean launchFirework() { - return firework; - } - - public String getFireworkColor() { - return fireworkColor; - } - - public List rewardCommands() { - return rewardCommands; - } - - public boolean makeSound() { - return sound; - } - - public String getSound() { - return soundEffect; - } - - private YamlConfiguration f() { - return TreasureManager.getRewardFile(); - } - - @Override - public void clear() { - } - - @Override - public boolean canEarn() { - return !permDisable || !ultraPlayer.getBukkitPlayer().hasPermission(disablePerm); - } - - @Override - public void give() { - for (String rewardCommand : rewardCommands) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), rewardCommand.replace("{player-name}", ultraPlayer.getBukkitPlayer().getName()).replace("{player-uuid}", "" + ultraPlayer.getBukkitPlayer().getUniqueId())); - } - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return new ItemStack(Material.NETHER_STAR); - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/PetReward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/PetReward.java deleted file mode 100644 index 6a4752d4b..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/PetReward.java +++ /dev/null @@ -1,73 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.MessageManager; -import be.isach.ultracosmetics.config.TreasureManager; -import be.isach.ultracosmetics.cosmetics.type.PetType; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -/** - * A pet reward. - * - * @author RadBuilder - * @since 01-14-2017 - */ -public class PetReward extends Reward { - private String name; - private ItemStack itemStack; - private List petList; - private UltraPlayer ultraPlayer; - - public PetReward(UltraPlayer ultraPlayer, UltraCosmetics ultraCosmetics) { - super(ultraPlayer, RewardType.PET, ultraCosmetics); - this.ultraPlayer = ultraPlayer; - } - - @Override - public void clear() { - petList.clear(); - } - - @Override - public boolean canEarn() { - petList = new ArrayList<>(); - for (PetType type : PetType.values()) - if (type.isEnabled() - && !ultraPlayer.getBukkitPlayer().hasPermission(type.getPermission()) - && type.canBeFound()) - petList.add(type); - return petList.size() > 0; - } - - @Override - public void give() { - int i = new Random().nextInt(petList.size()); - PetType p = petList.get(i); - name = MessageManager.getMessage("Treasure-Chests-Loot.Pet").replace("%pet%", p.getName()); - itemStack = new MaterialData(p.getMaterial(), p.getData()).toItemStack(1); - givePermission(p.getPermission()); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.pet.firework-effect.enabled")) - super.firework(TreasureManager.getRewardFile().getString("UcRewards.pet.firework-effect.color")); - if (TreasureManager.getRewardFile().getBoolean("UcRewards.pet.chat-message.enabled")) - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', TreasureManager.getRewardFile().getString("UcRewards.pet.chat-message.message")).replace("%name%", ultraPlayer.getBukkitPlayer().getName()).replace("%pet%", p.getName())); - } - - @Override - public String getName() { - return name; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/Reward.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/Reward.java deleted file mode 100644 index c4f540ca5..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/Reward.java +++ /dev/null @@ -1,138 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.UltraCosmetics; -import be.isach.ultracosmetics.config.SettingsManager; -import be.isach.ultracosmetics.player.UltraPlayer; -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; -import org.bukkit.entity.Firework; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkMeta; - -/** - * @author RadBuilder - * @since 01-14-2017 - */ -public abstract class Reward { - private UltraPlayer player; - private UltraCosmetics ultraCosmetics; - private RewardType type; - - public Reward(UltraPlayer owner, RewardType type, UltraCosmetics ultraCosmetics) { - this.player = owner; - this.ultraCosmetics = ultraCosmetics; - this.type = type; - } - - /** - * Clears the list of possible rewards. - */ - public abstract void clear(); - - /** - * @return {@code true} if the {@link be.isach.ultracosmetics.tempchests.reward.RewardType RewardType} - * can be earned, {@code false} otherwise. - */ - public abstract boolean canEarn(); - - /** - * Gives the reward to the player. - */ - public abstract void give(); - - /** - * @return The reward name. - */ - public abstract String getName(); - - /** - * @return The reward ItemStack. - */ - public abstract ItemStack getItemStack(); - - /** - * @return Gets the RewardType. - */ - public RewardType getType() { - return type; - } - - /** - * @return Gets the player. - */ - public UltraPlayer getPlayer() { - return player; - } - - /** - * Spawns a firework at the player's location. - * - * @param color The color of the firework. - */ - public void firework(String color) { - final Firework f = player.getBukkitPlayer().getWorld().spawn(player.getBukkitPlayer().getLocation().clone().add(0.5, 0, 0.5), Firework.class); - FireworkMeta fm = f.getFireworkMeta(); - fm.addEffect(getRandomFireworkEffect(color)); - f.setFireworkMeta(fm); - - Bukkit.getScheduler().runTaskLater(ultraCosmetics, f::detonate, 2L); - } - - /** - * Gives a permission to a player using the {@code Permission-Add-Command} specified in the config. - * - * @param permission The permission to give to the player. - */ - public void givePermission(String permission) { - String command = SettingsManager.getConfig().getString("TreasureChests.Permission-Add-Command").replace("%name%", player.getBukkitPlayer().getName()).replace("%permission%", permission); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); - } - - private FireworkEffect getRandomFireworkEffect(String color) { - Color c = parseColor(color); - FireworkEffect.Builder builder = FireworkEffect.builder(); - return builder.flicker(false).trail(false).with(FireworkEffect.Type.BALL).withColor(c).withFade(c).build(); - } - - private Color parseColor(String color) { - switch (color.toLowerCase()) { - case "aqua": - return Color.AQUA; - case "black": - return Color.BLACK; - case "blue": - return Color.BLUE; - case "fuchsia": - return Color.FUCHSIA; - case "gray": - return Color.GRAY; - case "green": - return Color.GREEN; - case "lime": - return Color.LIME; - case "maroon": - return Color.MAROON; - case "navy": - return Color.NAVY; - case "olive": - return Color.OLIVE; - case "orange": - return Color.ORANGE; - case "purple": - return Color.PURPLE; - case "red": - return Color.RED; - case "silver": - return Color.SILVER; - case "teal": - return Color.TEAL; - case "white": - return Color.WHITE; - case "yellow": - return Color.YELLOW; - default: - throw new IllegalArgumentException("Invalid color recieved: \"" + color + "\"."); - } - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/RewardType.java b/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/RewardType.java deleted file mode 100644 index c1526e516..000000000 --- a/core/src/main/java/be/isach/ultracosmetics/tempchests/reward/RewardType.java +++ /dev/null @@ -1,35 +0,0 @@ -package be.isach.ultracosmetics.tempchests.reward; - -import be.isach.ultracosmetics.config.TreasureManager; - -public enum RewardType { - AMMO(TreasureManager.getRewardFile().getInt("UcRewards.gadget-ammo.chance")), - MONEY(TreasureManager.getRewardFile().getInt("UcRewards.money.chance")), - GADGET(TreasureManager.getRewardFile().getInt("UcRewards.gadget.chance")), - MORPH(TreasureManager.getRewardFile().getInt("UcRewards.morph.chance")), - PET(TreasureManager.getRewardFile().getInt("UcRewards.pet.chance")), - EFFECT(TreasureManager.getRewardFile().getInt("UcRewards.effect.chance")), - MOUNT(TreasureManager.getRewardFile().getInt("UcRewards.mount.chance")), - HAT(TreasureManager.getRewardFile().getInt("UcRewards.hat.chance")), - HELMET(TreasureManager.getRewardFile().getInt("UcRewards.suits.chance") / 4), - CHESTPLATE(TreasureManager.getRewardFile().getInt("UcRewards.suits.chance") / 4), - LEGGINGS(TreasureManager.getRewardFile().getInt("UcRewards.suits.chance") / 4), - BOOTS(TreasureManager.getRewardFile().getInt("UcRewards.suits.chance") / 4), - EMOTE(TreasureManager.getRewardFile().getInt("UcRewards.emote.chance")), - NOTHING(0), - PERMISSION(0); - - private int chance; - - RewardType(int chance) { - this.chance = chance; - } - - public int getChance() { - return chance; - } - - public void setChance(int chance) { - this.chance = chance; - } -} diff --git a/core/src/main/java/be/isach/ultracosmetics/treasurechests/TreasureRandomizer.java b/core/src/main/java/be/isach/ultracosmetics/treasurechests/TreasureRandomizer.java index b921705d4..d546a2196 100755 --- a/core/src/main/java/be/isach/ultracosmetics/treasurechests/TreasureRandomizer.java +++ b/core/src/main/java/be/isach/ultracosmetics/treasurechests/TreasureRandomizer.java @@ -393,7 +393,7 @@ public void clear() { } public void giveNothing() { - if (UltraCosmeticsData.get().isUsingVaultEconomy()) { + if (UltraCosmeticsData.get().getPlugin().getEconomyHandler().isUsingEconomy()) { try { giveMoney(); } catch (Exception e) { @@ -407,13 +407,13 @@ public void giveNothing() { } public void giveMoney() { - if (!UltraCosmeticsData.get().isUsingVaultEconomy()) { + if (!UltraCosmeticsData.get().getPlugin().getEconomyHandler().isUsingEconomy()) { giveNothing(); return; } int money = MathUtils.randomRangeInt(20, (int) SettingsManager.getConfig().get("TreasureChests.Loots.Money.Max")); name = MessageManager.getMessage("Treasure-Chests-Loot.Money").replace("%money%", money + ""); - UltraCosmeticsData.get().getPlugin().getEconomy().depositPlayer(player, money); + UltraCosmeticsData.get().getPlugin().getEconomyHandler().deposit(player, money); itemStack = new ItemStack(Material.DOUBLE_PLANT); if (money > 3 * (int) SettingsManager.getConfig().get("TreasureChests.Loots.Money.Max") / 4) spawnRandomFirework(loc); diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 8062c481c..9b3854bad 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -42,6 +42,10 @@ Categories: Emotes: Go-Back-Arrow: true Clear-Cosmetic-Item: '152:0' + +# The economy that should be used. Supports 'Vault' or 'PlayerPoints' +Economy: 'Vault' + # Treasure Chests Settings. # /uc reload will not be enough to toggle them! # diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b92ac6df6..aaac2eb4a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Aug 09 01:47:19 CEST 2016 +#Sat Nov 04 14:07:30 PDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip