mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-12 14:58:26 +02:00
[Fix] Network Settings save/load
Database was not enabled when the call was made, leading to a NPE when using MySQL. (DataSource not initialized) Fixed by moving the calls to scheduled tasks inside TaskSystems.
This commit is contained in:
parent
47213fa564
commit
23f96f96aa
@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.settings.config;
|
package com.djrapitops.plan.system.settings.config;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
|
||||||
import com.djrapitops.plan.system.file.PlanFiles;
|
import com.djrapitops.plan.system.file.PlanFiles;
|
||||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -39,10 +38,4 @@ public class BukkitConfigSystem extends ConfigSystem {
|
|||||||
protected void copyDefaults() throws IOException {
|
protected void copyDefaults() throws IOException {
|
||||||
config.copyDefaults(files.readFromResource("config.yml"));
|
config.copyDefaults(files.readFromResource("config.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enable() throws EnableException {
|
|
||||||
super.enable();
|
|
||||||
config.getNetworkSettings().loadSettingsFromDB();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.settings.config;
|
package com.djrapitops.plan.system.settings.config;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
|
||||||
import com.djrapitops.plan.system.file.PlanFiles;
|
import com.djrapitops.plan.system.file.PlanFiles;
|
||||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
@ -39,10 +38,4 @@ public class BungeeConfigSystem extends ConfigSystem {
|
|||||||
protected void copyDefaults() throws IOException {
|
protected void copyDefaults() throws IOException {
|
||||||
config.copyDefaults(files.readFromResource("bungeeconfig.yml"));
|
config.copyDefaults(files.readFromResource("bungeeconfig.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enable() throws EnableException {
|
|
||||||
super.enable();
|
|
||||||
config.getNetworkSettings().placeSettingsToDB();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.tasks;
|
package com.djrapitops.plan.system.tasks;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
||||||
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -19,17 +21,20 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class BungeeTaskSystem extends TaskSystem {
|
public class BungeeTaskSystem extends TaskSystem {
|
||||||
|
|
||||||
|
private final PlanConfig config;
|
||||||
private final NetworkPageRefreshTask networkPageRefreshTask;
|
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||||
private final LogsFolderCleanTask logsFolderCleanTask;
|
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BungeeTaskSystem(
|
public BungeeTaskSystem(
|
||||||
|
PlanConfig config,
|
||||||
RunnableFactory runnableFactory,
|
RunnableFactory runnableFactory,
|
||||||
BungeeTPSCountTimer bungeeTPSCountTimer,
|
BungeeTPSCountTimer bungeeTPSCountTimer,
|
||||||
NetworkPageRefreshTask networkPageRefreshTask,
|
NetworkPageRefreshTask networkPageRefreshTask,
|
||||||
LogsFolderCleanTask logsFolderCleanTask
|
LogsFolderCleanTask logsFolderCleanTask
|
||||||
) {
|
) {
|
||||||
super(runnableFactory, bungeeTPSCountTimer);
|
super(runnableFactory, bungeeTPSCountTimer);
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
this.networkPageRefreshTask = networkPageRefreshTask;
|
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||||
this.logsFolderCleanTask = logsFolderCleanTask;
|
this.logsFolderCleanTask = logsFolderCleanTask;
|
||||||
@ -44,5 +49,11 @@ public class BungeeTaskSystem extends TaskSystem {
|
|||||||
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||||
|
registerTask("Settings Save", new AbsRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
config.getNetworkSettings().placeSettingsToDB();
|
||||||
|
}
|
||||||
|
}).runTaskAsynchronously();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
|||||||
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
|
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
|
||||||
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -27,7 +28,8 @@ public abstract class ServerTaskSystem extends TaskSystem {
|
|||||||
PlanConfig config,
|
PlanConfig config,
|
||||||
BootAnalysisTask bootAnalysisTask,
|
BootAnalysisTask bootAnalysisTask,
|
||||||
PeriodicAnalysisTask periodicAnalysisTask,
|
PeriodicAnalysisTask periodicAnalysisTask,
|
||||||
LogsFolderCleanTask logsFolderCleanTask) {
|
LogsFolderCleanTask logsFolderCleanTask
|
||||||
|
) {
|
||||||
super(runnableFactory, tpsCountTimer);
|
super(runnableFactory, tpsCountTimer);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.bootAnalysisTask = bootAnalysisTask;
|
this.bootAnalysisTask = bootAnalysisTask;
|
||||||
@ -54,5 +56,11 @@ public abstract class ServerTaskSystem extends TaskSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||||
|
registerTask("Settings Load", new AbsRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
config.getNetworkSettings().loadSettingsFromDB();
|
||||||
|
}
|
||||||
|
}).runTaskAsynchronously();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user