Code:
@Override
public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args) {
Player player = (Player)sender;
if(cmd.getName().equalsIgnoreCase("ban")) {
if(args.length == 1) {
Player pto = Bukkit.getPlayer(args[0]);
try {
PreparedStatement q = sql.getConnection().prepareStatement("INSERT INTO bandef(uuid,modo,date) VALUES (?,?,now())");
q.setString(1, pto.getUniqueId().toString());
q.setString(2, player.getName().toString());
q.execute();
q.close();
pto.kickPlayer(ChatColor.RED + "Vous avez été bannis définitivement par " + player.getName() + "." + ChatColor.GRAY + "\nSi vous ne savez pas pourquoi, demander de l'aide sur Discord.");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
player.sendMessage("§4[AdminTools]§rLe joueur " + pto.getName() + "à bien été bannis définitivement.");
}
}
else if(cmd.getName().equalsIgnoreCase("rl") || cmd.getName().equalsIgnoreCase("reload")) {
for (Player all : Bukkit.getServer().getOnlinePlayers()){
all.kickPlayer("§1Le serveur redémarre./n§rL'accès sera à nouveau disponible dans quelques instants.");
}
getServer().reload();
}
else if(cmd.getName().equalsIgnoreCase("op")) {
player.sendMessage("§4[AdminTools]§rCette commande a été désactiver.");
}
return false;
}
Code:
Unexpected exception while parsing console command "rl"
org.bukkit.command.CommandException: Unhandled exception executing command 'rl' in plugin AdminTools v1.0.4
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_12_R1.command.ColouredConsoleSender cannot be cast to org.bukkit.entity.Player
at eu.heroria.iceorange92.admintools.Main.onCommand(Main.java:163) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.12.2.jar:git-Spigot-4bd94dc-bdcc7c7]
... 8 more
PS: la ligne 163 c'est la définition de la variable player.
EDIT: j'ai essayer de créer une commande /ban qui ne faisait rien, mais j'ai eu le même message d'erreur.