From af72bfbbb61b7eb4c8de07fb270fe0946a145417 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 2 Sep 2021 10:24:30 +0100 Subject: [PATCH] Legacy base64 system has been removed in favour of the eco items system --- .../com/willfp/ecobosses/bosses/EcoBoss.java | 12 +++--- .../ecobosses/commands/CommandBase64.java | 41 ------------------- .../ecobosses/commands/CommandEcobosses.java | 1 - .../src/main/resources/bosses/alpha_wolf.yml | 3 +- .../main/resources/bosses/dark_guardian.yml | 3 +- .../src/main/resources/bosses/steel_golem.yml | 3 +- .../src/main/resources/bosses/tarantula.yml | 3 +- .../core-plugin/src/main/resources/plugin.yml | 5 --- 8 files changed, 10 insertions(+), 61 deletions(-) delete mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandBase64.java diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index b5094f1..1bde79d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap; import com.willfp.eco.core.EcoPlugin; import com.willfp.eco.core.PluginDependent; import com.willfp.eco.core.config.interfaces.Config; +import com.willfp.eco.core.items.Items; import com.willfp.eco.core.items.builder.ItemBuilder; import com.willfp.eco.core.items.builder.ItemStackBuilder; import com.willfp.eco.core.recipe.Recipes; @@ -329,13 +330,12 @@ public class EcoBoss extends PluginDependent { chance = Double.parseDouble(split[0]); string = split[1]; } - String tempConfigString = new String(Base64.getDecoder().decode(string)); - try { - tempConfig.loadFromString(tempConfigString); - } catch (InvalidConfigurationException e) { - e.printStackTrace(); + + ItemStack itemStack = Items.lookup(string).getItem(); + if (itemStack.getType() == Material.AIR) { + Bukkit.getLogger().warning(this.getName() + " has an invalid drop configured! (" + string + ")"); + continue; } - ItemStack itemStack = tempConfig.getItemStack("drop-key"); this.drops.put(itemStack, chance); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandBase64.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandBase64.java deleted file mode 100644 index 7dce25c..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandBase64.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.ecobosses.commands; - -import com.willfp.eco.core.command.CommandHandler; -import com.willfp.eco.core.command.impl.Subcommand; -import com.willfp.ecobosses.EcoBossesPlugin; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Base64; - -public class CommandBase64 extends Subcommand { - /** - * Instantiate a new executor for /ebdrop. - * - * @param plugin The plugin to manage the execution for. - */ - public CommandBase64(@NotNull final EcoBossesPlugin plugin) { - super(plugin, "base64", "ecobosses.command.base64", true); - } - - @Override - public CommandHandler getHandler() { - return (sender, args) -> { - Player player = (Player) sender; - ItemStack itemStack = player.getInventory().getItemInMainHand(); - String key = "drop-key"; - YamlConfiguration jank = new YamlConfiguration(); - jank.set(key, itemStack); - String configString = jank.saveToString(); - String dropString = Base64.getEncoder().encodeToString(configString.getBytes()); - - Bukkit.getLogger().info("Copy this into the drops section of your boss yml!"); - Bukkit.getLogger().info("\n" + dropString); - - player.sendMessage(this.getPlugin().getLangYml().getMessage("sent-drop")); - }; - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEcobosses.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEcobosses.java index 92ebf10..628aada 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEcobosses.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEcobosses.java @@ -16,7 +16,6 @@ public class CommandEcobosses extends PluginCommand { this.addSubcommand(new CommandReload(plugin)) .addSubcommand(new CommandKillall(plugin)) .addSubcommand(new CommandSpawn(plugin)) - .addSubcommand(new CommandBase64(plugin)) .addSubcommand(new CommandGive(plugin)); } diff --git a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml index 5ce7c5a..5542e0f 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml @@ -60,8 +60,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ecobosses base64 - # To set the chance for a drop, put :: + # To set the chance for a drop, put ::item drops: [] broadcast: diff --git a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml index 5180e08..a3f6c32 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml @@ -60,8 +60,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ecobosses base64 - # To set the chance for a drop, put :: + # To set the chance for a drop, put ::item drops: [] broadcast: diff --git a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml index 3399129..0e38d3c 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml @@ -60,8 +60,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ecobosses base64 - # To set the chance for a drop, put :: + # To set the chance for a drop, put ::item drops: [] broadcast: diff --git a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml index c087169..0704e32 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml @@ -60,8 +60,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ecobosses base64 - # To set the chance for a drop, put :: + # To set the chance for a drop, put ::item drops: [] broadcast: diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index a83f2a1..5f4310d 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -26,17 +26,12 @@ permissions: ecobosses.command.ecobosses: true ecobosses.command.reload: true ecobosses.command.spawn: true - ecobosses.command.base64: true ecobosses.command.give: true ecobosses.command.ecobosses: description: Allows the use of /ecobosses default: true - ecobosses.command.base64: - description: Allows the use of /ecobosses base64 - default: op - ecobosses.command.give: description: Allows the use of /ecobosses give default: op