mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Properly disable Geyser if we failed to load
This commit is contained in:
parent
964d94afd5
commit
e9d59208dc
5 changed files with 18 additions and 9 deletions
|
@ -71,9 +71,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
private IGeyserPingPassthrough geyserBungeePingPassthrough;
|
private IGeyserPingPassthrough geyserBungeePingPassthrough;
|
||||||
private GeyserImpl geyser;
|
private GeyserImpl geyser;
|
||||||
|
|
||||||
// We can't disable the plugin; hence we need to keep track of it manually
|
|
||||||
private boolean disabled;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
onGeyserInitialize();
|
onGeyserInitialize();
|
||||||
|
@ -98,7 +95,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.loadConfig()) {
|
if (!this.loadConfig()) {
|
||||||
disabled = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
|
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
|
||||||
|
@ -112,7 +108,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (disabled) {
|
if (geyser == null) {
|
||||||
return; // Config did not load properly!
|
return; // Config did not load properly!
|
||||||
}
|
}
|
||||||
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
|
// 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() {
|
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 (GeyserImpl.getInstance().isReloading()) {
|
||||||
if (!loadConfig()) {
|
if (!loadConfig()) {
|
||||||
return;
|
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(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server.message", "1.13.2"));
|
||||||
geyserLogger.error("");
|
geyserLogger.error("");
|
||||||
geyserLogger.error("*********************************************");
|
geyserLogger.error("*********************************************");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
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(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server_type.message", "Paper"));
|
||||||
geyserLogger.error("");
|
geyserLogger.error("");
|
||||||
geyserLogger.error("*********************************************");
|
geyserLogger.error("*********************************************");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +142,6 @@ 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("This version of Spigot is using an outdated version of netty. Please use Paper instead!");
|
||||||
geyserLogger.error("");
|
geyserLogger.error("");
|
||||||
geyserLogger.error("*********************************************");
|
geyserLogger.error("*********************************************");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +175,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
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
|
// Create command manager early so we can add Geyser extension commands
|
||||||
var sourceConverter = new CommandSourceConverter<>(
|
var sourceConverter = new CommandSourceConverter<>(
|
||||||
CommandSender.class,
|
CommandSender.class,
|
||||||
|
@ -482,6 +484,5 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.setup_guide", "https://geysermc.org/wiki/geyser/setup/"));
|
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.setup_guide", "https://geysermc.org/wiki/geyser/setup/"));
|
||||||
geyserLogger.error("");
|
geyserLogger.error("");
|
||||||
geyserLogger.error("*********************************************");
|
geyserLogger.error("*********************************************");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,9 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGeyserEnable() {
|
public void onGeyserEnable() {
|
||||||
|
if (geyser == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (GeyserImpl.getInstance().isReloading()) {
|
if (GeyserImpl.getInstance().isReloading()) {
|
||||||
if (!loadConfig()) {
|
if (!loadConfig()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -132,6 +132,10 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserBootst
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGeyserEnable() {
|
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();
|
boolean reloading = geyser.isReloading();
|
||||||
if (reloading) {
|
if (reloading) {
|
||||||
if (!this.loadConfig()) {
|
if (!this.loadConfig()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue