Skip to content

Commit d3ea651

Browse files
Feature: Detect incorrect proxy setups (#4941)
* Feature: Detect & warn about incorrect proxy setups on Spigot platforms * Properly disable Geyser if we failed to load
1 parent 41e65b0 commit d3ea651

File tree

6 files changed

+45
-9
lines changed

6 files changed

+45
-9
lines changed

bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
7171
private IGeyserPingPassthrough geyserBungeePingPassthrough;
7272
private GeyserImpl geyser;
7373

74-
// We can't disable the plugin; hence we need to keep track of it manually
75-
private boolean disabled;
76-
7774
@Override
7875
public void onLoad() {
7976
onGeyserInitialize();
@@ -98,7 +95,6 @@ public void onGeyserInitialize() {
9895
}
9996

10097
if (!this.loadConfig()) {
101-
disabled = true;
10298
return;
10399
}
104100
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
@@ -112,7 +108,7 @@ public void onGeyserInitialize() {
112108

113109
@Override
114110
public void onEnable() {
115-
if (disabled) {
111+
if (geyser == null) {
116112
return; // Config did not load properly!
117113
}
118114
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating

bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public void onGeyserInitialize() {
8989
}
9090

9191
public void onGeyserEnable() {
92+
// "Disabling" a mod isn't possible; so if we fail to initialize we need to manually stop here
93+
if (geyser == null) {
94+
return;
95+
}
96+
9297
if (GeyserImpl.getInstance().isReloading()) {
9398
if (!loadConfig()) {
9499
return;

bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public void onGeyserInitialize() {
117117
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server.message", "1.13.2"));
118118
geyserLogger.error("");
119119
geyserLogger.error("*********************************************");
120-
Bukkit.getPluginManager().disablePlugin(this);
121120
return;
122121
}
123122

@@ -131,7 +130,6 @@ public void onGeyserInitialize() {
131130
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server_type.message", "Paper"));
132131
geyserLogger.error("");
133132
geyserLogger.error("*********************************************");
134-
Bukkit.getPluginManager().disablePlugin(this);
135133
return;
136134
}
137135
}
@@ -144,10 +142,25 @@ public void onGeyserInitialize() {
144142
geyserLogger.error("This version of Spigot is using an outdated version of netty. Please use Paper instead!");
145143
geyserLogger.error("");
146144
geyserLogger.error("*********************************************");
147-
Bukkit.getPluginManager().disablePlugin(this);
148145
return;
149146
}
150147

148+
try {
149+
// Check spigot config for BungeeCord mode
150+
if (Bukkit.getServer().spigot().getConfig().getBoolean("settings.bungeecord")) {
151+
warnInvalidProxySetups("BungeeCord");
152+
return;
153+
}
154+
155+
// Now: Check for velocity mode - deliberately after checking bungeecord because this is a paper only option
156+
if (Bukkit.getServer().spigot().getPaperConfig().getBoolean("proxies.velocity.enabled")) {
157+
warnInvalidProxySetups("Velocity");
158+
return;
159+
}
160+
} catch (NoSuchMethodError e) {
161+
// no-op
162+
}
163+
151164
if (!loadConfig()) {
152165
return;
153166
}
@@ -162,6 +175,11 @@ public void onGeyserInitialize() {
162175

163176
@Override
164177
public void onEnable() {
178+
// Disabling the plugin in onLoad() is not supported; we need to manually stop here
179+
if (geyser == null) {
180+
return;
181+
}
182+
165183
// Create command manager early so we can add Geyser extension commands
166184
var sourceConverter = new CommandSourceConverter<>(
167185
CommandSender.class,
@@ -458,4 +476,13 @@ private boolean loadConfig() {
458476

459477
return true;
460478
}
479+
480+
private void warnInvalidProxySetups(String platform) {
481+
geyserLogger.error("*********************************************");
482+
geyserLogger.error("");
483+
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_proxy_backend", platform));
484+
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.setup_guide", "https://geysermc.org/wiki/geyser/setup/"));
485+
geyserLogger.error("");
486+
geyserLogger.error("*********************************************");
487+
}
461488
}

bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public void onGeyserInitialize() {
113113

114114
@Override
115115
public void onGeyserEnable() {
116+
// If e.g. the config failed to load, GeyserImpl was not loaded and we cannot start
117+
if (geyser == null) {
118+
return;
119+
}
116120
if (GeyserImpl.getInstance().isReloading()) {
117121
if (!loadConfig()) {
118122
return;

bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public void onGeyserInitialize() {
132132

133133
@Override
134134
public void onGeyserEnable() {
135+
// If e.g. the config failed to load, GeyserImpl was not loaded and we cannot start
136+
if (geyser == null) {
137+
return;
138+
}
135139
boolean reloading = geyser.isReloading();
136140
if (reloading) {
137141
if (!this.loadConfig()) {

0 commit comments

Comments
 (0)