You're going to need to add the toggle for if the player can yell or not. Do you already have that toggle?
If not you can either use a variable and save it to the character or create new methods in your connection class. If you are doing it with a variable then use the following:
Code:
if (playerCommand.startsWith("yell"))
{
String message = playerCommand.substring(5);
if (yellMuted)
return;
for (int i = 0; i < PlayerHandler.players.length; i++)
{
if (PlayerHandler.players[i] != null)
{
Client announce = (Client) PlayerHandler.players[i];
switch (c.playerRights)
{
case 1:
announce.sendMessage("[Moderator] " + Misc.formatPlayerName(c.playerName) + ": " + message);
break;
//TODO: Add other rights and stuff here.
}
}
}
}
Code:
if (playerCommand.startsWith("yellmute"))
{
String args[] = playerCommand.split(" ");
String yellMute = args[1];
for (int i = 0; i < PlayerHandler.players.length; i++)
{
if (PlayerHandler.players[i] != null)
{
if (PlayerHandler.players[i].playerName.equalsIgnoreCase(yellMute))
{
Client target = (Client) PlayerHandler.players[i];
target.yellMuted = true;
target.sendMessage("You can no longer yell as you have been yell muted!");
c.sendMessage("You have yell muted: " + Misc.formatPlayerName(c.playerName) + ".");
}
}
}
}
Code:
if (playerCommand.startsWith("unyellmute"))
{
String args[] = playerCommand.split(" ");
String unyellMute = args[1];
for (int i = 0; i < PlayerHandler.players.length; i++)
{
if (PlayerHandler.players[i] != null)
{
if (PlayerHandler.players[i].playerName.equalsIgnoreCase(unyellMute))
{
Client target = (Client) PlayerHandler.players[i];
target.yellMuted = false;
target.sendMessage("You can now yell again!");
c.sendMessage("You have unyell muted: " + Misc.formatPlayerName(c.playerName) + ".");
}
}
}
}
Add this in your Player class.
Code:
public boolean yellMuted;
Add these in your PlayerSave class.
Code:
characterfile.write("yell-muted");
characterfile.write(Boolean.toString(p.yellMuted), 0, Boolean.toString(p.yellMuted).length());
characterfile.newLine();
Code:
if (token.equals("yell-muted"))
{
p.yellMuted = Boolean.parseBoolean(token2);
}