mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +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;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -39,10 +38,4 @@ public class BukkitConfigSystem extends ConfigSystem {
|
|||
protected void copyDefaults() throws IOException {
|
||||
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;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -39,10 +38,4 @@ public class BungeeConfigSystem extends ConfigSystem {
|
|||
protected void copyDefaults() throws IOException {
|
||||
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;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -19,17 +21,20 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
public class BungeeTaskSystem extends TaskSystem {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||
|
||||
@Inject
|
||||
public BungeeTaskSystem(
|
||||
PlanConfig config,
|
||||
RunnableFactory runnableFactory,
|
||||
BungeeTPSCountTimer bungeeTPSCountTimer,
|
||||
NetworkPageRefreshTask networkPageRefreshTask,
|
||||
LogsFolderCleanTask logsFolderCleanTask
|
||||
) {
|
||||
super(runnableFactory, bungeeTPSCountTimer);
|
||||
this.config = config;
|
||||
|
||||
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||
this.logsFolderCleanTask = logsFolderCleanTask;
|
||||
|
@ -44,5 +49,11 @@ public class BungeeTaskSystem extends TaskSystem {
|
|||
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
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.PeriodicAnalysisTask;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -27,7 +28,8 @@ public abstract class ServerTaskSystem extends TaskSystem {
|
|||
PlanConfig config,
|
||||
BootAnalysisTask bootAnalysisTask,
|
||||
PeriodicAnalysisTask periodicAnalysisTask,
|
||||
LogsFolderCleanTask logsFolderCleanTask) {
|
||||
LogsFolderCleanTask logsFolderCleanTask
|
||||
) {
|
||||
super(runnableFactory, tpsCountTimer);
|
||||
this.config = config;
|
||||
this.bootAnalysisTask = bootAnalysisTask;
|
||||
|
@ -54,5 +56,11 @@ public abstract class ServerTaskSystem extends TaskSystem {
|
|||
}
|
||||
|
||||
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