mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Feature: Detect incorrect proxy setups (#4941)
* Feature: Detect & warn about incorrect proxy setups on Spigot platforms * Properly disable Geyser if we failed to load
This commit is contained in:
parent
41e65b0fcc
commit
d3ea65196b
6 changed files with 45 additions and 9 deletions
|
@ -71,9 +71,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
private IGeyserPingPassthrough geyserBungeePingPassthrough;
|
||||
private GeyserImpl geyser;
|
||||
|
||||
// We can't disable the plugin; hence we need to keep track of it manually
|
||||
private boolean disabled;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
onGeyserInitialize();
|
||||
|
@ -98,7 +95,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
}
|
||||
|
||||
if (!this.loadConfig()) {
|
||||
disabled = true;
|
||||
return;
|
||||
}
|
||||
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
|
||||
|
@ -112,7 +108,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (disabled) {
|
||||
if (geyser == null) {
|
||||
return; // Config did not load properly!
|
||||
}
|
||||
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
|
||||
|
|
|
@ -89,6 +89,11 @@ public abstract class GeyserModBootstrap implements GeyserBootstrap {
|
|||
}
|
||||
|
||||
public void onGeyserEnable() {
|
||||
// "Disabling" a mod isn't possible; so if we fail to initialize we need to manually stop here
|
||||
if (geyser == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GeyserImpl.getInstance().isReloading()) {
|
||||
if (!loadConfig()) {
|
||||
return;
|
||||
|
|
|
@ -117,7 +117,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server.message", "1.13.2"));
|
||||
geyserLogger.error("");
|
||||
geyserLogger.error("*********************************************");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -131,7 +130,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server_type.message", "Paper"));
|
||||
geyserLogger.error("");
|
||||
geyserLogger.error("*********************************************");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -144,10 +142,25 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
geyserLogger.error("This version of Spigot is using an outdated version of netty. Please use Paper instead!");
|
||||
geyserLogger.error("");
|
||||
geyserLogger.error("*********************************************");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check spigot config for BungeeCord mode
|
||||
if (Bukkit.getServer().spigot().getConfig().getBoolean("settings.bungeecord")) {
|
||||
warnInvalidProxySetups("BungeeCord");
|
||||
return;
|
||||
}
|
||||
|
||||
// Now: Check for velocity mode - deliberately after checking bungeecord because this is a paper only option
|
||||
if (Bukkit.getServer().spigot().getPaperConfig().getBoolean("proxies.velocity.enabled")) {
|
||||
warnInvalidProxySetups("Velocity");
|
||||
return;
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
if (!loadConfig()) {
|
||||
return;
|
||||
}
|
||||
|
@ -162,6 +175,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Disabling the plugin in onLoad() is not supported; we need to manually stop here
|
||||
if (geyser == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create command manager early so we can add Geyser extension commands
|
||||
var sourceConverter = new CommandSourceConverter<>(
|
||||
CommandSender.class,
|
||||
|
@ -458,4 +476,13 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void warnInvalidProxySetups(String platform) {
|
||||
geyserLogger.error("*********************************************");
|
||||
geyserLogger.error("");
|
||||
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_proxy_backend", platform));
|
||||
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.setup_guide", "https://geysermc.org/wiki/geyser/setup/"));
|
||||
geyserLogger.error("");
|
||||
geyserLogger.error("*********************************************");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,10 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
|
||||
@Override
|
||||
public void onGeyserEnable() {
|
||||
// If e.g. the config failed to load, GeyserImpl was not loaded and we cannot start
|
||||
if (geyser == null) {
|
||||
return;
|
||||
}
|
||||
if (GeyserImpl.getInstance().isReloading()) {
|
||||
if (!loadConfig()) {
|
||||
return;
|
||||
|
|
|
@ -132,6 +132,10 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserBootst
|
|||
|
||||
@Override
|
||||
public void onGeyserEnable() {
|
||||
// If e.g. the config failed to load, GeyserImpl was not loaded and we cannot start
|
||||
if (geyser == null) {
|
||||
return;
|
||||
}
|
||||
boolean reloading = geyser.isReloading();
|
||||
if (reloading) {
|
||||
if (!this.loadConfig()) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a943a1bb910f58caa61f14bafacbc622bd48a694
|
||||
Subproject commit 7499daf712ad6de70a07fba471b51b4ad92315c5
|
Loading…
Reference in a new issue