forked from TuxCoding/FastLogin
Run the plugin message reader async to prevent the timeout event
warning from BungeeCord
This commit is contained in:
@ -6,6 +6,7 @@ import com.github.games647.fastlogin.bungee.tasks.AsyncToggleMessage;
|
|||||||
import com.github.games647.fastlogin.core.PlayerProfile;
|
import com.github.games647.fastlogin.core.PlayerProfile;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -41,17 +42,22 @@ public class PluginMessageListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void readMessage(PluginMessageEvent pluginMessageEvent) {
|
private void readMessage(PluginMessageEvent pluginMessageEvent) {
|
||||||
byte[] data = pluginMessageEvent.getData();
|
//so that we can safely process this in the background
|
||||||
|
final byte[] data = Arrays.copyOf(pluginMessageEvent.getData(), pluginMessageEvent.getData().length);
|
||||||
|
final ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver();
|
||||||
|
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
ByteArrayDataInput dataInput = ByteStreams.newDataInput(data);
|
ByteArrayDataInput dataInput = ByteStreams.newDataInput(data);
|
||||||
String subchannel = dataInput.readUTF();
|
String subchannel = dataInput.readUTF();
|
||||||
|
|
||||||
ProxiedPlayer forPlayer = (ProxiedPlayer) pluginMessageEvent.getReceiver();
|
|
||||||
if ("ON".equals(subchannel)) {
|
if ("ON".equals(subchannel)) {
|
||||||
String playerName = dataInput.readUTF();
|
String playerName = dataInput.readUTF();
|
||||||
|
|
||||||
if (playerName.equals(forPlayer.getName()) && plugin.getConfig().getBoolean("premium-warning")
|
if (playerName.equals(forPlayer.getName()) && plugin.getConfig().getBoolean("premium-warning")
|
||||||
&& !plugin.getPendingConfirms().contains(forPlayer.getUniqueId())) {
|
&& !plugin.getPendingConfirms().contains(forPlayer.getUniqueId())) {
|
||||||
forPlayer.sendMessage(TextComponent.fromLegacyText(plugin.getCore().getMessage("premium-warning")));
|
String message = plugin.getCore().getMessage("premium-warning");
|
||||||
|
forPlayer.sendMessage(TextComponent.fromLegacyText(message));
|
||||||
plugin.getPendingConfirms().add(forPlayer.getUniqueId());
|
plugin.getPendingConfirms().add(forPlayer.getUniqueId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -80,4 +86,6 @@ public class PluginMessageListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user