mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06: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 net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -98,46 +99,52 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
p = this;
|
try {
|
||||||
getLogger().setFilter(new LogFilter(this));
|
p = this;
|
||||||
entityMetadata = new FixedMetadataValue(mcMMO.p, true);
|
getLogger().setFilter(new LogFilter(this));
|
||||||
setupFilePaths();
|
entityMetadata = new FixedMetadataValue(mcMMO.p, true);
|
||||||
setupSpout();
|
setupFilePaths();
|
||||||
loadConfigFiles();
|
setupSpout();
|
||||||
|
loadConfigFiles();
|
||||||
|
|
||||||
if (!Config.getInstance().getUseMySQL()) {
|
if (!Config.getInstance().getUseMySQL()) {
|
||||||
Users.loadUsers();
|
Users.loadUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
registerEvents();
|
||||||
|
|
||||||
|
// Setup the leader boards
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
||||||
|
Database.checkConnected();
|
||||||
|
Database.createStructure();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Leaderboard.updateLeaderboards();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
|
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogger().info("Version " + getDescription().getVersion() + " is enabled!");
|
||||||
|
|
||||||
|
scheduleTasks();
|
||||||
|
registerCommands();
|
||||||
|
|
||||||
|
MetricsManager.setup();
|
||||||
|
|
||||||
|
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||||
|
|
||||||
|
checkForUpdates();
|
||||||
|
|
||||||
|
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||||
|
Permissions.generateWorldTeleportPermissions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Throwable t) {
|
||||||
registerEvents();
|
getLogger().severe("There was an error while enabling mcMMO! Disabling now");
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
// Setup the leader boards
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
|
||||||
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
|
||||||
Database.checkConnected();
|
|
||||||
Database.createStructure();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Leaderboard.updateLeaderboards();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
|
||||||
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().info("Version " + getDescription().getVersion() + " is enabled!");
|
|
||||||
|
|
||||||
scheduleTasks();
|
|
||||||
registerCommands();
|
|
||||||
|
|
||||||
MetricsManager.setup();
|
|
||||||
|
|
||||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
|
||||||
|
|
||||||
checkForUpdates();
|
|
||||||
|
|
||||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
|
||||||
Permissions.generateWorldTeleportPermissions();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,11 +217,15 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
try {
|
||||||
PartyManager.saveParties();
|
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||||
|
PartyManager.saveParties();
|
||||||
|
placeStore.saveAll(); // Save our metadata
|
||||||
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||||
|
}
|
||||||
|
catch (NullPointerException e) {}
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||||
placeStore.saveAll(); // Save our metadata
|
|
||||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
|
||||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||||
|
|
||||||
if (Config.getInstance().getBackupsEnabled()) {
|
if (Config.getInstance().getBackupsEnabled()) {
|
||||||
@ -225,6 +236,14 @@ public class mcMMO extends JavaPlugin {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
getLogger().severe(e.toString());
|
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!
|
getLogger().info("Was disabled."); //How informative!
|
||||||
|
Loading…
Reference in New Issue
Block a user