Fixed Auto-Decaps not working

Added Removal of excessive exclamation marks
This commit is contained in:
Jerom van der Sar 2012-11-21 16:16:09 +01:00
parent fbc8d20fda
commit 488d721a93
2 changed files with 18 additions and 7 deletions

View File

@ -325,21 +325,33 @@ public class TFM_PlayerListener implements Listener
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
}
// check for caps
// check for caps and exclamation marks
if (message.length() >= 6)
{
int caps = 0;
int excl = 0;
for (char c : message.toCharArray())
{
if (Character.isUpperCase(c))
{
caps++;
}
if(c == '!')
{
excl++;
}
}
if (((float) caps / (float) message.length()) > 0.75) //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();
}
if(excl++ > 3)
{
message = message.replaceAll("!", "") + '!';
}
}
// finally, set message

View File

@ -15,11 +15,10 @@ import org.bukkit.World;
public class TFM_ProtectedArea implements Serializable
{
// Serializable Classes need one of these apperantly
private static final long serialVersionUID = 1L;
public static final double MAX_RADIUS = 50.0D;
// Serializable Classes need one of these apperantly
private static final long serialVersionUID = 1L;
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;
private final double radius;