diff --git a/src/main/java/info/itsthesky/itemcreator/ItemCreator.java b/src/main/java/info/itsthesky/itemcreator/ItemCreator.java index 054343b..6f6ed0d 100644 --- a/src/main/java/info/itsthesky/itemcreator/ItemCreator.java +++ b/src/main/java/info/itsthesky/itemcreator/ItemCreator.java @@ -62,6 +62,7 @@ public void onEnable() { getServer().getPluginManager().registerEvents(new MainListener(this), this); getCommand("itemcreator").setExecutor(new CreatorCommand()); + getCommand("itemcreator").setTabCompleter(new CreatorCommand()); getLogger().info("ItemCreator as been loaded!"); } diff --git a/src/main/java/info/itsthesky/itemcreator/core/CreatorCommand.java b/src/main/java/info/itsthesky/itemcreator/core/CreatorCommand.java index 0176f00..6735b03 100644 --- a/src/main/java/info/itsthesky/itemcreator/core/CreatorCommand.java +++ b/src/main/java/info/itsthesky/itemcreator/core/CreatorCommand.java @@ -11,11 +11,15 @@ import org.bukkit.command.TabCompleter; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Locale; +import java.util.stream.Collectors; public class CreatorCommand implements CommandExecutor, TabCompleter { @@ -65,24 +69,61 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command sender.sendMessage(Utils.colored("&6List of enchantments &e("+ Enchantment.values().length +")&6:")); for (Enchantment enchantment : Enchantment.values()) sender.sendMessage(Utils.colored(" &6→ &e" + - WordUtils.capitalize(enchantment.getKey().getKey().replace('_', ' ').toLowerCase(Locale.ENGLISH)) + WordUtils.capitalize(enchantment.getKey().getKey().replace('_', ' ').toLowerCase(Locale.ENGLISH)) + " &7(ID: "+enchantment.getName()+")")); return true; } + case "potion_effects" -> { + sender.sendMessage(Utils.colored("&6List of Potion Effects &e("+ PotionEffectType.values().length +")&6:")); + for (PotionEffectType enchantment : PotionEffectType.values()) + sender.sendMessage(Utils.colored(" &6→ &e" + + WordUtils.capitalize(enchantment.getName().replace('_', ' ').toLowerCase(Locale.ENGLISH)) + + " &7(ID: "+enchantment.getId()+")")); + return true; + } } } } - + sendHelp(sender); return true; } public void sendHelp(CommandSender sender) { - + sender.sendMessage(Utils.colored("&6&lItemCreator &ev" + ItemCreator.getInstance().getDescription().getVersion() + + "&e made by &6ItsTheSky#1234:")); + sender.sendMessage( + Utils.colored("&1"), + Utils.colored("&6/ic help &7- &eShow this help page"), + Utils.colored("&6/ic get &7- &eGet the specified custom item"), + Utils.colored("&6/ic menu &7- &eOpen the main ItemCreator menu"), + Utils.colored("&6/ic list (enchantments|potion_effects) &7- &eList possible values of enumeration"), + Utils.colored("&1") + ); } @Override public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { - return null; + final List completions = new ArrayList<>(); + if (args.length == 1) + completions.addAll(Arrays.asList("help", "get", "menu", "list")); + else { + if (args.length == 2) { + switch (args[0]) { + case "get": + completions.addAll(ItemCreator + .getInstance() + .getApi() + .loadAllItems() + .stream() + .map(CustomItem::getId) + .toList()); + break; + case "list": + completions.addAll(Arrays.asList("enchantments", "potion_effects")); + } + } + } + return completions; } }