mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-12 06:48:50 +02:00
Better Enable error logging. Solves #509
This commit is contained in:
parent
5ef1771fd4
commit
9cf7f1edde
@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanCommand;
|
||||
import com.djrapitops.plan.system.BukkitSystem;
|
||||
import com.djrapitops.plan.system.processing.importing.ImporterManager;
|
||||
@ -35,6 +36,9 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Main class for Bukkit that manages the plugin.
|
||||
*
|
||||
@ -76,9 +80,18 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
||||
Benchmark.stop("Enable", "Enable");
|
||||
Log.logDebug("Enable");
|
||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
||||
} catch (AbstractMethodError e) {
|
||||
Log.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
} catch (EnableException e) {
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
Log.error("----------------------------------------");
|
||||
Log.error("Error: " + e.getMessage());
|
||||
Log.error("----------------------------------------");
|
||||
onDisable();
|
||||
} catch (Exception e) {
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
||||
Log.toLog(this.getClass(), e);
|
||||
Log.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
Logger.getGlobal().log(Level.SEVERE, this.getClass().getSimpleName() + "-v" + getVersion(), e);
|
||||
onDisable();
|
||||
}
|
||||
registerCommand("plan", new PlanCommand(this));
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||
import com.djrapitops.plan.system.BungeeSystem;
|
||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||
@ -17,6 +18,8 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Bungee Main class.
|
||||
@ -39,9 +42,19 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
system.enable();
|
||||
|
||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
||||
} catch (AbstractMethodError e) {
|
||||
Log.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||
} catch (EnableException e) {
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||
Log.error("----------------------------------------");
|
||||
Log.error("Error: " + e.getMessage());
|
||||
Log.error("----------------------------------------");
|
||||
onDisable();
|
||||
} catch (Exception e) {
|
||||
Log.error("Plugin Failed to Initialize Correctly:");
|
||||
Log.toLog(this.getClass(), e);
|
||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||
Log.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||
Logger.getGlobal().log(Level.SEVERE, this.getClass().getSimpleName() + "-v" + getVersion(), e);
|
||||
onDisable();
|
||||
}
|
||||
registerCommand("planbungee", new PlanBungeeCommand(this));
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public abstract class PlanSystem implements SubSystem {
|
||||
Verify.nullCheck(hookHandler, () -> new IllegalStateException("Plugin Hooks were not initialized."));
|
||||
Verify.nullCheck(planAPI, () -> new IllegalStateException("Plan API was not initialized."));
|
||||
} catch (Exception e) {
|
||||
throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e);
|
||||
throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,8 @@ public abstract class DBSystem implements SubSystem {
|
||||
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
|
||||
Benchmark.stop("Enable", "Init Database");
|
||||
} catch (DBInitException e) {
|
||||
throw new EnableException("Database failed to initialize", e);
|
||||
Throwable cause = e.getCause();
|
||||
throw new EnableException(db.getName() + " init failure: " + cause.getMessage(), cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,8 @@ public class BukkitServerInfo extends ServerInfo {
|
||||
try {
|
||||
return serverUUID.isPresent() ? updateDbInfo(serverUUID.get()) : registerServer();
|
||||
} catch (DBException e) {
|
||||
throw new EnableException("Failed to read Server information from Database", e);
|
||||
String causeMsg = e.getCause().getMessage();
|
||||
throw new EnableException("Failed to read Server information from Database: " + causeMsg, e);
|
||||
} catch (IOException e) {
|
||||
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class BungeeServerInfo extends ServerInfo {
|
||||
server = registerBungeeInfo(db);
|
||||
}
|
||||
} catch (DBException e) {
|
||||
throw new EnableException("Failed to read Database for Server");
|
||||
throw new EnableException("Failed to read Server information from Database.");
|
||||
}
|
||||
return server;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user