mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-09 00:20:26 +00:00
Allow to customize ping events priority via handle-motd-order
This commit is contained in:
@@ -17,6 +17,7 @@ import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.config.HandleMotdOrder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
@@ -29,6 +30,7 @@ import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -42,8 +44,31 @@ public class RedisBungeeListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPing(ProxyPingEvent event) {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
private void onPingFirst(ProxyPingEvent event) {
|
||||
if (plugin.configuration().handleMotdPriority() != HandleMotdOrder.FIRST) {
|
||||
return;
|
||||
}
|
||||
onPing0(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPingNormal(ProxyPingEvent event) {
|
||||
if (plugin.configuration().handleMotdPriority() != HandleMotdOrder.NORMAL) {
|
||||
return;
|
||||
}
|
||||
onPing0(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onPingLast(ProxyPingEvent event) {
|
||||
if (plugin.configuration().handleMotdPriority() != HandleMotdOrder.LAST) {
|
||||
return;
|
||||
}
|
||||
onPing0(event);
|
||||
}
|
||||
|
||||
private void onPing0(ProxyPingEvent event) {
|
||||
if (!plugin.configuration().handleMotd()) return;
|
||||
if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getAddress().getAddress())) return;
|
||||
ServerInfo forced = AbstractReconnectHandler.getForcedHost(event.getConnection());
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.config.HandleMotdOrder;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
@@ -41,8 +42,31 @@ public class RedisBungeeListener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.LAST) // some plugins changes it online players so we need to be executed as last
|
||||
public void onPing(ProxyPingEvent event) {
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onPingFirst(ProxyPingEvent event) {
|
||||
if (plugin.configuration().handleMotdPriority() != HandleMotdOrder.FIRST) {
|
||||
return;
|
||||
}
|
||||
onPing0(event);
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.NORMAL)
|
||||
public void onPingNormal(ProxyPingEvent event) {
|
||||
if (plugin.configuration().handleMotdPriority() != HandleMotdOrder.NORMAL) {
|
||||
return;
|
||||
}
|
||||
onPing0(event);
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.LAST)
|
||||
public void onPingLast(ProxyPingEvent event) {
|
||||
if (plugin.configuration().handleMotdPriority() != HandleMotdOrder.LAST) {
|
||||
return;
|
||||
}
|
||||
onPing0(event);
|
||||
}
|
||||
|
||||
private void onPing0(ProxyPingEvent event) {
|
||||
if (!plugin.configuration().handleMotd()) return;
|
||||
if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getRemoteAddress().getAddress())) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user