mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-02 16:59:42 +01:00
Tasks, BungeeTaskSystem initialized by Dagger
This commit is contained in:
parent
8d28169c6c
commit
c6b9058bb0
@ -30,8 +30,10 @@ import dagger.Module;
|
|||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
@Component(modules = {
|
@Component(modules = {
|
||||||
BungeePlanModule.class,
|
BungeePlanModule.class,
|
||||||
APFModule.class,
|
APFModule.class,
|
||||||
@ -41,6 +43,7 @@ import java.io.InputStream;
|
|||||||
LocaleModule.class,
|
LocaleModule.class,
|
||||||
BungeeInfoSystemModule.class,
|
BungeeInfoSystemModule.class,
|
||||||
BungeeInfoModule.class,
|
BungeeInfoModule.class,
|
||||||
|
BungeeDataCacheModule.class,
|
||||||
BungeeDatabaseModule.class,
|
BungeeDatabaseModule.class,
|
||||||
PluginHookModule.class,
|
PluginHookModule.class,
|
||||||
BungeeAPIModule.class
|
BungeeAPIModule.class
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.djrapitops.plan.modules.bungee;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.system.cache.BungeeDataCache;
|
||||||
|
import com.djrapitops.plan.system.cache.DataCache;
|
||||||
|
import com.djrapitops.plan.system.cache.SessionCache;
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dagger module for Server CacheSystem.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
@Module
|
||||||
|
public class BungeeDataCacheModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
DataCache provideDataCache(BungeeDataCache bungeeDataCache) {
|
||||||
|
return bungeeDataCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
SessionCache provideSessionCache(DataCache cache) {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.djrapitops.plan.modules.server.bukkit;
|
package com.djrapitops.plan.modules.server.bukkit;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
|
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.info.server.properties.BukkitServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.BukkitServerProperties;
|
||||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
@ -14,6 +16,11 @@ import dagger.Provides;
|
|||||||
@Module
|
@Module
|
||||||
public class BukkitInfoModule {
|
public class BukkitInfoModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
ServerInfo provideBukkitServerInfo(BukkitServerInfo bukkitServerInfo) {
|
||||||
|
return bukkitServerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
ServerProperties provideServerProperties(Plan plugin) {
|
ServerProperties provideServerProperties(Plan plugin) {
|
||||||
return new BukkitServerProperties(plugin.getServer());
|
return new BukkitServerProperties(plugin.getServer());
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.djrapitops.plan.modules.server.sponge;
|
package com.djrapitops.plan.modules.server.sponge;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.SpongeServerInfo;
|
||||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.system.info.server.properties.SpongeServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.SpongeServerProperties;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
@ -14,6 +16,11 @@ import org.spongepowered.api.Sponge;
|
|||||||
@Module
|
@Module
|
||||||
public class SpongeInfoModule {
|
public class SpongeInfoModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
ServerInfo provideSpongeServerInfo(SpongeServerInfo spongeServerInfo) {
|
||||||
|
return spongeServerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
ServerProperties provideServerProperties() {
|
ServerProperties provideServerProperties() {
|
||||||
return new SpongeServerProperties(Sponge.getGame());
|
return new SpongeServerProperties(Sponge.getGame());
|
||||||
|
@ -32,7 +32,6 @@ public class BungeeSystem extends PlanSystem {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BungeeSystem(
|
public BungeeSystem(
|
||||||
PlanBungee plugin,
|
|
||||||
VersionCheckSystem versionCheckSystem,
|
VersionCheckSystem versionCheckSystem,
|
||||||
FileSystem fileSystem,
|
FileSystem fileSystem,
|
||||||
BungeeConfigSystem bungeeConfigSystem,
|
BungeeConfigSystem bungeeConfigSystem,
|
||||||
@ -41,6 +40,8 @@ public class BungeeSystem extends PlanSystem {
|
|||||||
BungeeCacheSystem bungeeCacheSystem,
|
BungeeCacheSystem bungeeCacheSystem,
|
||||||
DBSystem databaseSystem,
|
DBSystem databaseSystem,
|
||||||
WebServerSystem webServerSystem,
|
WebServerSystem webServerSystem,
|
||||||
|
BungeeListenerSystem bungeeListenerSystem,
|
||||||
|
BungeeTaskSystem bungeeTaskSystem,
|
||||||
HookHandler hookHandler,
|
HookHandler hookHandler,
|
||||||
ExportSystem exportSystem,
|
ExportSystem exportSystem,
|
||||||
PlanAPI planAPI
|
PlanAPI planAPI
|
||||||
@ -54,8 +55,8 @@ public class BungeeSystem extends PlanSystem {
|
|||||||
this.exportSystem = exportSystem;
|
this.exportSystem = exportSystem;
|
||||||
this.databaseSystem = databaseSystem;
|
this.databaseSystem = databaseSystem;
|
||||||
cacheSystem = bungeeCacheSystem;
|
cacheSystem = bungeeCacheSystem;
|
||||||
listenerSystem = new BungeeListenerSystem(plugin);
|
listenerSystem = bungeeListenerSystem;
|
||||||
taskSystem = new BungeeTaskSystem(plugin.getRunnableFactory());
|
taskSystem = bungeeTaskSystem;
|
||||||
|
|
||||||
this.infoSystem = infoSystem;
|
this.infoSystem = infoSystem;
|
||||||
this.serverInfo = serverInfo;
|
this.serverInfo = serverInfo;
|
||||||
|
@ -42,6 +42,7 @@ public abstract class InfoSystem implements SubSystem {
|
|||||||
this.connectionSystem = connectionSystem;
|
this.connectionSystem = connectionSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static InfoSystem getInstance() {
|
public static InfoSystem getInstance() {
|
||||||
InfoSystem infoSystem = PlanSystem.getInstance().getInfoSystem();
|
InfoSystem infoSystem = PlanSystem.getInstance().getInfoSystem();
|
||||||
Verify.nullCheck(infoSystem, () -> new IllegalStateException("Info System was not initialized."));
|
Verify.nullCheck(infoSystem, () -> new IllegalStateException("Info System was not initialized."));
|
||||||
|
@ -3,17 +3,22 @@ package com.djrapitops.plan.system.listeners;
|
|||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.system.listeners.bungee.PlayerOnlineListener;
|
import com.djrapitops.plan.system.listeners.bungee.PlayerOnlineListener;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class BungeeListenerSystem extends ListenerSystem {
|
public class BungeeListenerSystem extends ListenerSystem {
|
||||||
|
|
||||||
private final PlanBungee plugin;
|
private final PlanBungee plugin;
|
||||||
|
private PlayerOnlineListener playerOnlineListener;
|
||||||
|
|
||||||
public BungeeListenerSystem(PlanBungee plugin) {
|
@Inject
|
||||||
|
public BungeeListenerSystem(PlanBungee plugin, PlayerOnlineListener playerOnlineListener) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.playerOnlineListener = playerOnlineListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerListeners() {
|
protected void registerListeners() {
|
||||||
plugin.registerListener(new PlayerOnlineListener());
|
plugin.registerListener(playerOnlineListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,8 @@ import com.djrapitops.plan.system.processing.processors.player.BungeePlayerRegis
|
|||||||
import com.djrapitops.plan.system.processing.processors.player.IPUpdateProcessor;
|
import com.djrapitops.plan.system.processing.processors.player.IPUpdateProcessor;
|
||||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
||||||
@ -21,6 +22,7 @@ import net.md_5.bungee.api.event.ServerSwitchEvent;
|
|||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -31,6 +33,21 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class PlayerOnlineListener implements Listener {
|
public class PlayerOnlineListener implements Listener {
|
||||||
|
|
||||||
|
private final SessionCache sessionCache;
|
||||||
|
private final ServerInfo serverInfo;
|
||||||
|
private final ErrorHandler errorHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PlayerOnlineListener(
|
||||||
|
SessionCache sessionCache,
|
||||||
|
ServerInfo serverInfo,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
this.sessionCache = sessionCache;
|
||||||
|
this.serverInfo = serverInfo;
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPostLogin(PostLoginEvent event) {
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
try {
|
try {
|
||||||
@ -40,15 +57,15 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
InetAddress address = player.getAddress().getAddress();
|
InetAddress address = player.getAddress().getAddress();
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, now, "", ""));
|
sessionCache.cacheSession(uuid, new Session(uuid, now, "", ""));
|
||||||
|
|
||||||
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
|
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
|
||||||
new IPUpdateProcessor(uuid, address, now))
|
new IPUpdateProcessor(uuid, address, now))
|
||||||
);
|
);
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID_Old()));
|
ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,11 +75,11 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
ProxiedPlayer player = event.getPlayer();
|
ProxiedPlayer player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
SessionCache.getInstance().endSession(uuid, System.currentTimeMillis());
|
sessionCache.endSession(uuid, System.currentTimeMillis());
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID_Old()));
|
ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +91,10 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
// Replaces the current session in the cache.
|
// Replaces the current session in the cache.
|
||||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, now, "", ""));
|
sessionCache.cacheSession(uuid, new Session(uuid, now, "", ""));
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
package com.djrapitops.plan.system.tasks;
|
package com.djrapitops.plan.system.tasks;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.system.tasks.server.BukkitTPSCountTimer;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.system.tasks.server.PaperTPSCountTimer;
|
import com.djrapitops.plan.system.tasks.server.*;
|
||||||
import com.djrapitops.plan.system.tasks.server.PingCountTimer;
|
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -24,11 +23,25 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
|||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BukkitTaskSystem(Plan plugin, RunnableFactory runnableFactory) {
|
public BukkitTaskSystem(
|
||||||
super(runnableFactory,
|
Plan plugin,
|
||||||
|
PlanConfig config,
|
||||||
|
RunnableFactory runnableFactory,
|
||||||
|
PaperTPSCountTimer paperTPSCountTimer,
|
||||||
|
BukkitTPSCountTimer bukkitTPSCountTimer,
|
||||||
|
NetworkPageRefreshTask networkPageRefreshTask,
|
||||||
|
BootAnalysisTask bootAnalysisTask,
|
||||||
|
PeriodicAnalysisTask periodicAnalysisTask
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
runnableFactory,
|
||||||
Check.isPaperAvailable()
|
Check.isPaperAvailable()
|
||||||
? new PaperTPSCountTimer(plugin)
|
? paperTPSCountTimer
|
||||||
: new BukkitTPSCountTimer(plugin)
|
: bukkitTPSCountTimer,
|
||||||
|
config,
|
||||||
|
networkPageRefreshTask,
|
||||||
|
bootAnalysisTask,
|
||||||
|
periodicAnalysisTask
|
||||||
);
|
);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@ -37,7 +50,8 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
|||||||
public void enable() {
|
public void enable() {
|
||||||
super.enable();
|
super.enable();
|
||||||
try {
|
try {
|
||||||
PingCountTimer pingCountTimer = new PingCountTimer();
|
PingCountTimer pingCountTimer = new PingCountTimer(runnableFactory);
|
||||||
|
|
||||||
plugin.registerListener(pingCountTimer);
|
plugin.registerListener(pingCountTimer);
|
||||||
registerTask("PingCountTimer", pingCountTimer)
|
registerTask("PingCountTimer", pingCountTimer)
|
||||||
.runTaskTimer(20L, PingCountTimer.PING_INTERVAL);
|
.runTaskTimer(20L, PingCountTimer.PING_INTERVAL);
|
||||||
|
@ -9,7 +9,8 @@ import com.djrapitops.plan.system.tasks.bungee.EnableConnectionTask;
|
|||||||
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.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TaskSystem responsible for registering tasks for Bungee.
|
* TaskSystem responsible for registering tasks for Bungee.
|
||||||
@ -18,9 +19,20 @@ import com.google.inject.Inject;
|
|||||||
*/
|
*/
|
||||||
public class BungeeTaskSystem extends TaskSystem {
|
public class BungeeTaskSystem extends TaskSystem {
|
||||||
|
|
||||||
|
private final EnableConnectionTask enableConnectionTask;
|
||||||
|
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BungeeTaskSystem(RunnableFactory runnableFactory) {
|
public BungeeTaskSystem(
|
||||||
super(runnableFactory, new BungeeTPSCountTimer());
|
RunnableFactory runnableFactory,
|
||||||
|
BungeeTPSCountTimer bungeeTPSCountTimer,
|
||||||
|
EnableConnectionTask enableConnectionTask,
|
||||||
|
NetworkPageRefreshTask networkPageRefreshTask
|
||||||
|
) {
|
||||||
|
super(runnableFactory, bungeeTPSCountTimer);
|
||||||
|
|
||||||
|
this.enableConnectionTask = enableConnectionTask;
|
||||||
|
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,8 +41,8 @@ public class BungeeTaskSystem extends TaskSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerTasks() {
|
private void registerTasks() {
|
||||||
registerTask(new EnableConnectionTask()).runTaskAsynchronously();
|
registerTask(enableConnectionTask).runTaskAsynchronously();
|
||||||
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks());
|
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks());
|
||||||
registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks());
|
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.djrapitops.plan.system.tasks;
|
package com.djrapitops.plan.system.tasks;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
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.NetworkPageRefreshTask;
|
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
||||||
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.task.PluginTask;
|
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,12 +13,26 @@ import com.djrapitops.plugin.task.RunnableFactory;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ServerTaskSystem extends TaskSystem {
|
public abstract class ServerTaskSystem extends TaskSystem {
|
||||||
|
|
||||||
protected PluginTask bootAnalysisTask;
|
private final PlanConfig config;
|
||||||
|
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||||
|
private final PeriodicAnalysisTask periodicAnalysisTask;
|
||||||
|
protected BootAnalysisTask bootAnalysisTask;
|
||||||
|
|
||||||
public ServerTaskSystem(RunnableFactory runnableFactory, TPSCountTimer tpsCountTimer) {
|
public ServerTaskSystem(
|
||||||
|
RunnableFactory runnableFactory,
|
||||||
|
TPSCountTimer tpsCountTimer,
|
||||||
|
PlanConfig config,
|
||||||
|
NetworkPageRefreshTask networkPageRefreshTask,
|
||||||
|
BootAnalysisTask bootAnalysisTask,
|
||||||
|
PeriodicAnalysisTask periodicAnalysisTask
|
||||||
|
) {
|
||||||
super(runnableFactory, tpsCountTimer);
|
super(runnableFactory, tpsCountTimer);
|
||||||
|
this.config = config;
|
||||||
|
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||||
|
this.bootAnalysisTask = bootAnalysisTask;
|
||||||
|
this.periodicAnalysisTask = periodicAnalysisTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,21 +41,18 @@ public class ServerTaskSystem extends TaskSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerTasks() {
|
private void registerTasks() {
|
||||||
Benchmark.start("Task Registration");
|
|
||||||
|
|
||||||
// Analysis refresh settings
|
// Analysis refresh settings
|
||||||
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
|
int analysisRefreshMinutes = config.getNumber(Settings.ANALYSIS_AUTO_REFRESH);
|
||||||
boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0;
|
boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0;
|
||||||
long analysisPeriod = analysisRefreshMinutes * TimeAmount.MINUTE.ticks();
|
long analysisPeriod = analysisRefreshMinutes * TimeAmount.MINUTE.ticks();
|
||||||
|
|
||||||
registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks());
|
registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks());
|
||||||
registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(20L, 5L * TimeAmount.MINUTE.ticks());
|
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(20L, 5L * TimeAmount.MINUTE.ticks());
|
||||||
bootAnalysisTask = registerTask(new BootAnalysisTask()).runTaskLaterAsynchronously(30L * TimeAmount.SECOND.ticks());
|
registerTask(bootAnalysisTask).runTaskLaterAsynchronously(30L * TimeAmount.SECOND.ticks());
|
||||||
|
|
||||||
if (analysisRefreshTaskIsEnabled) {
|
if (analysisRefreshTaskIsEnabled) {
|
||||||
registerTask(new PeriodicAnalysisTask()).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod);
|
registerTask(periodicAnalysisTask).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod);
|
||||||
}
|
}
|
||||||
Benchmark.stop("Enable", "Task Registration");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelBootAnalysis() {
|
public void cancelBootAnalysis() {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package com.djrapitops.plan.system.tasks;
|
package com.djrapitops.plan.system.tasks;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanSponge;
|
import com.djrapitops.plan.PlanSponge;
|
||||||
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
|
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
|
||||||
|
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
||||||
|
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
||||||
import com.djrapitops.plan.system.tasks.server.SpongeTPSCountTimer;
|
import com.djrapitops.plan.system.tasks.server.SpongeTPSCountTimer;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
@ -13,8 +17,23 @@ public class SpongeTaskSystem extends ServerTaskSystem {
|
|||||||
private final PlanSponge plugin;
|
private final PlanSponge plugin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SpongeTaskSystem(PlanSponge plugin, RunnableFactory runnableFactory) {
|
public SpongeTaskSystem(
|
||||||
super(runnableFactory, new SpongeTPSCountTimer(plugin));
|
PlanSponge plugin,
|
||||||
|
PlanConfig config,
|
||||||
|
RunnableFactory runnableFactory,
|
||||||
|
SpongeTPSCountTimer spongeTPSCountTimer,
|
||||||
|
NetworkPageRefreshTask networkPageRefreshTask,
|
||||||
|
BootAnalysisTask bootAnalysisTask,
|
||||||
|
PeriodicAnalysisTask periodicAnalysisTask
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
runnableFactory,
|
||||||
|
spongeTPSCountTimer,
|
||||||
|
config,
|
||||||
|
networkPageRefreshTask,
|
||||||
|
bootAnalysisTask,
|
||||||
|
periodicAnalysisTask
|
||||||
|
);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,9 @@ package com.djrapitops.plan.system.tasks;
|
|||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor;
|
import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -17,11 +19,14 @@ import java.util.List;
|
|||||||
public abstract class TPSCountTimer extends AbsRunnable {
|
public abstract class TPSCountTimer extends AbsRunnable {
|
||||||
|
|
||||||
protected final List<TPS> history;
|
protected final List<TPS> history;
|
||||||
|
protected final PluginLogger logger;
|
||||||
|
protected final ErrorHandler errorHandler;
|
||||||
|
|
||||||
protected int latestPlayersOnline = 0;
|
protected int latestPlayersOnline = 0;
|
||||||
|
|
||||||
public TPSCountTimer() {
|
public TPSCountTimer(PluginLogger logger, ErrorHandler errorHandler) {
|
||||||
super();
|
this.logger = logger;
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
history = new ArrayList<>();
|
history = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +43,8 @@ public abstract class TPSCountTimer extends AbsRunnable {
|
|||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||||
Log.error("TPS Count Task Disabled due to error, reload Plan to re-enable.");
|
logger.error("TPS Count Task Disabled due to error, reload Plan to re-enable.");
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,30 @@ package com.djrapitops.plan.system.tasks.bungee;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||||
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class BungeeTPSCountTimer extends TPSCountTimer {
|
public class BungeeTPSCountTimer extends TPSCountTimer {
|
||||||
|
|
||||||
|
private final ServerProperties serverProperties;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BungeeTPSCountTimer(
|
||||||
|
ServerProperties serverProperties,
|
||||||
|
PluginLogger logger,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
super(logger, errorHandler);
|
||||||
|
this.serverProperties = serverProperties;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNewTPSEntry(long nanoTime, long now) {
|
public void addNewTPSEntry(long nanoTime, long now) {
|
||||||
int onlineCount = ServerInfo.getServerProperties_Old().getOnlinePlayers();
|
int onlineCount = serverProperties.getOnlinePlayers();
|
||||||
TPS tps = TPSBuilder.get()
|
TPS tps = TPSBuilder.get()
|
||||||
.date(now)
|
.date(now)
|
||||||
.skipTPS()
|
.skipTPS()
|
||||||
|
@ -5,12 +5,21 @@ import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
|||||||
import com.djrapitops.plan.system.info.request.GenerateNetworkPageContentRequest;
|
import com.djrapitops.plan.system.info.request.GenerateNetworkPageContentRequest;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class EnableConnectionTask extends AbsRunnable {
|
public class EnableConnectionTask extends AbsRunnable {
|
||||||
|
|
||||||
|
private ConnectionSystem connectionSystem;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public EnableConnectionTask(ConnectionSystem connectionSystem) {
|
||||||
|
this.connectionSystem = connectionSystem;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
WebExceptionLogger.logIfOccurs(this.getClass(),
|
WebExceptionLogger.logIfOccurs(this.getClass(),
|
||||||
() -> ConnectionSystem.getInstance().sendWideInfoRequest(new GenerateNetworkPageContentRequest())
|
() -> connectionSystem.sendWideInfoRequest(new GenerateNetworkPageContentRequest())
|
||||||
);
|
);
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,32 @@ import com.djrapitops.plan.system.info.InfoSystem;
|
|||||||
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
||||||
import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class BootAnalysisTask extends AbsRunnable {
|
public class BootAnalysisTask extends AbsRunnable {
|
||||||
|
|
||||||
|
private InfoSystem infoSystem;
|
||||||
|
private ErrorHandler errorHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BootAnalysisTask(InfoSystem infoSystem, ErrorHandler errorHandler) {
|
||||||
|
this.infoSystem = infoSystem;
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
||||||
InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID_Old()))
|
infoSystem.sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID_Old()))
|
||||||
);
|
);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
if (!PlanPlugin.getInstance().isReloading()) {
|
if (!PlanPlugin.getInstance().isReloading()) {
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
cancel();
|
cancel();
|
||||||
|
@ -2,22 +2,34 @@ package com.djrapitops.plan.system.tasks.server;
|
|||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.OperatingSystemMXBean;
|
import java.lang.management.OperatingSystemMXBean;
|
||||||
|
|
||||||
public class BukkitTPSCountTimer extends TPSCountTimer {
|
public class BukkitTPSCountTimer extends TPSCountTimer {
|
||||||
|
|
||||||
protected final Plan plugin;
|
protected final Plan plugin;
|
||||||
|
private ServerProperties serverProperties;
|
||||||
private long lastCheckNano;
|
private long lastCheckNano;
|
||||||
|
|
||||||
public BukkitTPSCountTimer(Plan plugin) {
|
@Inject
|
||||||
|
public BukkitTPSCountTimer(
|
||||||
|
Plan plugin,
|
||||||
|
ServerProperties serverProperties,
|
||||||
|
PluginLogger logger,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
super(logger, errorHandler);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.serverProperties = serverProperties;
|
||||||
lastCheckNano = -1;
|
lastCheckNano = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +62,7 @@ public class BukkitTPSCountTimer extends TPSCountTimer {
|
|||||||
long totalMemory = runtime.totalMemory();
|
long totalMemory = runtime.totalMemory();
|
||||||
long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000;
|
long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000;
|
||||||
|
|
||||||
int playersOnline = ServerInfo.getServerProperties_Old().getOnlinePlayers();
|
int playersOnline = serverProperties.getOnlinePlayers();
|
||||||
latestPlayersOnline = playersOnline;
|
latestPlayersOnline = playersOnline;
|
||||||
int loadedChunks = getLoadedChunks();
|
int loadedChunks = getLoadedChunks();
|
||||||
int entityCount;
|
int entityCount;
|
||||||
|
@ -4,10 +4,19 @@ import com.djrapitops.plan.system.info.InfoSystem;
|
|||||||
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class NetworkPageRefreshTask extends AbsRunnable {
|
public class NetworkPageRefreshTask extends AbsRunnable {
|
||||||
|
|
||||||
|
private InfoSystem infoSystem;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public NetworkPageRefreshTask(InfoSystem infoSystem) {
|
||||||
|
this.infoSystem = infoSystem;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
WebExceptionLogger.logIfOccurs(this.getClass(), () -> InfoSystem.getInstance().updateNetworkPage());
|
WebExceptionLogger.logIfOccurs(this.getClass(), () -> infoSystem.updateNetworkPage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,23 @@ package com.djrapitops.plan.system.tasks.server;
|
|||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class PaperTPSCountTimer extends BukkitTPSCountTimer {
|
public class PaperTPSCountTimer extends BukkitTPSCountTimer {
|
||||||
|
|
||||||
public PaperTPSCountTimer(Plan plugin) {
|
@Inject
|
||||||
super(plugin);
|
public PaperTPSCountTimer(
|
||||||
|
Plan plugin,
|
||||||
|
ServerProperties serverProperties,
|
||||||
|
PluginLogger logger,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
super(plugin, serverProperties, logger, errorHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,24 +5,46 @@ import com.djrapitops.plan.system.info.InfoSystem;
|
|||||||
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
||||||
import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.logging.L;
|
||||||
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class PeriodicAnalysisTask extends AbsRunnable {
|
public class PeriodicAnalysisTask extends AbsRunnable {
|
||||||
|
|
||||||
|
private final InfoSystem infoSystem;
|
||||||
|
private final ServerInfo serverInfo;
|
||||||
|
private final PluginLogger logger;
|
||||||
|
private final ErrorHandler errorHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PeriodicAnalysisTask(
|
||||||
|
InfoSystem infoSystem,
|
||||||
|
ServerInfo serverInfo,
|
||||||
|
PluginLogger logger,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
this.infoSystem = infoSystem;
|
||||||
|
this.serverInfo = serverInfo;
|
||||||
|
this.logger = logger;
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
||||||
InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID_Old()))
|
infoSystem.sendRequest(new GenerateAnalysisPageRequest(serverInfo.getServerUUID()))
|
||||||
);
|
);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
if (!PlanPlugin.getInstance().isReloading()) {
|
if (!PlanPlugin.getInstance().isReloading()) {
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||||
Log.error("Periodic Analysis Task Disabled due to error, reload Plan to re-enable.");
|
logger.error("Periodic Analysis Task Disabled due to error, reload Plan to re-enable.");
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,13 @@ public class PingCountTimer extends AbsRunnable implements Listener {
|
|||||||
pingField = localPing;
|
pingField = localPing;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory = new HashMap<>();
|
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
private final RunnableFactory runnableFactory;
|
||||||
|
|
||||||
|
public PingCountTimer(RunnableFactory runnableFactory) {
|
||||||
|
this.runnableFactory = runnableFactory;
|
||||||
|
playerHistory = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isPingMethodAvailable() {
|
private static boolean isPingMethodAvailable() {
|
||||||
try {
|
try {
|
||||||
@ -153,7 +159,7 @@ public class PingCountTimer extends AbsRunnable implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
||||||
Player player = joinEvent.getPlayer();
|
Player player = joinEvent.getPlayer();
|
||||||
RunnableFactory.createNew("Add Player to Ping list", new AbsRunnable() {
|
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
|
@ -1,23 +1,28 @@
|
|||||||
package com.djrapitops.plan.system.tasks.server;
|
package com.djrapitops.plan.system.tasks.server;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanSponge;
|
|
||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
import com.djrapitops.plan.data.container.builders.TPSBuilder;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.OperatingSystemMXBean;
|
import java.lang.management.OperatingSystemMXBean;
|
||||||
|
|
||||||
public class SpongeTPSCountTimer extends TPSCountTimer {
|
public class SpongeTPSCountTimer extends TPSCountTimer {
|
||||||
|
|
||||||
private long lastCheckNano;
|
private long lastCheckNano;
|
||||||
|
private ServerProperties serverProperties;
|
||||||
|
|
||||||
public SpongeTPSCountTimer(PlanSponge plugin) {
|
@Inject
|
||||||
super();
|
public SpongeTPSCountTimer(ServerProperties serverProperties, PluginLogger logger, ErrorHandler errorHandler) {
|
||||||
|
super(logger, errorHandler);
|
||||||
|
this.serverProperties = serverProperties;
|
||||||
lastCheckNano = -1;
|
lastCheckNano = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +61,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer {
|
|||||||
long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000;
|
long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000;
|
||||||
|
|
||||||
double tps = Sponge.getGame().getServer().getTicksPerSecond();
|
double tps = Sponge.getGame().getServer().getTicksPerSecond();
|
||||||
int playersOnline = ServerInfo.getServerProperties_Old().getOnlinePlayers();
|
int playersOnline = serverProperties.getOnlinePlayers();
|
||||||
latestPlayersOnline = playersOnline;
|
latestPlayersOnline = playersOnline;
|
||||||
int loadedChunks = -1; // getLoadedChunks();
|
int loadedChunks = -1; // getLoadedChunks();
|
||||||
int entityCount = getEntityCount();
|
int entityCount = getEntityCount();
|
||||||
|
Loading…
Reference in New Issue
Block a user