|
Post by santaclaus on Aug 4, 2006 15:48:20 GMT -5
public boolean banned(String host) { try { BufferedReader in = new BufferedReader(new FileReader("data/bannedusers.dat")); String data = null; while ((data = in.readLine()) != null) { if (host.equalsIgnoreCase(data)) { return true; } } } catch (IOException e) { System.out.println("Unable to bann player"); e.printStackTrace(); } return false; }
Now voids: Code:
public void appendToBanned (String player) { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter("data/bannedusers.dat", true)); bw.write(player); bw.newLine(); bw.flush(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { if (bw != null) try { bw.close(); } catch (IOException ioe2) { sendMessage("Unable to bann user"); } } }
Now commands: Code:
else if(command.startsWith("pbann") && command.length() > 4){ String player = command.substring(4); PlayerHandler.kickNick = player; player = player.replace(" ", "_"); PlayerHander.messageToAll = player + " has been smoked by Mod " +playerName+; appendToBanned(player); }
This makes spaces and underlines make no difference: Search for: Code:
PlayerSave loadgame = loadGame(playerName, playerPass);
Above it put this: Code:
String fname = playerName.replace(" ","_"); if(banned(fname)) { returnCode = 4; playerName = "_"; disconnected = true; teleportToX = 10000; teleportToY = 10000; actionTimer == 5; }
Now :bann + player name banns the player.
Edit: don't forget to make banned data folder
|
|
|
Post by gamerguy3379 on Aug 5, 2006 17:36:29 GMT -5
lawl
|
|
|
Post by santaclaus on Sept 9, 2006 16:18:25 GMT -5
l0l
|
|
|
Post by Juicy on Jan 27, 2007 11:19:13 GMT -5
lol
|
|