totally dependent weapon command depending on what u added in the yml files now

This commit is contained in:
night0721 2022-07-12 21:38:51 +01:00
parent ecc4990117
commit bc588dac46
2 changed files with 12 additions and 2 deletions

View file

@ -162,7 +162,7 @@ public class CustomItemManager {
}
}
private static List<String> getAllFilesFromDirectory(String path) {
public static List<String> getAllFilesFromDirectory(String path) {
ArrayList<String> ns = new ArrayList<>();
try {
File f = new File(main.getDataFolder(), path);

View file

@ -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<String> 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<String> hh = getAllFilesFromDirectory("ItemData");
ArrayList<String> 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<>();
}