totally dependent weapon command depending on what u added in the yml files now
This commit is contained in:
parent
ecc4990117
commit
bc588dac46
2 changed files with 12 additions and 2 deletions
|
@ -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<>();
|
ArrayList<String> ns = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
File f = new File(main.getDataFolder(), path);
|
File f = new File(main.getDataFolder(), path);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.night.nullvalkyrie.Items.CustomItemManager;
|
||||||
import com.night.nullvalkyrie.Main;
|
import com.night.nullvalkyrie.Main;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
@ -13,6 +14,9 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
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 {
|
public class WeaponCommand extends Command {
|
||||||
private Main main;
|
private Main main;
|
||||||
public WeaponCommand(Main main) {
|
public WeaponCommand(Main main) {
|
||||||
|
@ -52,7 +56,13 @@ public class WeaponCommand extends Command {
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
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<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue