If the name gets added to the file, but the player can still talk, then you're probably missing the following check in Chat.java
Below:
Code:
public void processPacket(Client c, int packetType, int packetSize) {
c.setChatTextEffects(c.getInStream().readUnsignedByteS());
c.setChatTextColor(c.getInStream().readUnsignedByteS());
c.setChatTextSize((byte)(c.packetSize - 2));
c.inStream.readBytes_reverseA(c.getChatText(), c.getChatTextSize(), 0);
Add:
Code:
if (!Connection.isMuted(c)){
lastUser = c.playerName;
lastMessage = Misc.textUnpack(c.getChatText(), c.getChatTextSize());
newMessage = true;
c.setChatTextUpdateRequired(true);
}
If it's not being added to the file, make sure the path to the file in Connection.java is correct.
Make sure you have the following methods in Connection.java
Code:
public static void muteUsers() {
try {
BufferedReader in = new BufferedReader(new FileReader("./Data/bans/UsersMuted.txt"));
String data = null;
try {
while ((data = in.readLine()) != null) {
mutedNames.add(data);
}
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Under:
Code:
public static void initialize() {
Code:
public static void addNameToMuteList(String name) {
mutedNames.add(name.toLowerCase());
addUserToFile(name);
}
Code:
public static void addUserToFile(String Name) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter("###PATH TO UsersMuted.txt###", true));
try {
out.newLine();
out.write(Name);
} finally {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
End finally, here's my ::mute command.
Code:
if (playerCommand.startsWith("mute") || playerCommand.startsWith("Mute") || playerCommand.startsWith("MUTE")) {
try {
String playerToBan = playerCommand.substring(5);
Connection.addNameToMuteList(playerToBan);
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(Server.playerHandler.players[i] != null) {
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
Client c2 = (Client)Server.playerHandler.players[i];
c2.sendMessage("You have been muted by: " + c.playerName+".");
c.sendMessage("You have muted: " + c2.playerName+".");
break;
}
}
}
} catch(Exception e) {
c.sendMessage("Player Must Be Offline.");
}
}
To clear a little thing up, "muteUsers();" needs to be in method "public static void initialize() {"