mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Added message repeat prevention
This commit is contained in:
parent
878199c2d5
commit
92a6bbce94
@ -208,7 +208,7 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
Location target_pos = p.getLocation().add(0, 1, 0);
|
||||
|
||||
boolean out_of_cage = false;
|
||||
boolean out_of_cage;
|
||||
if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld()))
|
||||
{
|
||||
out_of_cage = true;
|
||||
@ -287,10 +287,22 @@ public class TFM_PlayerListener implements Listener
|
||||
try
|
||||
{
|
||||
final Player p = event.getPlayer();
|
||||
String message = event.getMessage().trim();
|
||||
|
||||
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)
|
||||
{
|
||||
@ -318,8 +330,6 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
String message = event.getMessage().trim();
|
||||
|
||||
// strip color from messages
|
||||
message = ChatColor.stripColor(message);
|
||||
|
||||
|
@ -45,6 +45,7 @@ public class TFM_UserInfo
|
||||
private boolean mp44_armed = false;
|
||||
private boolean mp44_firing = false;
|
||||
private int lockup_schedule_id = -1;
|
||||
private String last_message = "";
|
||||
|
||||
public TFM_UserInfo(Player player)
|
||||
{
|
||||
@ -406,4 +407,14 @@ public class TFM_UserInfo
|
||||
{
|
||||
this.lockup_schedule_id = lockup_schedule_id;
|
||||
}
|
||||
|
||||
public void setLastMessage(String last_message)
|
||||
{
|
||||
this.last_message = last_message;
|
||||
}
|
||||
|
||||
public String getLastMessage()
|
||||
{
|
||||
return this.last_message;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user