Add saveConfig() and filter-config value

This commit is contained in:
marc-go
2026-01-07 15:05:05 +01:00
parent 6b263e0e8b
commit 9814a58ea6
2 changed files with 40 additions and 18 deletions

View File

@@ -19,7 +19,11 @@ public final class AdvancedKill extends JavaPlugin {
saveDefaultConfig(); saveDefaultConfig();
getCommand("akill").setExecutor(this); getCommand("akill").setExecutor(this);
getCommand("afilter").setExecutor(new AdvancedKillFilter());
if (getConfig().getBoolean("filter-player")) {
getCommand("afilter").setExecutor(new AdvancedKillFilter(this));
}
getLogger().info("AdvancedKill was loaded!"); getLogger().info("AdvancedKill was loaded!");
} }
@@ -110,21 +114,32 @@ public final class AdvancedKill extends JavaPlugin {
//Completions //Completions
@Override @Override
public @Nullable List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public @Nullable List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
List<String> completions = new ArrayList<>(); List<String> completions = new ArrayList<>();
if (sender.hasPermission("akill.use")) {
if (args.length == 1) {
completions.add("lightning");
completions.add("void");
completions.add("zombie");
completions.add("half");
completions.add("anvil");
completions.add("explosion");
completions.add("fall");
completions.add("lava");
}
if (args.length == 2) { if (label.equals("akill")) {
if (sender.hasPermission("akill.use")) {
if (args.length == 1) {
completions.add("lightning");
completions.add("void");
completions.add("zombie");
completions.add("half");
completions.add("anvil");
completions.add("explosion");
completions.add("fall");
completions.add("lava");
}
if (args.length == 2) {
for (Player player : Bukkit.getOnlinePlayers()) {
completions.add(player.getName());
}
}
}
}
if (label.equals("afilter")) {
if (args.length == 1) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
completions.add(player.getName()); completions.add(player.getName());
} }

View File

@@ -2,13 +2,19 @@ package de.marc.advancedKill;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
public class AdvancedKillFilter extends JavaPlugin { public class AdvancedKillFilter implements CommandExecutor {
private AdvancedKill plugin;
public AdvancedKillFilter(AdvancedKill plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("akill.admin")) { if (!sender.hasPermission("akill.admin")) {
sender.sendMessage("§cPermission denied!"); sender.sendMessage("§cPermission denied!");
@@ -24,7 +30,7 @@ public class AdvancedKillFilter extends JavaPlugin {
String uuid = target.getUniqueId().toString(); String uuid = target.getUniqueId().toString();
List<String> players = getConfig().getStringList("bypass-players"); List<String> players = plugin.getConfig().getStringList("bypass-players");
String msg = ""; String msg = "";
@@ -36,7 +42,8 @@ public class AdvancedKillFilter extends JavaPlugin {
msg = "§aPlayer was added successfully!"; msg = "§aPlayer was added successfully!";
} }
getConfig().set("bypass-players", players); plugin.getConfig().set("bypass-players", players);
plugin.saveConfig();
sender.sendMessage(msg); sender.sendMessage(msg);