diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java index d24627d..9be7e5a 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java @@ -2,7 +2,7 @@ package com.willfp.ecobosses; import com.willfp.eco.core.AbstractPacketAdapter; import com.willfp.eco.core.EcoPlugin; -import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.command.impl.PluginCommand; import com.willfp.eco.core.integrations.IntegrationLoader; import com.willfp.ecobosses.bosses.EcoBosses; import com.willfp.ecobosses.bosses.listeners.AttackListeners; @@ -11,11 +11,8 @@ import com.willfp.ecobosses.bosses.listeners.DeathListeners; import com.willfp.ecobosses.bosses.listeners.PassiveListeners; import com.willfp.ecobosses.bosses.listeners.SpawnListeners; import com.willfp.ecobosses.bosses.util.BossUtils; -import com.willfp.ecobosses.commands.CommandEbdrop; -import com.willfp.ecobosses.commands.CommandEbkillall; -import com.willfp.ecobosses.commands.CommandEbreload; -import com.willfp.ecobosses.commands.CommandEbspawn; -import com.willfp.ecobosses.commands.TabCompleterEbspawn; +import com.willfp.ecobosses.commands.CommandEcobosses; +import com.willfp.ecobosses.commands.CommandSpawn; import lombok.Getter; import org.bukkit.event.Listener; @@ -98,18 +95,10 @@ public class EcoBossesPlugin extends EcoPlugin { return new ArrayList<>(); } - /** - * EcoEnchants-specific commands. - * - * @return A list of all commands. - */ @Override - public List getCommands() { + public List getPluginCommands() { return Arrays.asList( - new CommandEbreload(this), - new CommandEbdrop(this), - new CommandEbspawn(this), - new CommandEbkillall(this) + new CommandEcobosses(this) ); } @@ -142,7 +131,7 @@ public class EcoBossesPlugin extends EcoPlugin { public List> getUpdatableClasses() { return Arrays.asList( EcoBosses.class, - TabCompleterEbspawn.class + CommandSpawn.class ); } 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 4b5c909..27b57a4 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 @@ -10,10 +10,19 @@ import com.willfp.ecobosses.bosses.effects.Effect; import com.willfp.ecobosses.bosses.effects.Effects; import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils; import com.willfp.ecobosses.bosses.util.bosstype.BossType; -import com.willfp.ecobosses.bosses.util.obj.*; +import com.willfp.ecobosses.bosses.util.obj.BossbarProperties; +import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions; +import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions; +import com.willfp.ecobosses.bosses.util.obj.OptionedSound; +import com.willfp.ecobosses.bosses.util.obj.SpawnTotem; +import com.willfp.ecobosses.bosses.util.obj.TargetMode; import lombok.AccessLevel; import lombok.Getter; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.configuration.InvalidConfigurationException; @@ -23,7 +32,14 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; import java.util.stream.Collectors; public class EcoBoss extends PluginDependent { 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 new file mode 100644 index 0000000..7dce25c --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandBase64.java @@ -0,0 +1,41 @@ +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/CommandEbdrop.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbdrop.java deleted file mode 100644 index c0d6ff1..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbdrop.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.willfp.ecobosses.commands; - -import com.willfp.eco.core.command.AbstractCommand; -import com.willfp.ecobosses.EcoBossesPlugin; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.List; - -public class CommandEbdrop extends AbstractCommand { - /** - * Instantiate a new executor for /ebdrop. - * - * @param plugin The plugin to manage the execution for. - */ - public CommandEbdrop(@NotNull final EcoBossesPlugin plugin) { - super(plugin, "ebdrop", "ecobosses.ebdrop", true); - } - - @Override - public void onExecute(@NotNull final CommandSender sender, - @NotNull final List 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(StandardCharsets.UTF_8)); - - 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/CommandEbkillall.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbkillall.java deleted file mode 100644 index 6154d0f..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbkillall.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecobosses.commands; - -import com.willfp.eco.core.command.AbstractCommand; -import com.willfp.ecobosses.EcoBossesPlugin; -import com.willfp.ecobosses.bosses.util.BossUtils; -import org.bukkit.command.CommandSender; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class CommandEbkillall extends AbstractCommand { - /** - * Instantiate a new executor for /ebspawn. - * - * @param plugin The plugin to manage the execution for. - */ - public CommandEbkillall(@NotNull final EcoBossesPlugin plugin) { - super(plugin, "ebkillall", "ecobosses.killall", false); - } - - @Override - public void onExecute(@NotNull final CommandSender sender, - @NotNull final List args) { - boolean force = false; - if (args.size() == 1) { - force = args.get(0).equalsIgnoreCase("force"); - } - - sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses(force)))); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbreload.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbreload.java deleted file mode 100644 index 071e0aa..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbreload.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.willfp.ecobosses.commands; - -import com.willfp.eco.core.command.AbstractCommand; -import com.willfp.ecobosses.EcoBossesPlugin; -import org.bukkit.command.CommandSender; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class CommandEbreload extends AbstractCommand { - /** - * Instantiate a new executor for /ebreload. - * - * @param plugin The plugin to manage the execution for. - */ - public CommandEbreload(@NotNull final EcoBossesPlugin plugin) { - super(plugin, "ebreload", "ecobosses.reload", false); - } - - @Override - public void onExecute(@NotNull final CommandSender sender, - @NotNull final List args) { - this.getPlugin().reload(); - this.getPlugin().reload(); - sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded")); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbspawn.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbspawn.java deleted file mode 100644 index 33687f4..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEbspawn.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.willfp.ecobosses.commands; - -import com.willfp.eco.core.command.AbstractCommand; -import com.willfp.eco.core.command.AbstractTabCompleter; -import com.willfp.ecobosses.EcoBossesPlugin; -import com.willfp.ecobosses.bosses.EcoBoss; -import com.willfp.ecobosses.bosses.EcoBosses; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class CommandEbspawn extends AbstractCommand { - /** - * Instantiate a new executor for /ebspawn. - * - * @param plugin The plugin to manage the execution for. - */ - public CommandEbspawn(@NotNull final EcoBossesPlugin plugin) { - super(plugin, "ebspawn", "ecobosses.ebspawn", false); - } - - @Override - @Nullable - public AbstractTabCompleter getTab() { - return new TabCompleterEbspawn(this); - } - - @Override - public void onExecute(@NotNull final CommandSender sender, - @NotNull final List args) { - if (args.isEmpty()) { - sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss")); - return; - } - - String bossName = args.get(0); - - EcoBoss boss = EcoBosses.getByName(bossName.toLowerCase()); - - if (boss == null) { - sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss")); - return; - } - - Location location = null; - - if (sender instanceof Player) { - location = ((Player) sender).getLocation(); - } - - if (args.size() >= 4) { - String xString = args.get(1); - String yString = args.get(2); - String zString = args.get(3); - - double xPos; - double yPos; - double zPos; - - if (xString.startsWith("~") && sender instanceof Player) { - String xDiff = xString.replace("~", ""); - String yDiff = yString.replace("~", ""); - String zDiff = zString.replace("~", ""); - - if (xDiff.isEmpty()) { - xPos = ((Player) sender).getLocation().getX(); - } else { - try { - xPos = ((Player) sender).getLocation().getX() + Double.parseDouble(xDiff); - } catch (NumberFormatException e) { - xPos = ((Player) sender).getLocation().getX(); - } - } - - if (yDiff.isEmpty()) { - yPos = ((Player) sender).getLocation().getY(); - } else { - try { - yPos = ((Player) sender).getLocation().getY() + Double.parseDouble(yDiff); - } catch (NumberFormatException e) { - yPos = ((Player) sender).getLocation().getY(); - } - } - - if (zDiff.isEmpty()) { - zPos = ((Player) sender).getLocation().getZ(); - } else { - try { - zPos = ((Player) sender).getLocation().getZ() + Double.parseDouble(yDiff); - } catch (NumberFormatException e) { - zPos = ((Player) sender).getLocation().getZ(); - } - } - } else { - try { - xPos = Double.parseDouble(xString); - yPos = Double.parseDouble(yString); - zPos = Double.parseDouble(zString); - } catch (NumberFormatException e) { - sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location")); - return; - } - } - - location = new Location(null, xPos, yPos, zPos); - } - - World world = null; - if (sender instanceof Player) { - world = ((Player) sender).getWorld(); - } - - if (args.size() >= 5) { - world = Bukkit.getWorld(args.get(4)); - } - - if (location == null) { - sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location")); - return; - } - - location.setWorld(world); - - if (world == null) { - sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-world")); - return; - } - - boss.spawn(location); - sender.sendMessage(this.getPlugin().getLangYml().getMessage("spawned")); - } -} 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 new file mode 100644 index 0000000..1398341 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandEcobosses.java @@ -0,0 +1,28 @@ +package com.willfp.ecobosses.commands; + +import com.willfp.eco.core.command.CommandHandler; +import com.willfp.eco.core.command.impl.PluginCommand; +import com.willfp.ecobosses.EcoBossesPlugin; +import org.jetbrains.annotations.NotNull; + +public class CommandEcobosses extends PluginCommand { + /** + * Instantiate a new executor for /ebdrop. + * + * @param plugin The plugin to manage the execution for. + */ + public CommandEcobosses(@NotNull final EcoBossesPlugin plugin) { + super(plugin, "ecobosses", "ecobosses.command.ecobosses", true); + this.addSubcommand(new CommandReload(plugin)) + .addSubcommand(new CommandKillall(plugin)) + .addSubcommand(new CommandSpawn(plugin)) + .addSubcommand(new CommandBase64(plugin)); + } + + @Override + public CommandHandler getHandler() { + return (sender, args) -> { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-command")); + }; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandKillall.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandKillall.java new file mode 100644 index 0000000..d49c5dd --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandKillall.java @@ -0,0 +1,30 @@ +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 com.willfp.ecobosses.bosses.util.BossUtils; +import org.jetbrains.annotations.NotNull; + +public class CommandKillall extends Subcommand { + /** + * Instantiate a new executor for /ebspawn. + * + * @param plugin The plugin to manage the execution for. + */ + public CommandKillall(@NotNull final EcoBossesPlugin plugin) { + super(plugin, "killall", "ecobosses.command.killall", false); + } + + @Override + public CommandHandler getHandler() { + return (sender, args) -> { + boolean force = false; + if (args.size() == 1) { + force = args.get(0).equalsIgnoreCase("force"); + } + + sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses(force)))); + }; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandReload.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandReload.java new file mode 100644 index 0000000..42ef30b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandReload.java @@ -0,0 +1,26 @@ +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.jetbrains.annotations.NotNull; + +public class CommandReload extends Subcommand { + /** + * Instantiate a new executor for /ebreload. + * + * @param plugin The plugin to manage the execution for. + */ + public CommandReload(@NotNull final EcoBossesPlugin plugin) { + super(plugin, "reload", "ecobosses.command.reload", false); + } + + @Override + public CommandHandler getHandler() { + return (sender, args) -> { + this.getPlugin().reload(); + this.getPlugin().reload(); + sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded")); + }; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandSpawn.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandSpawn.java new file mode 100644 index 0000000..4bece1f --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/CommandSpawn.java @@ -0,0 +1,210 @@ +package com.willfp.ecobosses.commands; + +import com.willfp.eco.core.command.CommandHandler; +import com.willfp.eco.core.command.TabCompleteHandler; +import com.willfp.eco.core.command.impl.Subcommand; +import com.willfp.eco.core.config.ConfigUpdater; +import com.willfp.ecobosses.EcoBossesPlugin; +import com.willfp.ecobosses.bosses.EcoBoss; +import com.willfp.ecobosses.bosses.EcoBosses; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class CommandSpawn extends Subcommand { + /** + * The cached names. + */ + private static final List BOSS_NAMES = new ArrayList<>(); + + /** + * The cached numbers. + */ + private static final List TILDE = Arrays.asList( + "~" + ); + + /** + * Instantiate a new executor for /ebspawn. + * + * @param plugin The plugin to manage the execution for. + */ + public CommandSpawn(@NotNull final EcoBossesPlugin plugin) { + super(plugin, "spawn", "ecobosses.command.spawn", false); + reload(); + } + + /** + * Called on reload. + */ + @ConfigUpdater + public static void reload() { + BOSS_NAMES.clear(); + BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList())); + } + + @Override + public CommandHandler getHandler() { + return (sender, args) -> { + if (args.isEmpty()) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss")); + return; + } + + String bossName = args.get(0); + + EcoBoss boss = EcoBosses.getByName(bossName.toLowerCase()); + + if (boss == null) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss")); + return; + } + + Location location = null; + + if (sender instanceof Player) { + location = ((Player) sender).getLocation(); + } + + if (args.size() >= 4) { + String xString = args.get(1); + String yString = args.get(2); + String zString = args.get(3); + + double xPos; + double yPos; + double zPos; + + if (xString.startsWith("~") && sender instanceof Player) { + String xDiff = xString.replace("~", ""); + String yDiff = yString.replace("~", ""); + String zDiff = zString.replace("~", ""); + + if (xDiff.isEmpty()) { + xPos = ((Player) sender).getLocation().getX(); + } else { + try { + xPos = ((Player) sender).getLocation().getX() + Double.parseDouble(xDiff); + } catch (NumberFormatException e) { + xPos = ((Player) sender).getLocation().getX(); + } + } + + if (yDiff.isEmpty()) { + yPos = ((Player) sender).getLocation().getY(); + } else { + try { + yPos = ((Player) sender).getLocation().getY() + Double.parseDouble(yDiff); + } catch (NumberFormatException e) { + yPos = ((Player) sender).getLocation().getY(); + } + } + + if (zDiff.isEmpty()) { + zPos = ((Player) sender).getLocation().getZ(); + } else { + try { + zPos = ((Player) sender).getLocation().getZ() + Double.parseDouble(yDiff); + } catch (NumberFormatException e) { + zPos = ((Player) sender).getLocation().getZ(); + } + } + } else { + try { + xPos = Double.parseDouble(xString); + yPos = Double.parseDouble(yString); + zPos = Double.parseDouble(zString); + } catch (NumberFormatException e) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location")); + return; + } + } + + location = new Location(null, xPos, yPos, zPos); + } + + World world = null; + if (sender instanceof Player) { + world = ((Player) sender).getWorld(); + } + + if (args.size() >= 5) { + world = Bukkit.getWorld(args.get(4)); + } + + if (location == null) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location")); + return; + } + + location.setWorld(world); + + if (world == null) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-world")); + return; + } + + boss.spawn(location); + sender.sendMessage(this.getPlugin().getLangYml().getMessage("spawned")); + }; + } + + @Override + public TabCompleteHandler getTabCompleter() { + return (sender, args) -> { + + List completions = new ArrayList<>(); + + if (args.isEmpty()) { + // Currently, this case is not ever reached + return new ArrayList<>(); + } + + if (args.size() == 1) { + StringUtil.copyPartialMatches(args.get(0), BOSS_NAMES, completions); + + Collections.sort(completions); + return completions; + } + + if (args.size() == 2) { + StringUtil.copyPartialMatches(args.get(1), TILDE, completions); + + Collections.sort(completions); + return completions; + } + + if (args.size() == 3) { + StringUtil.copyPartialMatches(args.get(2), TILDE, completions); + + Collections.sort(completions); + return completions; + } + + if (args.size() == 4) { + StringUtil.copyPartialMatches(args.get(3), TILDE, completions); + + Collections.sort(completions); + return completions; + } + + if (args.size() == 5) { + StringUtil.copyPartialMatches(args.get(4), Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), completions); + + Collections.sort(completions); + return completions; + } + + return new ArrayList<>(0); + }; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/TabCompleterEbspawn.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/TabCompleterEbspawn.java deleted file mode 100644 index 27a3d29..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/commands/TabCompleterEbspawn.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.willfp.ecobosses.commands; - -import com.willfp.eco.core.command.AbstractTabCompleter; -import com.willfp.eco.core.config.ConfigUpdater; -import com.willfp.ecobosses.bosses.EcoBoss; -import com.willfp.ecobosses.bosses.EcoBosses; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -public class TabCompleterEbspawn extends AbstractTabCompleter { - /** - * The cached names. - */ - private static final List BOSS_NAMES = new ArrayList<>(); - - /** - * The cached numbers. - */ - private static final List TILDE = Arrays.asList( - "~" - ); - - /** - * Instantiate a new tab-completer for /ebspawn. - * - * @param command Instance of /ebspawn. - */ - public TabCompleterEbspawn(@NotNull final CommandEbspawn command) { - super(command); - reload(); - } - - /** - * Called on reload. - */ - @ConfigUpdater - public static void reload() { - BOSS_NAMES.clear(); - BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList())); - } - - /** - * The execution of the tabcompleter. - * - * @param sender The sender of the command. - * @param args The arguments of the command. - * @return A list of tab-completions. - */ - @Override - public List onTab(@NotNull final CommandSender sender, - @NotNull final List args) { - List completions = new ArrayList<>(); - - if (args.isEmpty()) { - // Currently, this case is not ever reached - return new ArrayList<>(); - } - - if (args.size() == 1) { - StringUtil.copyPartialMatches(args.get(0), BOSS_NAMES, completions); - - Collections.sort(completions); - return completions; - } - - if (args.size() == 2) { - StringUtil.copyPartialMatches(args.get(1), TILDE, completions); - - Collections.sort(completions); - return completions; - } - - if (args.size() == 3) { - StringUtil.copyPartialMatches(args.get(2), TILDE, completions); - - Collections.sort(completions); - return completions; - } - - if (args.size() == 4) { - StringUtil.copyPartialMatches(args.get(3), TILDE, completions); - - Collections.sort(completions); - return completions; - } - - if (args.size() == 5) { - StringUtil.copyPartialMatches(args.get(4), Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), completions); - - Collections.sort(completions); - return completions; - } - - return new ArrayList<>(0); - } -} 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 b1207c7..e7f192e 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 @@ -38,7 +38,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ebdrop + # Get items to add here by copying the console output for /ecobosses base64 # To set the chance for a drop, put :: drops: [] diff --git a/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml b/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml index 29f67d9..ced3373 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/illusioner.yml @@ -38,7 +38,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ebdrop + # Get items to add here by copying the console output for /ecobosses base64 # To set the chance for a drop, put :: drops: [] 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 33c5c33..f2b9c09 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 @@ -38,7 +38,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ebdrop + # Get items to add here by copying the console output for /ecobosses base64 # To set the chance for a drop, put :: drops: [] 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 e6f9e7b..53b32ab 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml @@ -38,7 +38,7 @@ rewards: # Use %player% as the placeholder for the player name commands: [] - # Get items to add here by copying the console output for /ebdrop + # Get items to add here by copying the console output for /ecobosses base64 # To set the chance for a drop, put :: drops: [] diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index e6c6c3b..03d0ab1 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -1,6 +1,7 @@ messages: prefix: "&9&lEcoBosses &f» " no-permission: "&cYou don't have permission to do this!" + invalid-command: "&cUnknown subcommand!" not-player: "&cThis command must be run by a player" reloaded: "Reloaded!" sent-drop: "Check console for the drop!" diff --git a/gradle.properties b/gradle.properties index a49a851..a5aee30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 5.1.4 +version = 5.2.0 plugin-name = EcoBosses \ No newline at end of file