diff --git a/src/main/java/com/night/nullvalkyrie/Items/CustomItemManager.java b/src/main/java/com/night/nullvalkyrie/Items/CustomItemManager.java index de83ecd..ec41430 100644 --- a/src/main/java/com/night/nullvalkyrie/Items/CustomItemManager.java +++ b/src/main/java/com/night/nullvalkyrie/Items/CustomItemManager.java @@ -162,7 +162,7 @@ public class CustomItemManager { } } - private static List getAllFilesFromDirectory(String path) { + public static List getAllFilesFromDirectory(String path) { ArrayList ns = new ArrayList<>(); try { File f = new File(main.getDataFolder(), path); diff --git a/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java b/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java index 2d6e823..8281c50 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java @@ -4,6 +4,7 @@ import com.night.nullvalkyrie.Items.CustomItemManager; import com.night.nullvalkyrie.Main; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.util.StringUtil; @@ -13,6 +14,9 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import static com.night.nullvalkyrie.Items.CustomItemManager.getAllFilesFromDirectory; +import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig; + public class WeaponCommand extends Command { private Main main; public WeaponCommand(Main main) { @@ -52,7 +56,13 @@ public class WeaponCommand extends Command { @Override public List onTabComplete(CommandSender sender, String[] args) { if(args.length == 1) { - return StringUtil.copyPartialMatches(args[0], Arrays.asList("Snow Gun", "Frag Grenade", "Widow Sword", "Terminator", "Explosive Bow", "Teleport Door", "Grappling Hook"), new ArrayList<>()); + List hh = getAllFilesFromDirectory("ItemData"); + ArrayList cc = new ArrayList<>(); + for(int kk = 0; kk < hh.size(); kk++) { + FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk)); + cc.add(c.getString("name")); + } + return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>()); } return new ArrayList<>(); }