So currently I am making a plugin to remake mineplex features, and I got stuck when I got to bans, because I was trying to make it so that when you ban someone it puts a string in config with their name which you said in args, & then the string would have a value of "banned".. However when I do the command it says the message, gives me an internal error, and doesn't set thing string, anyone know why? (The error is on getConfig.set)
if (cmd.getName().equalsIgnoreCase("ban")) {
Player p = Bukkit.getPlayer(args[0]);
if (args.length == 0) {
sender.sendMessage("&9GWEN> &7Specify a player to ban");
} else {
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',
"&9GWEN> &7" + args[0] + " &7has been banned. I am always watching."));
getConfig().set(p.getName(), "banned");
if(!(p == null)) {
p.kickPlayer("You have been banned by a mod");
}
}
}
UPDATE: So I redid the code, here is the new code.. No errors but it doesnt change the config
Player p = Bukkit.getPlayer(args[0]);
if (args.length == 0) {
sender.sendMessage("&9GWEN> &7Specify a player to ban");
} else {
if(!(p == null)) {
p.kickPlayer("You have been banned by a mod");
}
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',
"&9GWEN> &7" + args[0] + " &7has been banned. I am always watching."));
this.getConfig().set(args[0], "banned");
saveDefaultConfig();
}
}```