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 @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) 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); TFM_Util.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())

View File

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

View File

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