Use Paper API for detecting proxies (1.21.6+)

Related #1312
This commit is contained in:
TuxCoding
2025-06-23 10:44:58 +02:00
parent 001cf3237b
commit f86c918a8b
2 changed files with 9 additions and 1 deletions

View File

@@ -168,7 +168,7 @@
<dependency> <dependency>
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version> <version>1.21.6-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
<!-- Use our own newer api version --> <!-- Use our own newer api version -->
<exclusions> <exclusions>

View File

@@ -31,6 +31,7 @@ import com.github.games647.fastlogin.core.message.LoginActionMessage;
import com.github.games647.fastlogin.core.message.NamespaceKey; import com.github.games647.fastlogin.core.message.NamespaceKey;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import io.papermc.paper.configuration.ServerConfiguration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -133,6 +134,13 @@ public class BungeeManager {
} }
private boolean detectProxy() { private boolean detectProxy() {
try {
ServerConfiguration.class.getDeclaredMethod("isProxyEnabled");
return Bukkit.getServerConfig().isProxyEnabled();
} catch (NoSuchMethodException noSuchMethodEx) {
// Ignore continue below
}
try { try {
if (isProxySupported("org.spigotmc.SpigotConfig", "bungee")) { if (isProxySupported("org.spigotmc.SpigotConfig", "bungee")) {
return true; return true;