mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-23 02:55:19 +01:00
Disable plugin on load error
This commit is contained in:
parent
c63ec971d6
commit
f8564e4e3f
@ -62,7 +62,7 @@ public class BukkitPlugin extends JavaPlugin implements ServerInterface, Listene
|
||||
|
||||
private static BukkitPlugin instance;
|
||||
|
||||
private Plugin bluemap;
|
||||
private Plugin pluginInstance;
|
||||
private EventForwarder eventForwarder;
|
||||
private BukkitCommands commands;
|
||||
|
||||
@ -77,8 +77,8 @@ public BukkitPlugin() {
|
||||
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
this.eventForwarder = new EventForwarder();
|
||||
this.bluemap = new Plugin("bukkit", this);
|
||||
this.commands = new BukkitCommands(this.bluemap);
|
||||
this.pluginInstance = new Plugin("bukkit", this);
|
||||
this.commands = new BukkitCommands(this.pluginInstance);
|
||||
|
||||
BukkitPlugin.instance = this;
|
||||
}
|
||||
@ -130,11 +130,11 @@ public void onEnable() {
|
||||
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
||||
try {
|
||||
Logger.global.logInfo("Loading...");
|
||||
this.bluemap.load();
|
||||
if (bluemap.isLoaded()) Logger.global.logInfo("Loaded!");
|
||||
this.pluginInstance.load();
|
||||
if (pluginInstance.isLoaded()) Logger.global.logInfo("Loaded!");
|
||||
} catch (IOException | ParseResourceException | RuntimeException e) {
|
||||
Logger.global.logError("Failed to load!", e);
|
||||
this.bluemap.unload();
|
||||
this.pluginInstance.unload();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -143,7 +143,7 @@ public void onEnable() {
|
||||
public void onDisable() {
|
||||
Logger.global.logInfo("Stopping...");
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
bluemap.unload();
|
||||
pluginInstance.unload();
|
||||
Logger.global.logInfo("Saved and stopped!");
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ public File getConfigFolder() {
|
||||
}
|
||||
|
||||
public Plugin getBlueMap() {
|
||||
return bluemap;
|
||||
return pluginInstance;
|
||||
}
|
||||
|
||||
public static BukkitPlugin getInstance() {
|
||||
|
@ -114,6 +114,7 @@ public void onInitialize() {
|
||||
if (pluginInstance.isLoaded()) Logger.global.logInfo("BlueMap loaded!");
|
||||
} catch (IOException | ParseResourceException e) {
|
||||
Logger.global.logError("Failed to load bluemap!", e);
|
||||
pluginInstance.unload();
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
|
@ -115,6 +115,7 @@ public void onServerStarting(FMLServerStartingEvent event) {
|
||||
if (pluginInstance.isLoaded()) Logger.global.logInfo("Loaded!");
|
||||
} catch (IOException | ParseResourceException e) {
|
||||
Logger.global.logError("Failed to load bluemap!", e);
|
||||
pluginInstance.unload();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class SpongePlugin implements ServerInterface {
|
||||
@Inject
|
||||
private MetricsLite2 metrics;
|
||||
|
||||
private Plugin bluemap;
|
||||
private Plugin pluginInstance;
|
||||
private SpongeCommands commands;
|
||||
|
||||
private SpongeExecutorService asyncExecutor;
|
||||
@ -95,8 +95,8 @@ public SpongePlugin(org.slf4j.Logger logger) {
|
||||
this.onlinePlayerMap = new ConcurrentHashMap<>();
|
||||
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
this.bluemap = new Plugin("sponge", this);
|
||||
this.commands = new SpongeCommands(bluemap);
|
||||
this.pluginInstance = new Plugin("sponge", this);
|
||||
this.commands = new SpongeCommands(pluginInstance);
|
||||
}
|
||||
|
||||
@Listener
|
||||
@ -122,10 +122,11 @@ public void onServerStart(GameStartingServerEvent evt) {
|
||||
asyncExecutor.execute(() -> {
|
||||
try {
|
||||
Logger.global.logInfo("Loading...");
|
||||
bluemap.load();
|
||||
if (bluemap.isLoaded()) Logger.global.logInfo("Loaded!");
|
||||
pluginInstance.load();
|
||||
if (pluginInstance.isLoaded()) Logger.global.logInfo("Loaded!");
|
||||
} catch (IOException | ParseResourceException | RuntimeException e) {
|
||||
Logger.global.logError("Failed to load!", e);
|
||||
pluginInstance.unload();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -134,7 +135,7 @@ public void onServerStart(GameStartingServerEvent evt) {
|
||||
public void onServerStop(GameStoppingEvent evt) {
|
||||
Logger.global.logInfo("Stopping...");
|
||||
Sponge.getScheduler().getScheduledTasks(this).forEach(t -> t.cancel());
|
||||
bluemap.unload();
|
||||
pluginInstance.unload();
|
||||
Logger.global.logInfo("Saved and stopped!");
|
||||
}
|
||||
|
||||
@ -143,11 +144,11 @@ public void onServerReload(GameReloadEvent evt) {
|
||||
asyncExecutor.execute(() -> {
|
||||
try {
|
||||
Logger.global.logInfo("Reloading...");
|
||||
bluemap.reload();
|
||||
pluginInstance.reload();
|
||||
Logger.global.logInfo("Reloaded!");
|
||||
} catch (IOException | ParseResourceException | RuntimeException e) {
|
||||
Logger.global.logError("Failed to load!", e);
|
||||
bluemap.unload();
|
||||
pluginInstance.unload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user