Move repeat message detection so spam filter can still catch it.

Who cares if someone uses too many !!'s.
Removed extra check for /socialspy, /packet has been hard-coded out already.
Added back in check for is muted.
General cleanup.
This commit is contained in:
Steven Lawson 2012-12-01 15:31:25 -05:00
parent ff7a77cbfd
commit 93d390c96a
4 changed files with 17 additions and 38 deletions

View File

@ -12,7 +12,6 @@ public class Command_stop extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
for (Player p : server.getOnlinePlayers())

View File

@ -101,6 +101,7 @@ public class TFM_PlayerListener implements Listener
}
event.setCancelled(true);
return;
}
break;
}
@ -130,6 +131,7 @@ public class TFM_PlayerListener implements Listener
}
event.setCancelled(true);
return;
}
break;
@ -293,17 +295,6 @@ public class TFM_PlayerListener implements Listener
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.incrementMsgCount();
// check for message repeat
if(playerdata.getLastMessage().equalsIgnoreCase(message))
{
TFM_Util.playerMsg(p, "Please do not repeat messages.");
event.setCancelled(true);
playerdata.setLastMessage(message);
return;
}
playerdata.setLastMessage(message);
// check for spam
if (playerdata.getMsgCount() > 10)
{
@ -316,6 +307,15 @@ public class TFM_PlayerListener implements Listener
return;
}
// check for message repeat
if (playerdata.getLastMessage().equalsIgnoreCase(message))
{
TFM_Util.playerMsg(p, "Please do not repeat messages.");
event.setCancelled(true);
return;
}
playerdata.setLastMessage(message);
// check for muted
if (playerdata.isMuted())
{
@ -341,33 +341,21 @@ public class TFM_PlayerListener implements Listener
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
}
// check for caps and exclamation marks
// check for caps - Quit messing with this :-/
if (message.length() >= 6)
{
int caps = 0;
int excl = 0;
for (char c : message.toCharArray())
{
if (Character.isUpperCase(c))
{
caps++;
}
if(c == '!')
{
excl++;
}
}
if (caps > 6 || caps > 3 && ((float) caps / (float) message.length()) > 0.55)
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
{
message = message.toLowerCase();
}
if(excl++ > 3)
{
message = message.replaceAll("!", "") + '!';
}
}
// finally, set message
@ -496,14 +484,6 @@ public class TFM_PlayerListener implements Listener
{
block_command = true;
}
else if (!TFM_SuperadminList.isUserSuperadmin(p) && Pattern.compile("^/socialspy").matcher(command).find())
{
block_command = true;
}
else if (!TFM_SuperadminList.isUserSuperadmin(p) && Pattern.compile("^/packet").matcher(command).find())
{
block_command = true;
}
}
if (block_command)
@ -513,7 +493,8 @@ public class TFM_PlayerListener implements Listener
return;
}
// block muted commands
// block commands while player is muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{

View File

@ -16,7 +16,6 @@ import org.bukkit.World;
public class TFM_ProtectedArea implements Serializable
{
private static final long serialVersionUID = -3270338811000937254L;
public static final double MAX_RADIUS = 50.0D;
private static Map<String, TFM_ProtectedArea> protectedAreas = new HashMap<String, TFM_ProtectedArea>();
private final SerializableLocation center_location;