mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Setting mcMMO to disable itself if it errors on load. Fixes most reloading errors.
This commit is contained in:
parent
fd821139bd
commit
d2035f1816
@ -8,6 +8,7 @@ import java.util.List;
|
||||
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -98,6 +99,7 @@ public class mcMMO extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
p = this;
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
entityMetadata = new FixedMetadataValue(mcMMO.p, true);
|
||||
@ -140,6 +142,11 @@ public class mcMMO extends JavaPlugin {
|
||||
Permissions.generateWorldTeleportPermissions();
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
getLogger().severe("There was an error while enabling mcMMO! Disabling now");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
@ -210,11 +217,15 @@ public class mcMMO extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
try {
|
||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
}
|
||||
catch (NullPointerException e) {}
|
||||
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
|
||||
if (Config.getInstance().getBackupsEnabled()) {
|
||||
@ -225,6 +236,14 @@ public class mcMMO extends JavaPlugin {
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
if (e instanceof NoClassDefFoundError) {
|
||||
getLogger().severe("Backup class not found. Do not replace the mcMMO jar during runtime.");
|
||||
}
|
||||
else {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("Was disabled."); //How informative!
|
||||
|
Loading…
Reference in New Issue
Block a user