Don't run chat filtering on the main thread
This commit is contained in:
parent
01409af5bd
commit
1893e98036
@ -22,6 +22,7 @@ import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -230,18 +231,35 @@ public class Chat extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < event.getLines().length; i++)
|
||||
String[] lines = event.getLines();
|
||||
|
||||
runAsync(() ->
|
||||
{
|
||||
String line = event.getLine(i);
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
String line = lines[i];
|
||||
if (line != null && line.length() > 0)
|
||||
{
|
||||
String filteredLine = getFilteredMessage(event.getPlayer(), line);
|
||||
if (filteredLine != null)
|
||||
event.setLine(i, filteredLine);
|
||||
{
|
||||
lines[i] = filteredLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runSync(() ->
|
||||
{
|
||||
Sign sign = (Sign) event.getBlock().getState();
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
sign.setLine(i, lines[i]);
|
||||
}
|
||||
sign.update();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void filterChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user