mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 02:09:50 +01:00
Better Enable error logging. Solves #509
This commit is contained in:
parent
5ef1771fd4
commit
9cf7f1edde
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan;
|
package com.djrapitops.plan;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.command.PlanCommand;
|
import com.djrapitops.plan.command.PlanCommand;
|
||||||
import com.djrapitops.plan.system.BukkitSystem;
|
import com.djrapitops.plan.system.BukkitSystem;
|
||||||
import com.djrapitops.plan.system.processing.importing.ImporterManager;
|
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 com.djrapitops.plugin.settings.ColorScheme;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class for Bukkit that manages the plugin.
|
* Main class for Bukkit that manages the plugin.
|
||||||
*
|
*
|
||||||
@ -76,9 +80,18 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
Benchmark.stop("Enable", "Enable");
|
Benchmark.stop("Enable", "Enable");
|
||||||
Log.logDebug("Enable");
|
Log.logDebug("Enable");
|
||||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
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) {
|
} catch (Exception e) {
|
||||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
|
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();
|
onDisable();
|
||||||
}
|
}
|
||||||
registerCommand("plan", new PlanCommand(this));
|
registerCommand("plan", new PlanCommand(this));
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan;
|
package com.djrapitops.plan;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||||
import com.djrapitops.plan.system.BungeeSystem;
|
import com.djrapitops.plan.system.BungeeSystem;
|
||||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
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 com.djrapitops.plugin.settings.ColorScheme;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bungee Main class.
|
* Bungee Main class.
|
||||||
@ -39,9 +42,19 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
system.enable();
|
system.enable();
|
||||||
|
|
||||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
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) {
|
} catch (Exception e) {
|
||||||
Log.error("Plugin Failed to Initialize Correctly:");
|
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee 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("planbungee", new PlanBungeeCommand(this));
|
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(hookHandler, () -> new IllegalStateException("Plugin Hooks were not initialized."));
|
||||||
Verify.nullCheck(planAPI, () -> new IllegalStateException("Plan API was not initialized."));
|
Verify.nullCheck(planAPI, () -> new IllegalStateException("Plan API was not initialized."));
|
||||||
} catch (Exception e) {
|
} 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()));
|
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
|
||||||
Benchmark.stop("Enable", "Init Database");
|
Benchmark.stop("Enable", "Init Database");
|
||||||
} catch (DBInitException e) {
|
} 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 {
|
try {
|
||||||
return serverUUID.isPresent() ? updateDbInfo(serverUUID.get()) : registerServer();
|
return serverUUID.isPresent() ? updateDbInfo(serverUUID.get()) : registerServer();
|
||||||
} catch (DBException e) {
|
} 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) {
|
} catch (IOException e) {
|
||||||
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class BungeeServerInfo extends ServerInfo {
|
|||||||
server = registerBungeeInfo(db);
|
server = registerBungeeInfo(db);
|
||||||
}
|
}
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
throw new EnableException("Failed to read Database for Server");
|
throw new EnableException("Failed to read Server information from Database.");
|
||||||
}
|
}
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user