Okay hey guys - I'm using a 667 source and I was developing a section of code in commands.java so that no staff can ban each other (because you know, you get that odd one who tries to ban other staff for fun) - and I tried banning myself, owner and I got banned haha. My code now works, tested it with another owner account and kills the player who tries banning staff - however, I found that my unban command doesn't work?
Here's the ban command and unban command:
::ban
[SPOIL]
Code:
if (cmd[0].equalsIgnoreCase("ban")) {
if (cmd[1].equalsIgnoreCase("Zodiac")) {
player.getPackets().sendGameMessage("Don't try ban me.");
}
if (cmd[1].equalsIgnoreCase("Callum")) {
player.getPackets().sendGameMessage("Don't bother.");
}
else {
String name = "";
for (int i = 1; i < cmd.length; i++)
name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
Player target = World.getPlayerByDisplayName(name);
if (target != null) {
target.setBanned(Utils.currentTimeMillis()
+ (48 * 60 * 60 * 1000));
target.getSession().getChannel().close();
player.getPackets().sendGameMessage("You have banned 48 hours: "+ target.getDisplayName() + ".");
} else {
player.getPackets().sendGameMessage("Couldn't find player " + name + ".");
}
try {
File file = new File("data/logs/ban.txt");
BufferedWriter writer = new BufferedWriter(new FileWriter(
file, true));
writer.write ("[" + DateFormat.getDateTimeInstance().format(new Date()) + "]" + player.getDisplayName() + " banned " + target.getDisplayName());
writer.newLine();
writer.flush();
} catch (IOException e) {A
e.printStackTrace();
}
return true;
[/SPOIL]
::unban
[SPOIL]
Code:
if (cmd[0].equalsIgnoreCase("unban")) {
String name = "";
for (int i = 1; i < cmd.length; i++)
name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
Player target = null;
if (target == null) {
target = SerializableFilesManager.loadPlayer(Utils.formatPlayerNameForProtocol(name));
player.setPermBanned(false);
player.setBanned(0);
SerializableFilesManager.savePlayer(target);
if (!IPBanL.getList().contains(player.getLastIP()))
player.getPackets().sendGameMessage("You unbanned "+ Utils.formatPlayerNameForProtocol(name) + ".", true);
else
player.getPackets().sendGameMessage("Something went wrong. Contact a developer.", true);
}
}
[/SPOIL]
And here's what's confusing me - it's notifying me saying "You have unbanned (playername) but it's still not working?
- Is it something to do with
Code:
player.setBanned(0);
Would that need to be changed to
Code:
player.setBanned(false);
Update:
Tried changing it from '0' to 'false' - compile error so no go. Any help?