mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-04-07 20:55:49 +02: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();
|
saveConfig();
|
||||||
Benchmark.stop("Enable", "Copy default config");
|
Benchmark.stop("Enable", "Copy default config");
|
||||||
|
|
||||||
processingQueue = new ProcessingQueue();
|
|
||||||
|
|
||||||
Benchmark.start("Init Database");
|
Benchmark.start("Init Database");
|
||||||
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
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.");
|
Log.error("WebServer was not successfully initialized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processingQueue = new ProcessingQueue();
|
||||||
|
|
||||||
serverInfoManager = new ServerInfoManager(this);
|
serverInfoManager = new ServerInfoManager(this);
|
||||||
infoManager = new InformationManager(this);
|
infoManager = new InformationManager(this);
|
||||||
webServer.setInfoManager(infoManager);
|
webServer.setInfoManager(infoManager);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package main.java.com.djrapitops.plan.database.databases;
|
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.Log;
|
||||||
import main.java.com.djrapitops.plan.api.IPlan;
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
@ -65,13 +67,28 @@ public abstract class SQLDB extends Database {
|
|||||||
try {
|
try {
|
||||||
setupDataSource();
|
setupDataSource();
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
clean();
|
scheduleClean(10L);
|
||||||
} finally {
|
} finally {
|
||||||
Benchmark.stop("Database", benchName);
|
Benchmark.stop("Database", benchName);
|
||||||
Log.logDebug("Database");
|
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.
|
* Ensures connection functions correctly and all tables exist.
|
||||||
* <p>
|
* <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.");
|
Log.info("Cleaning the database.");
|
||||||
try {
|
|
||||||
tpsTable.clean();
|
tpsTable.clean();
|
||||||
Log.info("Clean complete.");
|
Log.info("Clean complete.");
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new DatabaseInitException("Database Clean failed", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user