mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Fixed onEnable Exception
This commit is contained in:
parent
328d5e01bf
commit
c5e803a41f
@ -146,7 +146,6 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
|
||||
saveConfig();
|
||||
Benchmark.stop("Enable", "Copy default config");
|
||||
|
||||
processingQueue = new ProcessingQueue();
|
||||
|
||||
Benchmark.start("Init Database");
|
||||
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
||||
@ -161,6 +160,8 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
|
||||
Log.error("WebServer was not successfully initialized.");
|
||||
}
|
||||
|
||||
processingQueue = new ProcessingQueue();
|
||||
|
||||
serverInfoManager = new ServerInfoManager(this);
|
||||
infoManager = new InformationManager(this);
|
||||
webServer.setInfoManager(infoManager);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.database.databases;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||
@ -65,13 +67,28 @@ public abstract class SQLDB extends Database {
|
||||
try {
|
||||
setupDataSource();
|
||||
setupDatabase();
|
||||
clean();
|
||||
scheduleClean(10L);
|
||||
} finally {
|
||||
Benchmark.stop("Database", benchName);
|
||||
Log.logDebug("Database");
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleClean(long secondsDelay) {
|
||||
plugin.getRunnableFactory().createNew(new AbsRunnable("DB Clean Task") {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
clean();
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} finally {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * secondsDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures connection functions correctly and all tables exist.
|
||||
* <p>
|
||||
@ -223,14 +240,10 @@ public abstract class SQLDB extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
private void clean() throws DatabaseInitException {
|
||||
private void clean() throws SQLException {
|
||||
Log.info("Cleaning the database.");
|
||||
try {
|
||||
tpsTable.clean();
|
||||
Log.info("Clean complete.");
|
||||
} catch (SQLException e) {
|
||||
throw new DatabaseInitException("Database Clean failed", e);
|
||||
}
|
||||
tpsTable.clean();
|
||||
Log.info("Clean complete.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user