Schedule sending the chat.text warning message.

Thread safety not guaranteed by API.
This commit is contained in:
asofold 2013-07-14 20:29:21 +02:00
parent 00836ac9d7
commit 821dc34d7a

View File

@ -5,6 +5,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.NCPAPIProvider; import fr.neatmonster.nocheatplus.NCPAPIProvider;
@ -271,7 +272,13 @@ public class Text extends AsyncCheck implements INotifyReload{
} }
} }
else if (cc.chatWarningCheck && time - data.chatWarningTime > cc.chatWarningTimeout && (100f * accumulated / cc.textFreqNormLevel > cc.chatWarningLevel || 100f * shortTermAccumulated / cc.textFreqShortTermLevel > cc.chatWarningLevel)){ else if (cc.chatWarningCheck && time - data.chatWarningTime > cc.chatWarningTimeout && (100f * accumulated / cc.textFreqNormLevel > cc.chatWarningLevel || 100f * shortTermAccumulated / cc.textFreqShortTermLevel > cc.chatWarningLevel)){
player.sendMessage(ColorUtil.replaceColors(cc.chatWarningMessage)); // TODO: In case this gets used more often, use the player tasks, at least once PlayerData can be used for async calls.
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("NoCheatPlus"), new Runnable(){
@Override
public void run() {
player.sendMessage(ColorUtil.replaceColors(cc.chatWarningMessage));
};
});
data.chatWarningTime = time; data.chatWarningTime = time;
} }
else { else {