mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 05:57:50 +01:00
[Merge] Merge apf-3.3.0-merging to apf-3.3.0
This Commit fixes merge and commit issues in the merge.
This commit is contained in:
parent
e6a263e071
commit
25b35ac4ca
@ -26,7 +26,7 @@ import com.djrapitops.plan.modules.FilesModule;
|
|||||||
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
||||||
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
||||||
import com.djrapitops.plan.modules.server.ServerSuperClassBindingModule;
|
import com.djrapitops.plan.modules.server.ServerSuperClassBindingModule;
|
||||||
import com.djrapitops.plan.modules.server.bukkit.BukkitInfoModule;
|
import com.djrapitops.plan.modules.server.bukkit.BukkitServerPropertiesModule;
|
||||||
import com.djrapitops.plan.modules.server.bukkit.BukkitSuperClassBindingModule;
|
import com.djrapitops.plan.modules.server.bukkit.BukkitSuperClassBindingModule;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.locale.Locale;
|
import com.djrapitops.plan.system.locale.Locale;
|
||||||
@ -55,7 +55,7 @@ import java.util.logging.Logger;
|
|||||||
SystemObjectBindingModule.class,
|
SystemObjectBindingModule.class,
|
||||||
APFModule.class,
|
APFModule.class,
|
||||||
FilesModule.class,
|
FilesModule.class,
|
||||||
BukkitInfoModule.class,
|
BukkitServerPropertiesModule.class,
|
||||||
ServerSuperClassBindingModule.class,
|
ServerSuperClassBindingModule.class,
|
||||||
BukkitSuperClassBindingModule.class
|
BukkitSuperClassBindingModule.class
|
||||||
})
|
})
|
||||||
|
@ -10,8 +10,9 @@ import com.djrapitops.plan.modules.APFModule;
|
|||||||
import com.djrapitops.plan.modules.FilesModule;
|
import com.djrapitops.plan.modules.FilesModule;
|
||||||
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
||||||
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
||||||
import com.djrapitops.plan.modules.bungee.BungeeInfoModule;
|
import com.djrapitops.plan.modules.proxy.ProxySuperClassBindingModule;
|
||||||
import com.djrapitops.plan.modules.bungee.BungeeSuperClassBindingModule;
|
import com.djrapitops.plan.modules.proxy.bungee.BungeeServerPropertiesModule;
|
||||||
|
import com.djrapitops.plan.modules.proxy.bungee.BungeeSuperClassBindingModule;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.locale.Locale;
|
import com.djrapitops.plan.system.locale.Locale;
|
||||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||||
@ -37,8 +38,9 @@ import java.io.InputStream;
|
|||||||
SystemObjectBindingModule.class,
|
SystemObjectBindingModule.class,
|
||||||
APFModule.class,
|
APFModule.class,
|
||||||
FilesModule.class,
|
FilesModule.class,
|
||||||
|
ProxySuperClassBindingModule.class,
|
||||||
BungeeSuperClassBindingModule.class,
|
BungeeSuperClassBindingModule.class,
|
||||||
BungeeInfoModule.class
|
BungeeServerPropertiesModule.class
|
||||||
})
|
})
|
||||||
interface PlanBungeeComponent {
|
interface PlanBungeeComponent {
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.djrapitops.plan.modules.FilesModule;
|
|||||||
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
||||||
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
||||||
import com.djrapitops.plan.modules.server.ServerSuperClassBindingModule;
|
import com.djrapitops.plan.modules.server.ServerSuperClassBindingModule;
|
||||||
import com.djrapitops.plan.modules.server.sponge.SpongeInfoModule;
|
import com.djrapitops.plan.modules.server.sponge.SpongeServerPropertiesModule;
|
||||||
import com.djrapitops.plan.modules.server.sponge.SpongeSuperClassBindingModule;
|
import com.djrapitops.plan.modules.server.sponge.SpongeSuperClassBindingModule;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.locale.Locale;
|
import com.djrapitops.plan.system.locale.Locale;
|
||||||
@ -18,7 +18,6 @@ import com.djrapitops.plugin.SpongePlugin;
|
|||||||
import com.djrapitops.plugin.command.ColorScheme;
|
import com.djrapitops.plugin.command.ColorScheme;
|
||||||
import com.djrapitops.plugin.command.CommandNode;
|
import com.djrapitops.plugin.command.CommandNode;
|
||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.google.inject.Inject;
|
|
||||||
import dagger.BindsInstance;
|
import dagger.BindsInstance;
|
||||||
import dagger.Component;
|
import dagger.Component;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
@ -46,7 +45,7 @@ import java.io.InputStream;
|
|||||||
FilesModule.class,
|
FilesModule.class,
|
||||||
ServerSuperClassBindingModule.class,
|
ServerSuperClassBindingModule.class,
|
||||||
SpongeSuperClassBindingModule.class,
|
SpongeSuperClassBindingModule.class,
|
||||||
SpongeInfoModule.class
|
SpongeServerPropertiesModule.class
|
||||||
})
|
})
|
||||||
interface PlanSpongeComponent {
|
interface PlanSpongeComponent {
|
||||||
|
|
||||||
@ -94,13 +93,13 @@ class SpongePlanModule {
|
|||||||
)
|
)
|
||||||
public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||||
|
|
||||||
@Inject
|
@com.google.inject.Inject
|
||||||
private Metrics metrics;
|
private Metrics metrics;
|
||||||
|
|
||||||
@Inject
|
@com.google.inject.Inject
|
||||||
private Logger slf4jLogger;
|
private Logger slf4jLogger;
|
||||||
|
|
||||||
@Inject
|
@com.google.inject.Inject
|
||||||
@ConfigDir(sharedRoot = false)
|
@ConfigDir(sharedRoot = false)
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
private PlanSystem system;
|
private PlanSystem system;
|
||||||
|
@ -6,29 +6,83 @@ package com.djrapitops.plan;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.command.PlanVelocityCommand;
|
import com.djrapitops.plan.command.PlanVelocityCommand;
|
||||||
import com.djrapitops.plan.system.VelocitySystem;
|
import com.djrapitops.plan.modules.APFModule;
|
||||||
|
import com.djrapitops.plan.modules.FilesModule;
|
||||||
|
import com.djrapitops.plan.modules.SuperClassBindingModule;
|
||||||
|
import com.djrapitops.plan.modules.SystemObjectBindingModule;
|
||||||
|
import com.djrapitops.plan.modules.proxy.ProxySuperClassBindingModule;
|
||||||
|
import com.djrapitops.plan.modules.proxy.velocity.VelocityServerPropertiesModule;
|
||||||
|
import com.djrapitops.plan.modules.proxy.velocity.VelocitySuperClassBindingModule;
|
||||||
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.locale.Locale;
|
import com.djrapitops.plan.system.locale.Locale;
|
||||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
|
||||||
import com.djrapitops.plugin.VelocityPlugin;
|
import com.djrapitops.plugin.VelocityPlugin;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
import com.djrapitops.plugin.command.ColorScheme;
|
||||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
import com.djrapitops.plugin.command.CommandNode;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.settings.ColorScheme;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import dagger.BindsInstance;
|
||||||
|
import dagger.Component;
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
VelocityPlanModule.class,
|
||||||
|
SuperClassBindingModule.class,
|
||||||
|
SystemObjectBindingModule.class,
|
||||||
|
APFModule.class,
|
||||||
|
FilesModule.class,
|
||||||
|
ProxySuperClassBindingModule.class,
|
||||||
|
VelocitySuperClassBindingModule.class,
|
||||||
|
VelocityServerPropertiesModule.class
|
||||||
|
})
|
||||||
|
interface PlanVelocityComponent {
|
||||||
|
|
||||||
|
PlanVelocityCommand planCommand();
|
||||||
|
|
||||||
|
PlanSystem system();
|
||||||
|
|
||||||
|
@Component.Builder
|
||||||
|
interface Builder {
|
||||||
|
|
||||||
|
@BindsInstance
|
||||||
|
Builder plan(PlanVelocity plan);
|
||||||
|
|
||||||
|
PlanVelocityComponent build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Module
|
||||||
|
class VelocityPlanModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
PlanPlugin providePlanPlugin(PlanVelocity plugin) {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Named("mainCommand")
|
||||||
|
CommandNode provideMainCommand(PlanVelocityCommand command) {
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Velocity Main class.
|
* Velocity Main class.
|
||||||
*
|
* <p>
|
||||||
* Based on the PlanBungee class
|
* Based on the PlanBungee class
|
||||||
*
|
*
|
||||||
* @author MicleBrick
|
* @author MicleBrick
|
||||||
@ -36,16 +90,16 @@ import java.nio.file.Path;
|
|||||||
@Plugin(id = "plan", name = "Plan", version = "4.4.6", description = "Player Analytics Plugin by Rsl1122", authors = {"Rsl1122"})
|
@Plugin(id = "plan", name = "Plan", version = "4.4.6", description = "Player Analytics Plugin by Rsl1122", authors = {"Rsl1122"})
|
||||||
public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
||||||
|
|
||||||
private VelocitySystem system;
|
private PlanSystem system;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
|
|
||||||
public static PlanVelocity getInstance() {
|
@com.google.inject.Inject
|
||||||
return (PlanVelocity) StaticHolder.getInstance(PlanVelocity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
@DataDirectory
|
@DataDirectory
|
||||||
private Path dataFolderPath;
|
private Path dataFolderPath;
|
||||||
|
@com.google.inject.Inject
|
||||||
|
private ProxyServer proxy;
|
||||||
|
@com.google.inject.Inject
|
||||||
|
private Logger slf4jLogger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getDataFolder() {
|
public File getDataFolder() {
|
||||||
@ -54,45 +108,39 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
PlanVelocityComponent component = DaggerPlanVelocityComponent.builder().plan(this).build();
|
||||||
try {
|
try {
|
||||||
system = new VelocitySystem(this);
|
system = component.system();
|
||||||
locale = system.getLocaleSystem().getLocale();
|
locale = system.getLocaleSystem().getLocale();
|
||||||
system.enable();
|
system.enable();
|
||||||
|
|
||||||
Log.info(locale.getString(PluginLang.ENABLED));
|
logger.info(locale.getString(PluginLang.ENABLED));
|
||||||
} catch (AbstractMethodError e) {
|
} catch (AbstractMethodError e) {
|
||||||
Log.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
logger.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart.");
|
||||||
} catch (EnableException e) {
|
} catch (EnableException e) {
|
||||||
Log.error("----------------------------------------");
|
logger.error("----------------------------------------");
|
||||||
Log.error("Error: " + e.getMessage());
|
logger.error("Error: " + e.getMessage());
|
||||||
Log.error("----------------------------------------");
|
logger.error("----------------------------------------");
|
||||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planvelocity reload");
|
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||||
onDisable();
|
onDisable();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().error(this.getClass().getSimpleName() + "-v" + getVersion(), e);
|
errorHandler.log(L.CRITICAL, this.getClass(), e);
|
||||||
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planvelocity reload");
|
logger.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /planbungee reload");
|
||||||
Log.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
logger.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues");
|
||||||
onDisable();
|
onDisable();
|
||||||
}
|
}
|
||||||
registerCommand("planvelocity", new PlanVelocityCommand(this));
|
PlanVelocityCommand command = component.planCommand();
|
||||||
|
command.registerCommands();
|
||||||
|
registerCommand("planvelocity", command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
system.disable();
|
system.disable();
|
||||||
|
|
||||||
Log.info(locale.getString(PluginLang.DISABLED));
|
slf4jLogger.info(locale.getString(PluginLang.DISABLED));
|
||||||
Benchmark.pluginDisabled(PlanVelocity.class);
|
|
||||||
DebugLog.pluginDisabled(PlanVelocity.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() {
|
|
||||||
return getClass().getAnnotation(Plugin.class).version();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReload() {
|
public void onReload() {
|
||||||
// Nothing to be done, systems are disabled
|
// Nothing to be done, systems are disabled
|
||||||
@ -105,11 +153,11 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ColorScheme getColorScheme() {
|
public ColorScheme getColorScheme() {
|
||||||
return PlanColorScheme.create();
|
return PlanColorScheme.create(system.getConfigSystem().getConfig(), logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VelocitySystem getSystem() {
|
public PlanSystem getSystem() {
|
||||||
return system;
|
return system;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,19 +166,13 @@ public class PlanVelocity extends VelocityPlugin implements PlanPlugin {
|
|||||||
return reloading;
|
return reloading;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ProxyServer proxy;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProxyServer getProxy() {
|
public ProxyServer getProxy() {
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Logger logger;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Logger getLogger() {
|
protected Logger getLogger() {
|
||||||
return logger;
|
return slf4jLogger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,18 @@ import javax.inject.Singleton;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlanAPI extension for Bungee.
|
* PlanAPI extension for proxy servers.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BungeeAPI extends CommonAPI {
|
public class ProxyAPI extends CommonAPI {
|
||||||
|
|
||||||
private final HookHandler hookHandler;
|
private final HookHandler hookHandler;
|
||||||
private final Database database;
|
private final Database database;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BungeeAPI(
|
public ProxyAPI(
|
||||||
UUIDUtility uuidUtility,
|
UUIDUtility uuidUtility,
|
||||||
Database database,
|
Database database,
|
||||||
HookHandler hookHandler,
|
HookHandler hookHandler,
|
||||||
|
@ -25,7 +25,7 @@ import javax.inject.Singleton;
|
|||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PlanBungeeCommand extends TreeCmdNode {
|
public class PlanVelocityCommand extends TreeCmdNode {
|
||||||
|
|
||||||
private final NetworkCommand networkCommand;
|
private final NetworkCommand networkCommand;
|
||||||
private final ListServersCommand listServersCommand;
|
private final ListServersCommand listServersCommand;
|
||||||
@ -42,7 +42,7 @@ public class PlanBungeeCommand extends TreeCmdNode {
|
|||||||
private boolean commandsRegistered;
|
private boolean commandsRegistered;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PlanBungeeCommand(
|
public PlanVelocityCommand(
|
||||||
ColorScheme colorScheme,
|
ColorScheme colorScheme,
|
||||||
Locale locale,
|
Locale locale,
|
||||||
// Group 1
|
// Group 1
|
||||||
@ -60,7 +60,7 @@ public class PlanBungeeCommand extends TreeCmdNode {
|
|||||||
ReloadCommand reloadCommand,
|
ReloadCommand reloadCommand,
|
||||||
DisableCommand disableCommand
|
DisableCommand disableCommand
|
||||||
) {
|
) {
|
||||||
super("planbungee", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
|
super("planvelocity", Permissions.MANAGE.getPermission(), CommandType.CONSOLE, null);
|
||||||
this.uninstalledCommand = uninstalledCommand;
|
this.uninstalledCommand = uninstalledCommand;
|
||||||
|
|
||||||
commandsRegistered = false;
|
commandsRegistered = false;
|
||||||
|
@ -36,7 +36,6 @@ public class ManageUninstalledCommand extends CommandNode {
|
|||||||
private final Database database;
|
private final Database database;
|
||||||
private final ErrorHandler errorHandler;
|
private final ErrorHandler errorHandler;
|
||||||
private final ServerInfo serverInfo;
|
private final ServerInfo serverInfo;
|
||||||
private final ConnectionSystem connectionSystem;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ManageUninstalledCommand(
|
public ManageUninstalledCommand(
|
||||||
@ -44,7 +43,6 @@ public class ManageUninstalledCommand extends CommandNode {
|
|||||||
Processing processing,
|
Processing processing,
|
||||||
Database database,
|
Database database,
|
||||||
ServerInfo serverInfo,
|
ServerInfo serverInfo,
|
||||||
ConnectionSystem connectionSystem,
|
|
||||||
ErrorHandler errorHandler
|
ErrorHandler errorHandler
|
||||||
) {
|
) {
|
||||||
super("uninstalled", Permissions.MANAGE.getPermission(), CommandType.ALL_WITH_ARGS);
|
super("uninstalled", Permissions.MANAGE.getPermission(), CommandType.ALL_WITH_ARGS);
|
||||||
@ -53,7 +51,6 @@ public class ManageUninstalledCommand extends CommandNode {
|
|||||||
this.processing = processing;
|
this.processing = processing;
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.serverInfo = serverInfo;
|
this.serverInfo = serverInfo;
|
||||||
this.connectionSystem = connectionSystem;
|
|
||||||
this.errorHandler = errorHandler;
|
this.errorHandler = errorHandler;
|
||||||
|
|
||||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_UNINSTALLED));
|
setShortHelp(locale.getString(CmdHelpLang.MANAGE_UNINSTALLED));
|
||||||
|
@ -155,8 +155,17 @@ public class Session extends DataContainer implements DateHolder {
|
|||||||
this.worldTimes = worldTimes;
|
this.worldTimes = worldTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerKills(List<PlayerKill> playerKills) {
|
@Override
|
||||||
this.playerKills = playerKills;
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Session session = (Session) o;
|
||||||
|
return getUnsafe(SessionKeys.START).equals(session.getUnsafe(SessionKeys.START)) &&
|
||||||
|
getValue(SessionKeys.END).orElse(-1L).equals(session.getValue(SessionKeys.END).orElse(-1L)) &&
|
||||||
|
mobKills == session.mobKills &&
|
||||||
|
deaths == session.deaths &&
|
||||||
|
Objects.equals(playerKills, session.playerKills) &&
|
||||||
|
Objects.equals(worldTimes, session.worldTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFetchedFromDB() {
|
public boolean isFetchedFromDB() {
|
||||||
@ -171,17 +180,8 @@ public class Session extends DataContainer implements DateHolder {
|
|||||||
putRawData(SessionKeys.DB_ID, sessionID);
|
putRawData(SessionKeys.DB_ID, sessionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<PlayerKill> getPlayerKills() {
|
||||||
public boolean equals(Object o) {
|
return playerKills;
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Session session = (Session) o;
|
|
||||||
return getUnsafe(SessionKeys.START).equals(session.getUnsafe(SessionKeys.START)) &&
|
|
||||||
getValue(SessionKeys.END).orElse(-1L).equals(session.getValue(SessionKeys.END).orElse(-1L)) &&
|
|
||||||
mobKills == session.mobKills &&
|
|
||||||
deaths == session.deaths &&
|
|
||||||
Objects.equals(playerKills, session.playerKills) &&
|
|
||||||
Objects.equals(worldTimes, session.worldTimes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -197,8 +197,8 @@ public class Session extends DataContainer implements DateHolder {
|
|||||||
return worldTimes;
|
return worldTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerKill> getPlayerKills() {
|
public void setPlayerKills(List<PlayerKill> playerKills) {
|
||||||
return playerKills;
|
this.playerKills = playerKills;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMobKills() {
|
private int getMobKills() {
|
||||||
|
@ -458,7 +458,9 @@ public class AnalysisContainer extends DataContainer {
|
|||||||
private void addPluginSuppliers() {
|
private void addPluginSuppliers() {
|
||||||
// TODO Refactor into a system that supports running the analysis on Bungee
|
// TODO Refactor into a system that supports running the analysis on Bungee
|
||||||
Key<String[]> navAndTabs = new Key<>(new Type<String[]>() {}, "NAV_AND_TABS");
|
Key<String[]> navAndTabs = new Key<>(new Type<String[]>() {}, "NAV_AND_TABS");
|
||||||
putCachingSupplier(navAndTabs, () -> pluginsTabContentCreator.createContent(this));
|
putCachingSupplier(navAndTabs, () -> pluginsTabContentCreator.createContent(
|
||||||
|
this, getValue(AnalysisKeys.PLAYERS_MUTATOR).orElse(new PlayersMutator(new ArrayList<>()))
|
||||||
|
));
|
||||||
putSupplier(AnalysisKeys.PLUGINS_TAB_NAV, () -> getUnsafe(navAndTabs)[0]);
|
putSupplier(AnalysisKeys.PLUGINS_TAB_NAV, () -> getUnsafe(navAndTabs)[0]);
|
||||||
putSupplier(AnalysisKeys.PLUGINS_TAB, () -> getUnsafe(navAndTabs)[1]);
|
putSupplier(AnalysisKeys.PLUGINS_TAB, () -> getUnsafe(navAndTabs)[1]);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,64 @@
|
|||||||
package com.djrapitops.plan.modules.bungee.proxy;
|
package com.djrapitops.plan.modules.proxy;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.api.PlanAPI;
|
||||||
|
import com.djrapitops.plan.api.ProxyAPI;
|
||||||
|
import com.djrapitops.plan.system.cache.DataCache;
|
||||||
|
import com.djrapitops.plan.system.cache.ProxyDataCache;
|
||||||
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
|
import com.djrapitops.plan.system.database.ProxyDBSystem;
|
||||||
|
import com.djrapitops.plan.system.importing.EmptyImportSystem;
|
||||||
|
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||||
|
import com.djrapitops.plan.system.info.InfoSystem;
|
||||||
|
import com.djrapitops.plan.system.info.ProxyInfoSystem;
|
||||||
|
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||||
|
import com.djrapitops.plan.system.info.connection.ProxyConnectionSystem;
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //TODO Class Javadoc Comment
|
* Dagger module for binding proxy server classes to super classes.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@Module
|
||||||
public class ProxySuperClassBindingModule {
|
public class ProxySuperClassBindingModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
PlanAPI provideProxyPlanAPI(ProxyAPI proxyAPI) {
|
||||||
|
return proxyAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
DBSystem provideProxyDatabaseSystem(ProxyDBSystem proxyDBSystem) {
|
||||||
|
return proxyDBSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
InfoSystem provideProxyInfoSystem(ProxyInfoSystem proxyInfoSystem) {
|
||||||
|
return proxyInfoSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ConnectionSystem provideProxyConnectionSystem(ProxyConnectionSystem proxyConnectionSystem) {
|
||||||
|
return proxyConnectionSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
DataCache provideProxyDataCache(ProxyDataCache proxyDataCache) {
|
||||||
|
return proxyDataCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ImportSystem provideImportSystem() {
|
||||||
|
return new EmptyImportSystem();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package com.djrapitops.plan.modules.bungee;
|
package com.djrapitops.plan.modules.proxy.bungee;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
|
||||||
import com.djrapitops.plan.system.info.server.properties.BungeeServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.BungeeServerProperties;
|
||||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
@ -13,18 +11,12 @@ import dagger.Provides;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dagger module for Bungee ServerInfo.
|
* Dagger module for Bungee ServerProperties.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Module
|
@Module
|
||||||
public class BungeeInfoModule {
|
public class BungeeServerPropertiesModule {
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
ServerInfo provideBungeeServerInfo(BungeeServerInfo bungeeServerInfo) {
|
|
||||||
return bungeeServerInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
package com.djrapitops.plan.modules.bungee;
|
package com.djrapitops.plan.modules.proxy.bungee;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.BungeeAPI;
|
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||||
import com.djrapitops.plan.api.PlanAPI;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.database.BungeeDBSystem;
|
|
||||||
import com.djrapitops.plan.system.database.DBSystem;
|
|
||||||
import com.djrapitops.plan.system.importing.EmptyImportSystem;
|
|
||||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
|
||||||
import com.djrapitops.plan.system.info.BungeeInfoSystem;
|
|
||||||
import com.djrapitops.plan.system.info.InfoSystem;
|
|
||||||
import com.djrapitops.plan.system.info.connection.BungeeConnectionSystem;
|
|
||||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
|
||||||
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
||||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.BungeeConfigSystem;
|
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
|
import com.djrapitops.plan.system.settings.config.ProxyConfigSystem;
|
||||||
import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
|
import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
|
||||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
@ -31,32 +23,14 @@ public class BungeeSuperClassBindingModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
PlanAPI provideBungeePlanAPI(BungeeAPI bungeeAPI) {
|
ServerInfo provideBungeeServerInfo(BungeeServerInfo bungeeServerInfo) {
|
||||||
return bungeeAPI;
|
return bungeeServerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
DBSystem provideBungeeDatabaseSystem(BungeeDBSystem dbSystem) {
|
ConfigSystem provideBungeeConfigSystem(ProxyConfigSystem proxyConfigSystem) {
|
||||||
return dbSystem;
|
return proxyConfigSystem;
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
ConfigSystem provideBungeeConfigSystem(BungeeConfigSystem bungeeConfigSystem) {
|
|
||||||
return bungeeConfigSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
InfoSystem provideBungeeInfoSystem(BungeeInfoSystem bungeeInfoSystem) {
|
|
||||||
return bungeeInfoSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
ConnectionSystem provideBungeeConnectionSystem(BungeeConnectionSystem bungeeConnectionSystem) {
|
|
||||||
return bungeeConnectionSystem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -70,11 +44,4 @@ public class BungeeSuperClassBindingModule {
|
|||||||
ListenerSystem provideBungeeListenerSystem(BungeeListenerSystem bungeeListenerSystem) {
|
ListenerSystem provideBungeeListenerSystem(BungeeListenerSystem bungeeListenerSystem) {
|
||||||
return bungeeListenerSystem;
|
return bungeeListenerSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
ImportSystem provideImportSystem() {
|
|
||||||
return new EmptyImportSystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,27 @@
|
|||||||
package com.djrapitops.plan.modules.proxy.velocity;
|
package com.djrapitops.plan.modules.proxy.velocity;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.PlanVelocity;
|
||||||
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
|
import com.djrapitops.plan.system.info.server.properties.VelocityServerProperties;
|
||||||
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //TODO Class Javadoc Comment
|
* Dagger module for Bungee ServerProperties.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class VelocityServerProperties {
|
@Module
|
||||||
|
public class VelocityServerPropertiesModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ServerProperties provideServerProperties(PlanVelocity plugin, PlanConfig config) {
|
||||||
|
return new VelocityServerProperties(plugin.getProxy(), config.getString(Settings.BUNGEE_IP));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
package com.djrapitops.plan.modules.proxy.bungee;
|
package com.djrapitops.plan.modules.proxy.velocity;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
import com.djrapitops.plan.system.info.server.VelocityServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.BungeeConfigSystem;
|
import com.djrapitops.plan.system.listeners.VelocityListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
import com.djrapitops.plan.system.tasks.BungeeTaskSystem;
|
import com.djrapitops.plan.system.settings.config.ProxyConfigSystem;
|
||||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||||
|
import com.djrapitops.plan.system.tasks.VelocityTaskSystem;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module for binding Bungee specific classes to the interface implementations.
|
* Module for binding Velocity specific classes to the interface implementations.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Module
|
@Module
|
||||||
public class BungeeSuperClassBindingModule {
|
public class VelocitySuperClassBindingModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ServerInfo provideBungeeServerInfo(BungeeServerInfo bungeeServerInfo) {
|
ServerInfo provideVelocityServerInfo(VelocityServerInfo velocityServerInfo) {
|
||||||
return bungeeServerInfo;
|
return velocityServerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ConfigSystem provideBungeeConfigSystem(BungeeConfigSystem bungeeConfigSystem) {
|
ConfigSystem provideVelocityConfigSystem(ProxyConfigSystem proxyConfigSystem) {
|
||||||
return bungeeConfigSystem;
|
return proxyConfigSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
TaskSystem provideBungeeTaskSystem(BungeeTaskSystem bungeeTaskSystem) {
|
TaskSystem provideVelocityTaskSystem(VelocityTaskSystem velocityTaskSystem) {
|
||||||
return bungeeTaskSystem;
|
return velocityTaskSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ListenerSystem provideBungeeListenerSystem(BungeeListenerSystem bungeeListenerSystem) {
|
ListenerSystem provideVelocityListenerSystem(VelocityListenerSystem velocityListenerSystem) {
|
||||||
return bungeeListenerSystem;
|
return velocityListenerSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
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;
|
||||||
@ -11,18 +9,12 @@ import dagger.Provides;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dagger module for Bukkit ServerInfo.
|
* Dagger module for Bukkit ServerProperties.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Module
|
@Module
|
||||||
public class BukkitInfoModule {
|
public class BukkitServerPropertiesModule {
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
ServerInfo provideBukkitServerInfo(BukkitServerInfo bukkitServerInfo) {
|
|
||||||
return bukkitServerInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -4,6 +4,8 @@ import com.djrapitops.plan.system.database.BukkitDBSystem;
|
|||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.importing.BukkitImportSystem;
|
import com.djrapitops.plan.system.importing.BukkitImportSystem;
|
||||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||||
|
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
|
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
|
||||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.BukkitConfigSystem;
|
import com.djrapitops.plan.system.settings.config.BukkitConfigSystem;
|
||||||
@ -23,6 +25,12 @@ import javax.inject.Singleton;
|
|||||||
@Module
|
@Module
|
||||||
public class BukkitSuperClassBindingModule {
|
public class BukkitSuperClassBindingModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ServerInfo provideBukkitServerInfo(BukkitServerInfo bukkitServerInfo) {
|
||||||
|
return bukkitServerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
DBSystem provideBukkitDatabaseSystem(BukkitDBSystem dbSystem) {
|
DBSystem provideBukkitDatabaseSystem(BukkitDBSystem dbSystem) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
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;
|
||||||
@ -11,18 +9,12 @@ import org.spongepowered.api.Sponge;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dagger module for Sponge ServerInfo.
|
* Dagger module for Sponge ServerProperties.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Module
|
@Module
|
||||||
public class SpongeInfoModule {
|
public class SpongeServerPropertiesModule {
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
ServerInfo provideSpongeServerInfo(SpongeServerInfo spongeServerInfo) {
|
|
||||||
return spongeServerInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -4,6 +4,8 @@ import com.djrapitops.plan.system.database.DBSystem;
|
|||||||
import com.djrapitops.plan.system.database.SpongeDBSystem;
|
import com.djrapitops.plan.system.database.SpongeDBSystem;
|
||||||
import com.djrapitops.plan.system.importing.EmptyImportSystem;
|
import com.djrapitops.plan.system.importing.EmptyImportSystem;
|
||||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.SpongeServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||||
import com.djrapitops.plan.system.listeners.SpongeListenerSystem;
|
import com.djrapitops.plan.system.listeners.SpongeListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
@ -23,6 +25,12 @@ import javax.inject.Singleton;
|
|||||||
@Module
|
@Module
|
||||||
public class SpongeSuperClassBindingModule {
|
public class SpongeSuperClassBindingModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ServerInfo provideSpongeServerInfo(SpongeServerInfo spongeServerInfo) {
|
||||||
|
return spongeServerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
DBSystem provideSpongeDatabaseSystem(SpongeDBSystem dbSystem) {
|
DBSystem provideSpongeDatabaseSystem(SpongeDBSystem dbSystem) {
|
||||||
|
@ -8,12 +8,14 @@ import com.djrapitops.plan.api.exceptions.EnableException;
|
|||||||
import com.djrapitops.plan.system.SubSystem;
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System that holds data caches of the plugin.
|
* System that holds data caches of the plugin.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class CacheSystem implements SubSystem {
|
public class CacheSystem implements SubSystem {
|
||||||
|
|
||||||
private final DataCache dataCache;
|
private final DataCache dataCache;
|
||||||
|
@ -23,7 +23,7 @@ public class ProxyDBSystem extends DBSystem {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ProxyDBSystem(Locale locale, MySQLDB mySQLDB,
|
public ProxyDBSystem(Locale locale, MySQLDB mySQLDB,
|
||||||
PluginLogger logger, Timings timings, ErrorHandler errorHandler) {
|
PluginLogger logger, Timings timings, ErrorHandler errorHandler) {
|
||||||
super(locale, logger, timings, errorHandler);
|
super(locale, logger, timings, errorHandler);
|
||||||
databases.add(mySQLDB);
|
databases.add(mySQLDB);
|
||||||
db = mySQLDB;
|
db = mySQLDB;
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql;
|
package com.djrapitops.plan.system.database.databases.sql;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.patches.Patch;
|
import com.djrapitops.plan.system.database.databases.sql.patches.Patch;
|
||||||
import com.djrapitops.plan.system.locale.Locale;
|
import com.djrapitops.plan.system.locale.Locale;
|
||||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||||
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.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task that is in charge on patching the database when the database enables.
|
* Task that is in charge on patching the database when the database enables.
|
||||||
*
|
*
|
||||||
@ -17,26 +16,30 @@ import java.util.function.Supplier;
|
|||||||
public class PatchTask extends AbsRunnable {
|
public class PatchTask extends AbsRunnable {
|
||||||
|
|
||||||
private final Patch[] patches;
|
private final Patch[] patches;
|
||||||
private final Supplier<Locale> locale;
|
|
||||||
|
|
||||||
public PatchTask(Patch[] patches, Supplier<Locale> locale) {
|
private final Locale locale;
|
||||||
|
private final PluginLogger logger;
|
||||||
|
private final ErrorHandler errorHandler;
|
||||||
|
|
||||||
|
public PatchTask(Patch[] patches, Locale locale, PluginLogger logger, ErrorHandler errorHandler) {
|
||||||
this.patches = patches;
|
this.patches = patches;
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
|
this.logger = logger;
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
boolean didApply = applyPatches();
|
boolean applied = applyPatches();
|
||||||
Log.info(locale.get().getString(
|
logger.info(locale.getString(
|
||||||
didApply ? PluginLang.DB_APPLIED_PATCHES : PluginLang.DB_APPLIED_PATCHES_ALREADY
|
applied ? PluginLang.DB_APPLIED_PATCHES : PluginLang.DB_APPLIED_PATCHES_ALREADY
|
||||||
));
|
));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.error("----------------------------------------------------");
|
logger.error("----------------------------------------------------");
|
||||||
Log.error(locale.get().getString(PluginLang.ENABLE_FAIL_DB_PATCH));
|
logger.error(locale.getString(PluginLang.ENABLE_FAIL_DB_PATCH));
|
||||||
Log.error("----------------------------------------------------");
|
logger.error("----------------------------------------------------");
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.CRITICAL, this.getClass(), e);
|
||||||
PlanPlugin.getInstance().onDisable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +48,7 @@ public class PatchTask extends AbsRunnable {
|
|||||||
for (Patch patch : patches) {
|
for (Patch patch : patches) {
|
||||||
if (!patch.hasBeenApplied()) {
|
if (!patch.hasBeenApplied()) {
|
||||||
String patchName = patch.getClass().getSimpleName();
|
String patchName = patch.getClass().getSimpleName();
|
||||||
Log.info(locale.get().getString(PluginLang.DB_APPLY_PATCH, patchName));
|
logger.info(locale.getString(PluginLang.DB_APPLY_PATCH, patchName));
|
||||||
patch.apply();
|
patch.apply();
|
||||||
didApply = true;
|
didApply = true;
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,8 @@ public abstract class SQLDB extends Database {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runnableFactory.createNew("Database Patch", new PatchTask(patches, locale))
|
runnableFactory.create("Database Patch", new PatchTask(patches, locale, logger, errorHandler))
|
||||||
.runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L);
|
.runTaskLaterAsynchronously(TimeAmount.toTicks(5L, TimeUnit.SECONDS));
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
// Task failed to register because plugin is being disabled
|
// Task failed to register because plugin is being disabled
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import com.djrapitops.plan.system.cache.SessionCache;
|
|||||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.info.server.Server;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -94,9 +94,9 @@ public class ProxyConnectionSystem extends ConnectionSystem {
|
|||||||
for (Server server : bukkitServers.values()) {
|
for (Server server : bukkitServers.values()) {
|
||||||
webExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server));
|
webExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server));
|
||||||
}
|
}
|
||||||
// Quick hack
|
// Quick hack for Bungee Plugins Tab
|
||||||
if (infoRequest instanceof GenerateInspectPluginsTabRequest) {
|
if (infoRequest instanceof GenerateInspectPluginsTabRequest) {
|
||||||
webExceptionLogger.logIfOccurs(this.getClass(), () -> InfoSystem.getInstance().sendRequest(infoRequest));
|
webExceptionLogger.logIfOccurs(this.getClass(), infoRequest::runLocally);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,29 +4,42 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.info.server;
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanVelocity;
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.info.server.properties.VelocityServerProperties;
|
|
||||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
import com.djrapitops.plan.system.webserver.WebServer;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
|
import dagger.Lazy;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages Server information on the Velocity instance.
|
* Manages Server information on the Bungee instance.
|
||||||
*
|
*
|
||||||
* Based on BungeeServerInfo
|
* @author Rsl1122
|
||||||
*
|
|
||||||
* @author MicleBrick
|
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class VelocityServerInfo extends ServerInfo {
|
public class VelocityServerInfo extends ServerInfo {
|
||||||
|
|
||||||
public VelocityServerInfo(PlanVelocity plugin) {
|
private final Database database;
|
||||||
super(new VelocityServerProperties(plugin.getProxy()));
|
private final Lazy<WebServer> webServer;
|
||||||
|
private final PluginLogger logger;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public VelocityServerInfo(
|
||||||
|
ServerProperties serverProperties,
|
||||||
|
Database database,
|
||||||
|
Lazy<WebServer> webServer,
|
||||||
|
PluginLogger logger
|
||||||
|
) {
|
||||||
|
super(serverProperties);
|
||||||
|
this.database = database;
|
||||||
|
this.webServer = webServer;
|
||||||
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,14 +47,12 @@ public class VelocityServerInfo extends ServerInfo {
|
|||||||
checkIfDefaultIP();
|
checkIfDefaultIP();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Database db = Database.getActive();
|
Optional<Server> bungeeInfo = database.fetch().getBungeeInformation();
|
||||||
// doesn't seem like this would need to be different for velocity, perhaps rename to getProxyInformation()?
|
if (bungeeInfo.isPresent()) {
|
||||||
Optional<Server> velocityInfo = db.fetch().getBungeeInformation();
|
server = bungeeInfo.get();
|
||||||
if (velocityInfo.isPresent()) {
|
updateServerInfo(database);
|
||||||
server = velocityInfo.get();
|
|
||||||
updateServerInfo(db);
|
|
||||||
} else {
|
} else {
|
||||||
server = registerVelocityInfo(db);
|
server = registerVelocityInfo(database);
|
||||||
}
|
}
|
||||||
} catch (DBOpException e) {
|
} catch (DBOpException e) {
|
||||||
throw new EnableException("Failed to read Server information from Database.");
|
throw new EnableException("Failed to read Server information from Database.");
|
||||||
@ -50,7 +61,7 @@ public class VelocityServerInfo extends ServerInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateServerInfo(Database db) {
|
private void updateServerInfo(Database db) {
|
||||||
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
String accessAddress = webServer.get().getAccessAddress();
|
||||||
if (!accessAddress.equals(server.getWebAddress())) {
|
if (!accessAddress.equals(server.getWebAddress())) {
|
||||||
server.setWebAddress(accessAddress);
|
server.setWebAddress(accessAddress);
|
||||||
db.save().serverInfoForThisServer(server);
|
db.save().serverInfoForThisServer(server);
|
||||||
@ -58,31 +69,35 @@ public class VelocityServerInfo extends ServerInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfDefaultIP() throws EnableException {
|
private void checkIfDefaultIP() throws EnableException {
|
||||||
String ip = ServerInfo.getServerProperties().getIp();
|
String ip = serverProperties.getIp();
|
||||||
if ("0.0.0.0".equals(ip)) {
|
if ("0.0.0.0".equals(ip)) {
|
||||||
Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
logger.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
||||||
Log.info("Player Analytics partially enabled (Use /planvelocity to reload config)");
|
logger.info("Player Analytics partially enabled (Use /planbungee to reload config)");
|
||||||
throw new EnableException("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
throw new EnableException("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Server registerVelocityInfo(Database db) throws EnableException {
|
private Server registerVelocityInfo(Database db) throws EnableException {
|
||||||
ServerProperties properties = ServerInfo.getServerProperties();
|
UUID serverUUID = generateNewUUID();
|
||||||
UUID serverUUID = generateNewUUID(properties);
|
String accessAddress = webServer.get().getAccessAddress();
|
||||||
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
|
||||||
|
|
||||||
Server velocityCord = new Server(-1, serverUUID, "VelocityCord", accessAddress, properties.getMaxPlayers());
|
// TODO Rework to allow Velocity as name.
|
||||||
db.save().serverInfoForThisServer(velocityCord);
|
Server bungeeCord = new Server(-1, serverUUID, "BungeeCord", accessAddress, serverProperties.getMaxPlayers());
|
||||||
|
db.save().serverInfoForThisServer(bungeeCord);
|
||||||
|
|
||||||
Optional<Server> velocityInfo = db.fetch().getBungeeInformation();
|
Optional<Server> bungeeInfo = db.fetch().getBungeeInformation();
|
||||||
if (velocityInfo.isPresent()) {
|
if (bungeeInfo.isPresent()) {
|
||||||
return velocityInfo.get();
|
return bungeeInfo.get();
|
||||||
}
|
}
|
||||||
throw new EnableException("VelocityCord registration failed (DB)");
|
throw new EnableException("Velocity registration failed (DB)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID generateNewUUID(ServerProperties properties) {
|
private UUID generateNewUUID() {
|
||||||
String seed = properties.getName() + properties.getIp() + properties.getPort() + properties.getVersion() + properties.getImplVersion();
|
String seed = serverProperties.getName() +
|
||||||
|
serverProperties.getIp() +
|
||||||
|
serverProperties.getPort() +
|
||||||
|
serverProperties.getVersion() +
|
||||||
|
serverProperties.getImplVersion();
|
||||||
return UUID.nameUUIDFromBytes(seed.getBytes());
|
return UUID.nameUUIDFromBytes(seed.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.djrapitops.plan.system.info.server.properties;
|
package com.djrapitops.plan.system.info.server.properties;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +11,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||||||
*/
|
*/
|
||||||
public class VelocityServerProperties extends ServerProperties {
|
public class VelocityServerProperties extends ServerProperties {
|
||||||
|
|
||||||
public VelocityServerProperties(ProxyServer server) {
|
public VelocityServerProperties(ProxyServer server, String serverIP) {
|
||||||
super(
|
super(
|
||||||
server.getAllServers().toString(),
|
server.getAllServers().toString(),
|
||||||
"Velocity",
|
"Velocity",
|
||||||
@ -20,7 +19,7 @@ public class VelocityServerProperties extends ServerProperties {
|
|||||||
// not sure how to get these
|
// not sure how to get these
|
||||||
server.getClass().getPackage().getImplementationVersion(),
|
server.getClass().getPackage().getImplementationVersion(),
|
||||||
server.getClass().getPackage().getImplementationVersion(),
|
server.getClass().getPackage().getImplementationVersion(),
|
||||||
Settings.BUNGEE_IP::toString,
|
() -> serverIP,
|
||||||
-1, // not sure how to get this
|
-1, // not sure how to get this
|
||||||
RedisCheck.isClassAvailable() ? new RedisPlayersOnlineSupplier() : server::getPlayerCount
|
RedisCheck.isClassAvailable() ? new RedisPlayersOnlineSupplier() : server::getPlayerCount
|
||||||
);
|
);
|
||||||
|
@ -3,17 +3,28 @@ package com.djrapitops.plan.system.listeners;
|
|||||||
import com.djrapitops.plan.PlanVelocity;
|
import com.djrapitops.plan.PlanVelocity;
|
||||||
import com.djrapitops.plan.system.listeners.velocity.PlayerOnlineListener;
|
import com.djrapitops.plan.system.listeners.velocity.PlayerOnlineListener;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class VelocityListenerSystem extends ListenerSystem {
|
public class VelocityListenerSystem extends ListenerSystem {
|
||||||
|
|
||||||
private final PlanVelocity plugin;
|
private final PlanVelocity plugin;
|
||||||
|
|
||||||
public VelocityListenerSystem(PlanVelocity plugin) {
|
private final PlayerOnlineListener playerOnlineListener;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public VelocityListenerSystem(
|
||||||
|
PlanVelocity 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
|
||||||
|
@ -70,7 +70,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
|
|
||||||
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
|
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
|
||||||
|
|
||||||
processing.submit(processors.player().bungeeRegisterProcessor(uuid, name, time,
|
processing.submit(processors.player().proxyRegisterProcessor(uuid, name, time,
|
||||||
gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null
|
gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null
|
||||||
));
|
));
|
||||||
processing.submit(processors.info().playerPageUpdateProcessor(uuid));
|
processing.submit(processors.info().playerPageUpdateProcessor(uuid));
|
||||||
|
@ -3,7 +3,6 @@ package com.djrapitops.plan.system.listeners.sponge;
|
|||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.system.cache.SessionCache;
|
import com.djrapitops.plan.system.cache.SessionCache;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.bukkit.AFKListener;
|
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
@ -82,8 +81,7 @@ public class SpongePlayerListener {
|
|||||||
public void onKick(KickPlayerEvent event) {
|
public void onKick(KickPlayerEvent event) {
|
||||||
try {
|
try {
|
||||||
UUID uuid = event.getTargetEntity().getUniqueId();
|
UUID uuid = event.getTargetEntity().getUniqueId();
|
||||||
// TODO
|
if (SpongeAFKListener.AFK_TRACKER.isAfk(uuid)) {
|
||||||
if (AFKListener.AFK_TRACKER.isAfk(uuid)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processing.submit(processors.player().kickProcessor(uuid));
|
processing.submit(processors.player().kickProcessor(uuid));
|
||||||
|
@ -8,30 +8,58 @@ import com.djrapitops.plan.data.container.Session;
|
|||||||
import com.djrapitops.plan.system.cache.SessionCache;
|
import com.djrapitops.plan.system.cache.SessionCache;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
import com.djrapitops.plan.system.processing.processors.player.BungeePlayerRegisterProcessor;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.processing.processors.player.IPUpdateProcessor;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
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 com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Join listener for Velocity.
|
* Player Join listener for Velocity.
|
||||||
*
|
* <p>
|
||||||
* Based on the bungee version.
|
* Based on the bungee version.
|
||||||
*
|
*
|
||||||
* @author MicleBrick
|
* @author MicleBrick
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class PlayerOnlineListener {
|
public class PlayerOnlineListener {
|
||||||
|
|
||||||
|
private final PlanConfig config;
|
||||||
|
private final Processors processors;
|
||||||
|
private final Processing processing;
|
||||||
|
private final SessionCache sessionCache;
|
||||||
|
private final ServerInfo serverInfo;
|
||||||
|
private final ErrorHandler errorHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PlayerOnlineListener(
|
||||||
|
PlanConfig config,
|
||||||
|
Processing processing,
|
||||||
|
Processors processors,
|
||||||
|
SessionCache sessionCache,
|
||||||
|
ServerInfo serverInfo,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
this.config = config;
|
||||||
|
this.processing = processing;
|
||||||
|
this.processors = processors;
|
||||||
|
this.sessionCache = sessionCache;
|
||||||
|
this.serverInfo = serverInfo;
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPostLogin(PostLoginEvent event) {
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
try {
|
try {
|
||||||
@ -39,18 +67,19 @@ public class PlayerOnlineListener {
|
|||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
String name = player.getUsername();
|
String name = player.getUsername();
|
||||||
InetAddress address = player.getRemoteAddress().getAddress();
|
InetAddress address = player.getRemoteAddress().getAddress();
|
||||||
long now = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, now, "", ""));
|
sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, "", ""));
|
||||||
|
|
||||||
// maybe rename to ProxyPlayerRegisterProcessor?
|
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
|
||||||
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
|
|
||||||
new IPUpdateProcessor(uuid, address, now))
|
processing.submit(processors.player().proxyRegisterProcessor(uuid, name, time,
|
||||||
);
|
gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
));
|
||||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID()));
|
processing.submit(processors.info().playerPageUpdateProcessor(uuid));
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,11 +89,11 @@ public class PlayerOnlineListener {
|
|||||||
Player player = event.getPlayer();
|
Player 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(processors.info().playerPageUpdateProcessor(uuid));
|
||||||
ResponseCache.clearResponse(PageId.SERVER.of(ServerInfo.getServerUUID()));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +105,10 @@ public class PlayerOnlineListener {
|
|||||||
|
|
||||||
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, serverInfo.getServerUUID(), now, "", ""));
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
processing.submit(processors.info().playerPageUpdateProcessor(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ import com.djrapitops.plan.system.locale.lang.PluginLang;
|
|||||||
import com.djrapitops.plugin.logging.L;
|
import com.djrapitops.plugin.logging.L;
|
||||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||||
import dagger.Lazy;
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
import dagger.Lazy;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -3,7 +3,6 @@ package com.djrapitops.plan.system.processing.processors.info;
|
|||||||
import com.djrapitops.plan.system.info.InfoSystem;
|
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.command.Sender;
|
import com.djrapitops.plugin.command.Sender;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -21,17 +20,14 @@ public class InfoProcessors {
|
|||||||
|
|
||||||
private final Lazy<InfoSystem> infoSystem;
|
private final Lazy<InfoSystem> infoSystem;
|
||||||
private final Lazy<WebExceptionLogger> webExceptionLogger;
|
private final Lazy<WebExceptionLogger> webExceptionLogger;
|
||||||
private final Lazy<RunnableFactory> runnableFactory;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public InfoProcessors(
|
public InfoProcessors(
|
||||||
Lazy<InfoSystem> infoSystem,
|
Lazy<InfoSystem> infoSystem,
|
||||||
Lazy<WebExceptionLogger> webExceptionLogger,
|
Lazy<WebExceptionLogger> webExceptionLogger
|
||||||
Lazy<RunnableFactory> runnableFactory
|
|
||||||
) {
|
) {
|
||||||
this.infoSystem = infoSystem;
|
this.infoSystem = infoSystem;
|
||||||
this.webExceptionLogger = webExceptionLogger;
|
this.webExceptionLogger = webExceptionLogger;
|
||||||
this.runnableFactory = runnableFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InspectCacheRequestProcessor inspectCacheRequestProcessor(
|
public InspectCacheRequestProcessor inspectCacheRequestProcessor(
|
||||||
@ -46,8 +42,6 @@ public class InfoProcessors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerPageUpdateProcessor playerPageUpdateProcessor(UUID uuid) {
|
public PlayerPageUpdateProcessor playerPageUpdateProcessor(UUID uuid) {
|
||||||
return new PlayerPageUpdateProcessor(uuid,
|
return new PlayerPageUpdateProcessor(uuid);
|
||||||
infoSystem.get(), webExceptionLogger.get(), runnableFactory.get()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,6 @@ public class PlayerPageUpdateProcessor implements Runnable {
|
|||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
// TODO Factory method fix
|
|
||||||
PlayerPageUpdateProcessor(
|
PlayerPageUpdateProcessor(
|
||||||
UUID uuid
|
UUID uuid
|
||||||
) {
|
) {
|
||||||
|
@ -49,8 +49,8 @@ public class PlayerProcessors {
|
|||||||
return new BanAndOpProcessor(uuid, banned, op, database.get());
|
return new BanAndOpProcessor(uuid, banned, op, database.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BungeeRegisterProcessor bungeeRegisterProcessor(UUID uuid, String name, long registered, Runnable... afterProcess) {
|
public ProxyRegisterProcessor proxyRegisterProcessor(UUID uuid, String name, long registered, Runnable... afterProcess) {
|
||||||
return new BungeeRegisterProcessor(uuid, name, registered, processing.get(), database.get(), afterProcess);
|
return new ProxyRegisterProcessor(uuid, name, registered, processing.get(), database.get(), afterProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EndSessionProcessor endSessionProcessor(UUID uuid, long time) {
|
public EndSessionProcessor endSessionProcessor(UUID uuid, long time) {
|
||||||
|
@ -15,7 +15,7 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class BungeeRegisterProcessor implements CriticalRunnable {
|
public class ProxyRegisterProcessor implements CriticalRunnable {
|
||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -25,7 +25,7 @@ public class BungeeRegisterProcessor implements CriticalRunnable {
|
|||||||
private final Processing processing;
|
private final Processing processing;
|
||||||
private final Database database;
|
private final Database database;
|
||||||
|
|
||||||
BungeeRegisterProcessor(
|
ProxyRegisterProcessor(
|
||||||
UUID uuid, String name, long registered,
|
UUID uuid, String name, long registered,
|
||||||
Processing processing,
|
Processing processing,
|
||||||
Database database,
|
Database database,
|
||||||
|
@ -96,6 +96,10 @@ public class WorldAliasSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Long> getPlaytimePerAlias(WorldTimes worldTimes) {
|
public Map<String, Long> getPlaytimePerAlias(WorldTimes worldTimes) {
|
||||||
|
if (worldTimes.getWorldTimes().isEmpty()) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Long> playtimePerWorld = worldTimes.getWorldTimes() // WorldTimes Map<String, GMTimes>
|
Map<String, Long> playtimePerWorld = worldTimes.getWorldTimes() // WorldTimes Map<String, GMTimes>
|
||||||
.entrySet().stream()
|
.entrySet().stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
@ -161,6 +165,10 @@ public class WorldAliasSettings {
|
|||||||
|
|
||||||
Map<String, Long> playtimePerAlias = getPlaytimePerAlias(worldTimes);
|
Map<String, Long> playtimePerAlias = getPlaytimePerAlias(worldTimes);
|
||||||
long total = worldTimes.getTotal();
|
long total = worldTimes.getTotal();
|
||||||
|
// Prevent arithmetic error if 0
|
||||||
|
if (total <= 0) {
|
||||||
|
total = -1;
|
||||||
|
}
|
||||||
|
|
||||||
long longest = 0;
|
long longest = 0;
|
||||||
String theWorld = "-";
|
String theWorld = "-";
|
||||||
|
@ -21,10 +21,10 @@ import java.io.IOException;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BungeeConfigSystem extends ConfigSystem {
|
public class ProxyConfigSystem extends ConfigSystem {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BungeeConfigSystem(
|
public ProxyConfigSystem(
|
||||||
PlanFiles files,
|
PlanFiles files,
|
||||||
PlanConfig config,
|
PlanConfig config,
|
||||||
Theme theme,
|
Theme theme,
|
||||||
|
@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class BukkitTaskSystem extends ServerTaskSystem {
|
public class BukkitTaskSystem extends ServerTaskSystem {
|
||||||
|
|
||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
private final PingCountTimer pingCountTimer;
|
private final PingCountTimerBukkit pingCountTimer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BukkitTaskSystem(
|
public BukkitTaskSystem(
|
||||||
@ -33,10 +33,9 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
|||||||
RunnableFactory runnableFactory,
|
RunnableFactory runnableFactory,
|
||||||
PaperTPSCountTimer paperTPSCountTimer,
|
PaperTPSCountTimer paperTPSCountTimer,
|
||||||
BukkitTPSCountTimer bukkitTPSCountTimer,
|
BukkitTPSCountTimer bukkitTPSCountTimer,
|
||||||
NetworkPageRefreshTask networkPageRefreshTask,
|
|
||||||
BootAnalysisTask bootAnalysisTask,
|
BootAnalysisTask bootAnalysisTask,
|
||||||
PeriodicAnalysisTask periodicAnalysisTask,
|
PeriodicAnalysisTask periodicAnalysisTask,
|
||||||
PingCountTimer pingCountTimer,
|
PingCountTimerBukkit pingCountTimer,
|
||||||
LogsFolderCleanTask logsFolderCleanTask
|
LogsFolderCleanTask logsFolderCleanTask
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
@ -56,8 +55,7 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
|||||||
super.enable();
|
super.enable();
|
||||||
try {
|
try {
|
||||||
plugin.registerListener(pingCountTimer);
|
plugin.registerListener(pingCountTimer);
|
||||||
// TODO config
|
long startDelay = TimeAmount.toTicks(config.getNumber(Settings.PING_SERVER_ENABLE_DELAY), TimeUnit.SECONDS);
|
||||||
long startDelay = TimeAmount.toTicks(Settings.PING_SERVER_ENABLE_DELAY.getNumber(), TimeUnit.SECONDS);
|
|
||||||
registerTask("PingCountTimer", pingCountTimer)
|
registerTask("PingCountTimer", pingCountTimer)
|
||||||
.runTaskTimer(startDelay, 40L);
|
.runTaskTimer(startDelay, 40L);
|
||||||
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.tasks;
|
package com.djrapitops.plan.system.tasks;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.PlanBungee;
|
||||||
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.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
||||||
@ -23,22 +24,28 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class BungeeTaskSystem extends TaskSystem {
|
public class BungeeTaskSystem extends TaskSystem {
|
||||||
|
|
||||||
|
private final PlanBungee plugin;
|
||||||
private final PlanConfig config;
|
private final PlanConfig config;
|
||||||
private final NetworkPageRefreshTask networkPageRefreshTask;
|
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||||
|
private final PingCountTimerBungee pingCountTimer;
|
||||||
private final LogsFolderCleanTask logsFolderCleanTask;
|
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BungeeTaskSystem(
|
public BungeeTaskSystem(
|
||||||
|
PlanBungee plugin,
|
||||||
PlanConfig config,
|
PlanConfig config,
|
||||||
RunnableFactory runnableFactory,
|
RunnableFactory runnableFactory,
|
||||||
BungeeTPSCountTimer bungeeTPSCountTimer,
|
BungeeTPSCountTimer bungeeTPSCountTimer,
|
||||||
NetworkPageRefreshTask networkPageRefreshTask,
|
NetworkPageRefreshTask networkPageRefreshTask,
|
||||||
|
PingCountTimerBungee pingCountTimer,
|
||||||
LogsFolderCleanTask logsFolderCleanTask
|
LogsFolderCleanTask logsFolderCleanTask
|
||||||
) {
|
) {
|
||||||
super(runnableFactory, bungeeTPSCountTimer);
|
super(runnableFactory, bungeeTPSCountTimer);
|
||||||
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
this.networkPageRefreshTask = networkPageRefreshTask;
|
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||||
|
this.pingCountTimer = pingCountTimer;
|
||||||
this.logsFolderCleanTask = logsFolderCleanTask;
|
this.logsFolderCleanTask = logsFolderCleanTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,11 +65,8 @@ public class BungeeTaskSystem extends TaskSystem {
|
|||||||
}
|
}
|
||||||
}).runTaskAsynchronously();
|
}).runTaskAsynchronously();
|
||||||
|
|
||||||
// TODO Move this elsewhere
|
|
||||||
PingCountTimerBungee pingCountTimer = new PingCountTimerBungee();
|
|
||||||
plugin.registerListener(pingCountTimer);
|
plugin.registerListener(pingCountTimer);
|
||||||
long startDelay = TimeAmount.SECOND.ticks() * (long) Settings.PING_SERVER_ENABLE_DELAY.getNumber();
|
long startDelay = TimeAmount.toTicks(config.getNumber(Settings.PING_SERVER_ENABLE_DELAY), TimeUnit.SECONDS);
|
||||||
RunnableFactory.createNew("PingCountTimer", pingCountTimer)
|
runnableFactory.create("PingCountTimer", pingCountTimer).runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL);
|
||||||
.runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public abstract class ServerTaskSystem extends TaskSystem {
|
public abstract class ServerTaskSystem extends TaskSystem {
|
||||||
|
|
||||||
private final PlanConfig config;
|
protected final PlanConfig config;
|
||||||
private final BootAnalysisTask bootAnalysisTask;
|
private final BootAnalysisTask bootAnalysisTask;
|
||||||
private final PeriodicAnalysisTask periodicAnalysisTask;
|
private final PeriodicAnalysisTask periodicAnalysisTask;
|
||||||
private final LogsFolderCleanTask logsFolderCleanTask;
|
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
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.Settings;
|
||||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
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.PeriodicAnalysisTask;
|
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
|
||||||
import com.djrapitops.plan.system.tasks.server.PingCountTimerSponge;
|
import com.djrapitops.plan.system.tasks.server.PingCountTimerSponge;
|
||||||
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.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.scheduler.Task;
|
import org.spongepowered.api.scheduler.Task;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class SpongeTaskSystem extends ServerTaskSystem {
|
public class SpongeTaskSystem extends ServerTaskSystem {
|
||||||
|
|
||||||
private final PlanSponge plugin;
|
private final PlanSponge plugin;
|
||||||
|
private final PingCountTimerSponge pingCountTimer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SpongeTaskSystem(
|
public SpongeTaskSystem(
|
||||||
@ -26,9 +26,9 @@ public class SpongeTaskSystem extends ServerTaskSystem {
|
|||||||
PlanConfig config,
|
PlanConfig config,
|
||||||
RunnableFactory runnableFactory,
|
RunnableFactory runnableFactory,
|
||||||
SpongeTPSCountTimer spongeTPSCountTimer,
|
SpongeTPSCountTimer spongeTPSCountTimer,
|
||||||
NetworkPageRefreshTask networkPageRefreshTask,
|
|
||||||
BootAnalysisTask bootAnalysisTask,
|
BootAnalysisTask bootAnalysisTask,
|
||||||
PeriodicAnalysisTask periodicAnalysisTask,
|
PeriodicAnalysisTask periodicAnalysisTask,
|
||||||
|
PingCountTimerSponge pingCountTimer,
|
||||||
LogsFolderCleanTask logsFolderCleanTask
|
LogsFolderCleanTask logsFolderCleanTask
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
@ -40,17 +40,16 @@ public class SpongeTaskSystem extends ServerTaskSystem {
|
|||||||
logsFolderCleanTask
|
logsFolderCleanTask
|
||||||
);
|
);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.pingCountTimer = pingCountTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
super.enable();
|
super.enable();
|
||||||
|
|
||||||
// TODO Move elsewhere
|
|
||||||
PingCountTimerSponge pingCountTimer = new PingCountTimerSponge();
|
|
||||||
plugin.registerListener(pingCountTimer);
|
plugin.registerListener(pingCountTimer);
|
||||||
long startDelay = TimeAmount.SECOND.ticks() * (long) Settings.PING_SERVER_ENABLE_DELAY.getNumber();
|
long startDelay = TimeAmount.toTicks(config.getNumber(Settings.PING_SERVER_ENABLE_DELAY), TimeUnit.SECONDS);
|
||||||
RunnableFactory.createNew("PingCountTimer", pingCountTimer)
|
runnableFactory.create("PingCountTimer", pingCountTimer)
|
||||||
.runTaskTimer(startDelay, PingCountTimerSponge.PING_INTERVAL);
|
.runTaskTimer(startDelay, PingCountTimerSponge.PING_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,18 @@ package com.djrapitops.plan.system.tasks;
|
|||||||
|
|
||||||
import com.djrapitops.plan.PlanVelocity;
|
import com.djrapitops.plan.PlanVelocity;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.tasks.proxy.EnableConnectionTask;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.system.tasks.velocity.VelocityTPSCountTimer;
|
|
||||||
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
|
||||||
|
import com.djrapitops.plan.system.tasks.server.PingCountTimerBungee;
|
||||||
import com.djrapitops.plan.system.tasks.server.PingCountTimerVelocity;
|
import com.djrapitops.plan.system.tasks.server.PingCountTimerVelocity;
|
||||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
import com.djrapitops.plan.system.tasks.velocity.VelocityTPSCountTimer;
|
||||||
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 java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TaskSystem responsible for registering tasks for Velocity.
|
* TaskSystem responsible for registering tasks for Velocity.
|
||||||
*
|
*
|
||||||
@ -22,10 +26,28 @@ import com.djrapitops.plugin.task.RunnableFactory;
|
|||||||
public class VelocityTaskSystem extends TaskSystem {
|
public class VelocityTaskSystem extends TaskSystem {
|
||||||
|
|
||||||
private final PlanVelocity plugin;
|
private final PlanVelocity plugin;
|
||||||
|
private final PlanConfig config;
|
||||||
|
private final NetworkPageRefreshTask networkPageRefreshTask;
|
||||||
|
private final PingCountTimerVelocity pingCountTimer;
|
||||||
|
private final LogsFolderCleanTask logsFolderCleanTask;
|
||||||
|
|
||||||
public VelocityTaskSystem(PlanVelocity plugin) {
|
@Inject
|
||||||
super(new VelocityTPSCountTimer(plugin));
|
public VelocityTaskSystem(
|
||||||
|
PlanVelocity plugin,
|
||||||
|
PlanConfig config,
|
||||||
|
RunnableFactory runnableFactory,
|
||||||
|
VelocityTPSCountTimer velocityTPSCountTimer,
|
||||||
|
NetworkPageRefreshTask networkPageRefreshTask,
|
||||||
|
PingCountTimerVelocity pingCountTimer,
|
||||||
|
LogsFolderCleanTask logsFolderCleanTask
|
||||||
|
) {
|
||||||
|
super(runnableFactory, velocityTPSCountTimer);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
|
this.networkPageRefreshTask = networkPageRefreshTask;
|
||||||
|
this.pingCountTimer = pingCountTimer;
|
||||||
|
this.logsFolderCleanTask = logsFolderCleanTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,16 +56,18 @@ public class VelocityTaskSystem extends TaskSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerTasks() {
|
private void registerTasks() {
|
||||||
registerTask(new EnableConnectionTask()).runTaskAsynchronously();
|
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||||
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks());
|
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||||
registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks());
|
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||||
if (Settings.ANALYSIS_EXPORT.isTrue()) {
|
registerTask("Settings Save", new AbsRunnable() {
|
||||||
registerTask(new HtmlExport(plugin)).runTaskAsynchronously();
|
@Override
|
||||||
}
|
public void run() {
|
||||||
PingCountTimerVelocity pingCountTimer = new PingCountTimerVelocity();
|
config.getNetworkSettings().placeSettingsToDB();
|
||||||
|
}
|
||||||
|
}).runTaskAsynchronously();
|
||||||
|
|
||||||
plugin.registerListener(pingCountTimer);
|
plugin.registerListener(pingCountTimer);
|
||||||
long startDelay = TimeAmount.SECOND.ticks() * (long) Settings.PING_SERVER_ENABLE_DELAY.getNumber();
|
long startDelay = TimeAmount.toTicks(config.getNumber(Settings.PING_SERVER_ENABLE_DELAY), TimeUnit.SECONDS);
|
||||||
RunnableFactory.createNew("PingCountTimer", pingCountTimer)
|
runnableFactory.create("PingCountTimer", pingCountTimer).runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL);
|
||||||
.runTaskTimer(startDelay, PingCountTimerVelocity.PING_INTERVAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ import org.bukkit.World;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.lang.management.OperatingSystemMXBean;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -27,6 +27,7 @@ import com.djrapitops.plan.data.store.objects.DateObj;
|
|||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
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.utilities.java.Reflection;
|
import com.djrapitops.plan.utilities.java.Reflection;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
@ -99,16 +100,19 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
|||||||
|
|
||||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
|
private final PlanConfig config;
|
||||||
private final Processors processors;
|
private final Processors processors;
|
||||||
private final Processing processing;
|
private final Processing processing;
|
||||||
private final RunnableFactory runnableFactory;
|
private final RunnableFactory runnableFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PingCountTimerBukkit(
|
public PingCountTimerBukkit(
|
||||||
|
PlanConfig config,
|
||||||
Processors processors,
|
Processors processors,
|
||||||
Processing processing,
|
Processing processing,
|
||||||
RunnableFactory runnableFactory
|
RunnableFactory runnableFactory
|
||||||
) {
|
) {
|
||||||
|
this.config = config;
|
||||||
this.processors = processors;
|
this.processors = processors;
|
||||||
this.processing = processing;
|
this.processing = processing;
|
||||||
this.runnableFactory = runnableFactory;
|
this.runnableFactory = runnableFactory;
|
||||||
@ -186,7 +190,7 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
|||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}// TODO Config
|
}// TODO Config
|
||||||
}).runTaskLater(TimeAmount.toTicks(Settings.PING_PLAYER_LOGIN_DELAY.getNumber(), TimeUnit.SECONDS));
|
}).runTaskLater(TimeAmount.toTicks(config.getNumber(Settings.PING_PLAYER_LOGIN_DELAY), TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -25,8 +25,9 @@ package com.djrapitops.plan.system.tasks.server;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.player.PingInsertProcessor;
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
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.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
@ -36,20 +37,44 @@ import net.md_5.bungee.api.event.ServerConnectedEvent;
|
|||||||
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
||||||
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 javax.inject.Singleton;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task that handles player ping calculation on Bungee based servers.
|
* Task that handles player ping calculation on Bungee based servers.
|
||||||
*
|
*
|
||||||
* @author BrainStone
|
* @author BrainStone
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
||||||
|
|
||||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||||
public static final int PING_INTERVAL = 2 * 20;
|
public static final int PING_INTERVAL = 2 * 20;
|
||||||
|
|
||||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory = new HashMap<>();
|
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
|
private final PlanConfig config;
|
||||||
|
private final Processors processors;
|
||||||
|
private final Processing processing;
|
||||||
|
private final RunnableFactory runnableFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PingCountTimerBungee(
|
||||||
|
PlanConfig config,
|
||||||
|
Processors processors,
|
||||||
|
Processing processing,
|
||||||
|
RunnableFactory runnableFactory
|
||||||
|
) {
|
||||||
|
this.config = config;
|
||||||
|
this.processors = processors;
|
||||||
|
this.processing = processing;
|
||||||
|
this.runnableFactory = runnableFactory;
|
||||||
|
playerHistory = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -59,13 +84,13 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
|||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int ping = getPing(player);
|
int ping = getPing(player);
|
||||||
if (ping < -1 || ping > TimeAmount.SECOND.ms() * 8L) {
|
if (ping < -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
|
||||||
// Don't accept bad values
|
// Don't accept bad values
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
history.add(new DateObj<>(time, ping));
|
history.add(new DateObj<>(time, ping));
|
||||||
if (history.size() >= 30) {
|
if (history.size() >= 30) {
|
||||||
Processing.submit(new PingInsertProcessor(uuid, new ArrayList<>(history)));
|
processing.submit(processors.player().pingInsertProcessor(uuid, new ArrayList<>(history)));
|
||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -90,14 +115,14 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
||||||
ProxiedPlayer player = joinEvent.getPlayer();
|
ProxiedPlayer 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.isConnected()) {
|
if (player.isConnected()) {
|
||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.SECOND.ticks() * (long) Settings.PING_PLAYER_LOGIN_DELAY.getNumber());
|
}).runTaskLater(TimeAmount.toTicks(config.getNumber(Settings.PING_PLAYER_LOGIN_DELAY), TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -25,8 +25,9 @@ package com.djrapitops.plan.system.tasks.server;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.player.PingInsertProcessor;
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
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.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
@ -35,7 +36,9 @@ import org.spongepowered.api.entity.living.player.Player;
|
|||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task that handles player ping calculation on Sponge based servers.
|
* Task that handles player ping calculation on Sponge based servers.
|
||||||
@ -48,7 +51,26 @@ public class PingCountTimerSponge extends AbsRunnable {
|
|||||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||||
public static final int PING_INTERVAL = 2 * 20;
|
public static final int PING_INTERVAL = 2 * 20;
|
||||||
|
|
||||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory = new HashMap<>();
|
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
|
private final PlanConfig config;
|
||||||
|
private final Processors processors;
|
||||||
|
private final Processing processing;
|
||||||
|
private final RunnableFactory runnableFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PingCountTimerSponge(
|
||||||
|
PlanConfig config,
|
||||||
|
Processors processors,
|
||||||
|
Processing processing,
|
||||||
|
RunnableFactory runnableFactory
|
||||||
|
) {
|
||||||
|
this.config = config;
|
||||||
|
this.processors = processors;
|
||||||
|
this.processing = processing;
|
||||||
|
this.runnableFactory = runnableFactory;
|
||||||
|
playerHistory = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -58,13 +80,13 @@ public class PingCountTimerSponge extends AbsRunnable {
|
|||||||
Optional<Player> player = Sponge.getServer().getPlayer(uuid);
|
Optional<Player> player = Sponge.getServer().getPlayer(uuid);
|
||||||
if (player.isPresent()) {
|
if (player.isPresent()) {
|
||||||
int ping = getPing(player.get());
|
int ping = getPing(player.get());
|
||||||
if (ping < -1 || ping > TimeAmount.SECOND.ms() * 8L) {
|
if (ping < -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
|
||||||
// Don't accept bad values
|
// Don't accept bad values
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
history.add(new DateObj<>(time, ping));
|
history.add(new DateObj<>(time, ping));
|
||||||
if (history.size() >= 30) {
|
if (history.size() >= 30) {
|
||||||
Processing.submit(new PingInsertProcessor(uuid, new ArrayList<>(history)));
|
processing.submit(processors.player().pingInsertProcessor(uuid, new ArrayList<>(history)));
|
||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -89,14 +111,14 @@ public class PingCountTimerSponge extends AbsRunnable {
|
|||||||
@Listener
|
@Listener
|
||||||
public void onPlayerJoin(ClientConnectionEvent.Join joinEvent) {
|
public void onPlayerJoin(ClientConnectionEvent.Join joinEvent) {
|
||||||
Player player = joinEvent.getTargetEntity();
|
Player player = joinEvent.getTargetEntity();
|
||||||
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()) {
|
||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.SECOND.ticks() * (long) Settings.PING_PLAYER_LOGIN_DELAY.getNumber());
|
}).runTaskLater(TimeAmount.toTicks(config.getNumber(Settings.PING_PLAYER_LOGIN_DELAY), TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
|
@ -26,8 +26,9 @@ package com.djrapitops.plan.system.tasks.server;
|
|||||||
import com.djrapitops.plan.PlanVelocity;
|
import com.djrapitops.plan.PlanVelocity;
|
||||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.player.PingInsertProcessor;
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
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.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
@ -36,38 +37,64 @@ import com.velocitypowered.api.event.connection.DisconnectEvent;
|
|||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task that handles player ping calculation on Velocity based servers.
|
* Task that handles player ping calculation on Velocity based servers.
|
||||||
*
|
* <p>
|
||||||
* Based on PingCountTimerBungee
|
* Based on PingCountTimerBungee
|
||||||
*
|
*
|
||||||
* @author MicleBrick
|
* @author MicleBrick
|
||||||
*/
|
*/
|
||||||
|
@Singleton
|
||||||
public class PingCountTimerVelocity extends AbsRunnable {
|
public class PingCountTimerVelocity extends AbsRunnable {
|
||||||
|
|
||||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||||
public static final int PING_INTERVAL = 2 * 20;
|
public static final int PING_INTERVAL = 2 * 20;
|
||||||
|
|
||||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory = new HashMap<>();
|
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
|
private final PlanVelocity plugin;
|
||||||
|
private final PlanConfig config;
|
||||||
|
private final Processors processors;
|
||||||
|
private final Processing processing;
|
||||||
|
private final RunnableFactory runnableFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PingCountTimerVelocity(
|
||||||
|
PlanVelocity plugin,
|
||||||
|
PlanConfig config,
|
||||||
|
Processors processors,
|
||||||
|
Processing processing,
|
||||||
|
RunnableFactory runnableFactory
|
||||||
|
) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
|
this.processors = processors;
|
||||||
|
this.processing = processing;
|
||||||
|
this.runnableFactory = runnableFactory;
|
||||||
|
playerHistory = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<UUID> loggedOut = new ArrayList<>();
|
List<UUID> loggedOut = new ArrayList<>();
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
playerHistory.forEach((uuid, history) -> {
|
playerHistory.forEach((uuid, history) -> {
|
||||||
Player player = PlanVelocity.getInstance().getProxy().getPlayer(uuid).orElse(null);
|
Player player = plugin.getProxy().getPlayer(uuid).orElse(null);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int ping = getPing(player);
|
int ping = getPing(player);
|
||||||
if (ping < -1 || ping > TimeAmount.SECOND.ms() * 8L) {
|
if (ping < -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
|
||||||
// Don't accept bad values
|
// Don't accept bad values
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
history.add(new DateObj<>(time, ping));
|
history.add(new DateObj<>(time, ping));
|
||||||
if (history.size() >= 30) {
|
if (history.size() >= 30) {
|
||||||
Processing.submit(new PingInsertProcessor(uuid, new ArrayList<>(history)));
|
processing.submit(processors.player().pingInsertProcessor(uuid, new ArrayList<>(history)));
|
||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -92,14 +119,14 @@ public class PingCountTimerVelocity extends AbsRunnable {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
public void onPlayerJoin(ServerConnectedEvent 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.isActive()) {
|
if (player.isActive()) {
|
||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.SECOND.ticks() * (long) Settings.PING_PLAYER_LOGIN_DELAY.getNumber());
|
}).runTaskLater(TimeAmount.toTicks(config.getNumber(Settings.PING_PLAYER_LOGIN_DELAY), TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -13,8 +13,6 @@ import org.spongepowered.api.world.World;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.lang.management.OperatingSystemMXBean;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SpongeTPSCountTimer extends TPSCountTimer {
|
public class SpongeTPSCountTimer extends TPSCountTimer {
|
||||||
|
@ -1,20 +1,37 @@
|
|||||||
package com.djrapitops.plan.system.tasks.velocity;
|
package com.djrapitops.plan.system.tasks.velocity;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanVelocity;
|
|
||||||
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.processing.Processing;
|
||||||
|
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||||
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;
|
||||||
|
|
||||||
public class VelocityTPSCountTimer extends TPSCountTimer<PlanVelocity> {
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
public VelocityTPSCountTimer(PlanVelocity plugin) {
|
@Singleton
|
||||||
super(plugin);
|
public class VelocityTPSCountTimer extends TPSCountTimer {
|
||||||
|
|
||||||
|
private final ServerProperties serverProperties;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public VelocityTPSCountTimer(
|
||||||
|
Processors processors,
|
||||||
|
Processing processing,
|
||||||
|
ServerProperties serverProperties,
|
||||||
|
PluginLogger logger,
|
||||||
|
ErrorHandler errorHandler
|
||||||
|
) {
|
||||||
|
super(processors, processing, 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().getOnlinePlayers();
|
int onlineCount = serverProperties.getOnlinePlayers();
|
||||||
TPS tps = TPSBuilder.get()
|
TPS tps = TPSBuilder.get()
|
||||||
.date(now)
|
.date(now)
|
||||||
.skipTPS()
|
.skipTPS()
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.djrapitops.plan.system.webserver.response.pages;
|
package com.djrapitops.plan.system.webserver.response.pages;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.system.webserver.response.pages;
|
|||||||
|
|
||||||
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.plan.system.webserver.response.Response;
|
|
||||||
import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent;
|
import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent;
|
||||||
import org.apache.commons.text.StringSubstitutor;
|
import org.apache.commons.text.StringSubstitutor;
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.webserver.response.pages;
|
package com.djrapitops.plan.system.webserver.response.pages;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
|
||||||
import com.djrapitops.plan.data.store.containers.NetworkContainer;
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
|
||||||
import com.djrapitops.plan.utilities.html.pages.NetworkPage;
|
import com.djrapitops.plan.utilities.html.pages.NetworkPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.djrapitops.plan.utilities.html.graphs;
|
package com.djrapitops.plan.utilities.html.graphs;
|
||||||
|
|
||||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for creating ProgressBars.
|
* Utility for creating Progress bars.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@ -12,16 +12,19 @@ public class ProgressBar {
|
|||||||
private final int obtained;
|
private final int obtained;
|
||||||
private final int max;
|
private final int max;
|
||||||
|
|
||||||
|
private final Formatter<Double> percentageFormatter;
|
||||||
|
|
||||||
private final String color;
|
private final String color;
|
||||||
|
|
||||||
public ProgressBar(int obtained, int max) {
|
public ProgressBar(int obtained, int max, Formatter<Double> percentageFormatter) {
|
||||||
this(obtained, max, "teal");
|
this(obtained, max, "teal", percentageFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressBar(int obtained, int max, String color) {
|
public ProgressBar(int obtained, int max, String color, Formatter<Double> percentageFormatter) {
|
||||||
this.obtained = obtained;
|
this.obtained = obtained;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.percentageFormatter = percentageFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toHtml() {
|
public String toHtml() {
|
||||||
@ -32,7 +35,7 @@ public class ProgressBar {
|
|||||||
" aria-valuenow=\"" + obtained + "\"" +
|
" aria-valuenow=\"" + obtained + "\"" +
|
||||||
" aria-valuemin=\"0\" aria-valuemax=\"" + max + "\"" +
|
" aria-valuemin=\"0\" aria-valuemax=\"" + max + "\"" +
|
||||||
" style=\"width: " + percentageRounded + "%;\">" +
|
" style=\"width: " + percentageRounded + "%;\">" +
|
||||||
obtained + " / " + max + " (" + Formatters.percentage().apply(percentage) + ")" +
|
obtained + " / " + max + " (" + percentageFormatter.apply(percentage) + ")" +
|
||||||
"</div></div>";
|
"</div></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,16 +22,18 @@ import static com.djrapitops.plan.data.store.keys.NetworkKeys.*;
|
|||||||
public class NetworkPage implements Page {
|
public class NetworkPage implements Page {
|
||||||
|
|
||||||
private final NetworkContainer networkContainer;
|
private final NetworkContainer networkContainer;
|
||||||
|
private final AnalysisPluginsTabContentCreator analysisPluginsTabContentCreator;
|
||||||
|
|
||||||
private final PlanFiles files;
|
private final PlanFiles files;
|
||||||
private final ServerProperties serverProperties;
|
private final ServerProperties serverProperties;
|
||||||
|
|
||||||
public NetworkPage(
|
NetworkPage(
|
||||||
NetworkContainer networkContainer,
|
NetworkContainer networkContainer,
|
||||||
PlanFiles files,
|
AnalysisPluginsTabContentCreator analysisPluginsTabContentCreator, PlanFiles files,
|
||||||
ServerProperties serverProperties
|
ServerProperties serverProperties
|
||||||
) {
|
) {
|
||||||
this.networkContainer = networkContainer;
|
this.networkContainer = networkContainer;
|
||||||
|
this.analysisPluginsTabContentCreator = analysisPluginsTabContentCreator;
|
||||||
this.files = files;
|
this.files = files;
|
||||||
this.serverProperties = serverProperties;
|
this.serverProperties = serverProperties;
|
||||||
}
|
}
|
||||||
@ -56,8 +58,7 @@ public class NetworkPage implements Page {
|
|||||||
SERVERS_TAB
|
SERVERS_TAB
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO Fix
|
String[] content = analysisPluginsTabContentCreator.createContent(null, networkContainer.getUnsafe(NetworkKeys.PLAYERS_MUTATOR));
|
||||||
String[] content = AnalysisPluginsTabContentCreator.createContent(networkContainer.getUnsafe(NetworkKeys.PLAYERS_MUTATOR), null);
|
|
||||||
String nav = content[0];
|
String nav = content[0];
|
||||||
String tabs = content[1];
|
String tabs = content[1];
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePlug
|
|||||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||||
import com.djrapitops.plan.utilities.html.structure.Accordions;
|
import com.djrapitops.plan.utilities.html.structure.Accordions;
|
||||||
|
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||||
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
||||||
import com.djrapitops.plugin.benchmarking.Timings;
|
import com.djrapitops.plugin.benchmarking.Timings;
|
||||||
import com.djrapitops.plugin.logging.debug.DebugLogger;
|
import com.djrapitops.plugin.logging.debug.DebugLogger;
|
||||||
@ -46,6 +47,7 @@ public class PageFactory {
|
|||||||
private final Lazy<Accordions> accordions;
|
private final Lazy<Accordions> accordions;
|
||||||
private final Lazy<Formatters> formatters;
|
private final Lazy<Formatters> formatters;
|
||||||
private final Lazy<AnalysisContainer.Factory> analysisContainerFactory;
|
private final Lazy<AnalysisContainer.Factory> analysisContainerFactory;
|
||||||
|
private final Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator;
|
||||||
private final Lazy<HookHandler> hookHandler;
|
private final Lazy<HookHandler> hookHandler;
|
||||||
private final Lazy<DebugLogger> debugLogger;
|
private final Lazy<DebugLogger> debugLogger;
|
||||||
private final Lazy<Timings> timings;
|
private final Lazy<Timings> timings;
|
||||||
@ -65,6 +67,7 @@ public class PageFactory {
|
|||||||
Lazy<Accordions> accordions,
|
Lazy<Accordions> accordions,
|
||||||
Lazy<Formatters> formatters,
|
Lazy<Formatters> formatters,
|
||||||
Lazy<AnalysisContainer.Factory> analysisContainerFactory,
|
Lazy<AnalysisContainer.Factory> analysisContainerFactory,
|
||||||
|
Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator,
|
||||||
Lazy<HookHandler> hookHandler,
|
Lazy<HookHandler> hookHandler,
|
||||||
Lazy<DebugLogger> debugLogger,
|
Lazy<DebugLogger> debugLogger,
|
||||||
Lazy<Timings> timings,
|
Lazy<Timings> timings,
|
||||||
@ -82,6 +85,7 @@ public class PageFactory {
|
|||||||
this.accordions = accordions;
|
this.accordions = accordions;
|
||||||
this.formatters = formatters;
|
this.formatters = formatters;
|
||||||
this.analysisContainerFactory = analysisContainerFactory;
|
this.analysisContainerFactory = analysisContainerFactory;
|
||||||
|
this.analysisPluginsTabContentCreator = analysisPluginsTabContentCreator;
|
||||||
this.hookHandler = hookHandler;
|
this.hookHandler = hookHandler;
|
||||||
this.debugLogger = debugLogger;
|
this.debugLogger = debugLogger;
|
||||||
this.timings = timings;
|
this.timings = timings;
|
||||||
@ -126,6 +130,8 @@ public class PageFactory {
|
|||||||
|
|
||||||
public NetworkPage networkPage() {
|
public NetworkPage networkPage() {
|
||||||
NetworkContainer networkContainer = database.get().fetch().getNetworkContainer(); // Not cached, big.
|
NetworkContainer networkContainer = database.get().fetch().getNetworkContainer(); // Not cached, big.
|
||||||
return new NetworkPage(networkContainer, fileSystem.get(), serverInfo.get().getServerProperties());
|
return new NetworkPage(networkContainer,
|
||||||
|
analysisPluginsTabContentCreator.get(),
|
||||||
|
fileSystem.get(), serverInfo.get().getServerProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ import com.djrapitops.plan.data.element.AnalysisContainer;
|
|||||||
import com.djrapitops.plan.data.element.InspectContainer;
|
import com.djrapitops.plan.data.element.InspectContainer;
|
||||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.data.plugin.PluginData;
|
import com.djrapitops.plan.data.plugin.PluginData;
|
||||||
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
|
|
||||||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||||
import com.djrapitops.plan.system.DebugChannels;
|
import com.djrapitops.plan.system.DebugChannels;
|
||||||
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
||||||
@ -52,9 +51,9 @@ public class AnalysisPluginsTabContentCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String[] createContent(
|
public String[] createContent(
|
||||||
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer
|
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer,
|
||||||
|
PlayersMutator mutator
|
||||||
) {
|
) {
|
||||||
PlayersMutator mutator = analysisContainer.getValue(AnalysisKeys.PLAYERS_MUTATOR).orElse(new PlayersMutator(new ArrayList<>()));
|
|
||||||
|
|
||||||
if (mutator.all().isEmpty()) {
|
if (mutator.all().isEmpty()) {
|
||||||
return new String[]{"<li><a>No Data</a></li>", ""};
|
return new String[]{"<li><a>No Data</a></li>", ""};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.djrapitops.plan.data.store.mutators.formatting;
|
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plan.utilities.formatting.time.TimeAmountFormatter;
|
||||||
import org.junit.AfterClass;
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import utilities.Teardown;
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@ -17,41 +17,35 @@ import static org.junit.Assert.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class TimeAmountFormatterDefaultTest {
|
public class TimeAmountFormatterDefaultTest {
|
||||||
|
|
||||||
private TimeAmountFormatter timeAmountFormatter;
|
private static TimeAmountFormatter underTest;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() {
|
public static void setUpClass() {
|
||||||
Settings.FORMAT_YEAR.setTemporaryValue("1 year, ");
|
// TODO Test initialization
|
||||||
Settings.FORMAT_YEARS.setTemporaryValue("%years% years, ");
|
Assume.assumeTrue(false);
|
||||||
Settings.FORMAT_MONTH.setTemporaryValue("1 month, ");
|
PlanConfig config = new PlanConfig(null, null, null);
|
||||||
Settings.FORMAT_MONTHS.setTemporaryValue("%months% months, ");
|
// Settings.FORMAT_YEAR.setTemporaryValue("1 year, ");
|
||||||
Settings.FORMAT_DAY.setTemporaryValue("1d ");
|
// Settings.FORMAT_YEARS.setTemporaryValue("%years% years, ");
|
||||||
Settings.FORMAT_DAYS.setTemporaryValue("%days%d ");
|
// Settings.FORMAT_MONTH.setTemporaryValue("1 month, ");
|
||||||
Settings.FORMAT_HOURS.setTemporaryValue("%hours%h ");
|
// Settings.FORMAT_MONTHS.setTemporaryValue("%months% months, ");
|
||||||
Settings.FORMAT_MINUTES.setTemporaryValue("%minutes%m ");
|
// Settings.FORMAT_DAY.setTemporaryValue("1d ");
|
||||||
Settings.FORMAT_SECONDS.setTemporaryValue("%seconds%s");
|
// Settings.FORMAT_DAYS.setTemporaryValue("%days%d ");
|
||||||
Settings.FORMAT_ZERO_SECONDS.setTemporaryValue("0s");
|
// Settings.FORMAT_HOURS.setTemporaryValue("%hours%h ");
|
||||||
}
|
// Settings.FORMAT_MINUTES.setTemporaryValue("%minutes%m ");
|
||||||
|
// Settings.FORMAT_SECONDS.setTemporaryValue("%seconds%s");
|
||||||
@AfterClass
|
// Settings.FORMAT_ZERO_SECONDS.setTemporaryValue("0s");
|
||||||
public static void tearDownClass() {
|
underTest = new TimeAmountFormatter(config);
|
||||||
Teardown.resetSettingsTempValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
timeAmountFormatter = new TimeAmountFormatter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exampleOne() {
|
public void exampleOne() {
|
||||||
String expected = "1 year, 1 month, 5d 12h 30m 20s";
|
String expected = "1 year, 1 month, 5d 12h 30m 20s";
|
||||||
|
|
||||||
long ms = TimeAmount.DAY.ms() * 400L +
|
long ms = TimeUnit.DAYS.toMillis(400L) +
|
||||||
TimeAmount.HOUR.ms() * 12L +
|
TimeUnit.HOURS.toMillis(12L) +
|
||||||
TimeAmount.MINUTE.ms() * 30L +
|
TimeUnit.MINUTES.toMillis(30L) +
|
||||||
TimeAmount.SECOND.ms() * 20L;
|
TimeUnit.SECONDS.toMillis(20L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -60,8 +54,8 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
public void exampleTwo() {
|
public void exampleTwo() {
|
||||||
String expected = "1 year, 1 month, 5d ";
|
String expected = "1 year, 1 month, 5d ";
|
||||||
|
|
||||||
long ms = TimeAmount.DAY.ms() * 400L;
|
long ms = TimeUnit.DAYS.toMillis(400L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -70,9 +64,9 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
public void exampleThree() {
|
public void exampleThree() {
|
||||||
String expected = "12h 20s";
|
String expected = "12h 20s";
|
||||||
|
|
||||||
long ms = TimeAmount.HOUR.ms() * 12L +
|
long ms = TimeUnit.HOURS.toMillis(12L) +
|
||||||
TimeAmount.SECOND.ms() * 20L;
|
TimeUnit.SECONDS.toMillis(20L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -81,8 +75,8 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
public void exampleFour() {
|
public void exampleFour() {
|
||||||
String expected = "30m ";
|
String expected = "30m ";
|
||||||
|
|
||||||
long ms = TimeAmount.MINUTE.ms() * 30L;
|
long ms = TimeUnit.MINUTES.toMillis(30L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -91,8 +85,8 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
public void exampleFive() {
|
public void exampleFive() {
|
||||||
String expected = "20s";
|
String expected = "20s";
|
||||||
|
|
||||||
long ms = TimeAmount.SECOND.ms() * 20L;
|
long ms = TimeUnit.SECONDS.toMillis(20L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -102,7 +96,7 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
String expected = "-";
|
String expected = "-";
|
||||||
|
|
||||||
long ms = 0L;
|
long ms = 0L;
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -111,8 +105,8 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
public void exampleOneSecond() {
|
public void exampleOneSecond() {
|
||||||
String expected = "1s";
|
String expected = "1s";
|
||||||
|
|
||||||
long ms = TimeAmount.SECOND.ms();
|
long ms = TimeUnit.SECONDS.toMillis(1L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -121,8 +115,8 @@ public class TimeAmountFormatterDefaultTest {
|
|||||||
public void exampleOneMinute() {
|
public void exampleOneMinute() {
|
||||||
String expected = "1m ";
|
String expected = "1m ";
|
||||||
|
|
||||||
long ms = TimeAmount.MINUTE.ms();
|
long ms = TimeUnit.MINUTES.toMillis(1L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.djrapitops.plan.data.store.mutators.formatting;
|
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plan.utilities.formatting.time.TimeAmountFormatter;
|
||||||
import org.junit.AfterClass;
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import utilities.Teardown;
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@ -17,41 +17,35 @@ import static org.junit.Assert.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class TimeAmountFormatterExtraZerosTest {
|
public class TimeAmountFormatterExtraZerosTest {
|
||||||
|
|
||||||
private TimeAmountFormatter timeAmountFormatter;
|
private static TimeAmountFormatter underTest;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() {
|
public static void setUpClass() {
|
||||||
Settings.FORMAT_YEAR.setTemporaryValue("1 year, ");
|
// TODO Test initialization
|
||||||
Settings.FORMAT_YEARS.setTemporaryValue("%years% years, ");
|
Assume.assumeTrue(false);
|
||||||
Settings.FORMAT_MONTH.setTemporaryValue("1 month, ");
|
PlanConfig config = new PlanConfig(null, null, null);
|
||||||
Settings.FORMAT_MONTHS.setTemporaryValue("%months% months, ");
|
// Settings.FORMAT_YEAR.setTemporaryValue("1 year, ");
|
||||||
Settings.FORMAT_DAY.setTemporaryValue("1d ");
|
// Settings.FORMAT_YEARS.setTemporaryValue("%years% years, ");
|
||||||
Settings.FORMAT_DAYS.setTemporaryValue("%days%d ");
|
// Settings.FORMAT_MONTH.setTemporaryValue("1 month, ");
|
||||||
Settings.FORMAT_HOURS.setTemporaryValue("%zero%%hours%:");
|
// Settings.FORMAT_MONTHS.setTemporaryValue("%months% months, ");
|
||||||
Settings.FORMAT_MINUTES.setTemporaryValue("%hours%%zero%%minutes%:");
|
// Settings.FORMAT_DAY.setTemporaryValue("1d ");
|
||||||
Settings.FORMAT_SECONDS.setTemporaryValue("%minutes%%zero%%seconds%");
|
// Settings.FORMAT_DAYS.setTemporaryValue("%days%d ");
|
||||||
Settings.FORMAT_ZERO_SECONDS.setTemporaryValue("00:00:00");
|
// Settings.FORMAT_HOURS.setTemporaryValue("%zero%%hours%:");
|
||||||
}
|
// Settings.FORMAT_MINUTES.setTemporaryValue("%hours%%zero%%minutes%:");
|
||||||
|
// Settings.FORMAT_SECONDS.setTemporaryValue("%minutes%%zero%%seconds%");
|
||||||
@AfterClass
|
// Settings.FORMAT_ZERO_SECONDS.setTemporaryValue("00:00:00");
|
||||||
public static void tearDownClass() {
|
underTest = new TimeAmountFormatter(config);
|
||||||
Teardown.resetSettingsTempValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
timeAmountFormatter = new TimeAmountFormatter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exampleOne() {
|
public void exampleOne() {
|
||||||
String expected = "1 year, 1 month, 5d 12:30:20";
|
String expected = "1 year, 1 month, 5d 12:30:20";
|
||||||
|
|
||||||
long ms = TimeAmount.DAY.ms() * 400L +
|
long ms = TimeUnit.DAYS.toMillis(400L) +
|
||||||
TimeAmount.HOUR.ms() * 12L +
|
TimeUnit.HOURS.toMillis(12L) +
|
||||||
TimeAmount.MINUTE.ms() * 30L +
|
TimeUnit.MINUTES.toMillis(30L) +
|
||||||
TimeAmount.SECOND.ms() * 20L;
|
TimeUnit.SECONDS.toMillis(20L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -60,8 +54,8 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
public void exampleTwo() {
|
public void exampleTwo() {
|
||||||
String expected = "1 year, 1 month, 5d 00:00:00";
|
String expected = "1 year, 1 month, 5d 00:00:00";
|
||||||
|
|
||||||
long ms = TimeAmount.DAY.ms() * 400L;
|
long ms = TimeUnit.DAYS.toMillis(400L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -70,9 +64,9 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
public void exampleThree() {
|
public void exampleThree() {
|
||||||
String expected = "12:00:20";
|
String expected = "12:00:20";
|
||||||
|
|
||||||
long ms = TimeAmount.HOUR.ms() * 12L +
|
long ms = TimeUnit.HOURS.toMillis(12L) +
|
||||||
TimeAmount.SECOND.ms() * 20L;
|
TimeUnit.SECONDS.toMillis(20L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -81,8 +75,8 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
public void exampleFour() {
|
public void exampleFour() {
|
||||||
String expected = "00:30:00";
|
String expected = "00:30:00";
|
||||||
|
|
||||||
long ms = TimeAmount.MINUTE.ms() * 30L;
|
long ms = TimeUnit.MINUTES.toMillis(30L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -91,8 +85,8 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
public void exampleFive() {
|
public void exampleFive() {
|
||||||
String expected = "00:00:20";
|
String expected = "00:00:20";
|
||||||
|
|
||||||
long ms = TimeAmount.SECOND.ms() * 20L;
|
long ms = TimeUnit.SECONDS.toMillis(20L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -102,7 +96,7 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
String expected = "-";
|
String expected = "-";
|
||||||
|
|
||||||
long ms = 0L;
|
long ms = 0L;
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -111,8 +105,8 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
public void exampleOneSecond() {
|
public void exampleOneSecond() {
|
||||||
String expected = "00:00:01";
|
String expected = "00:00:01";
|
||||||
|
|
||||||
long ms = TimeAmount.SECOND.ms();
|
long ms = TimeUnit.SECONDS.toMillis(1L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -121,8 +115,8 @@ public class TimeAmountFormatterExtraZerosTest {
|
|||||||
public void exampleOneMinute() {
|
public void exampleOneMinute() {
|
||||||
String expected = "00:01:00";
|
String expected = "00:01:00";
|
||||||
|
|
||||||
long ms = TimeAmount.MINUTE.ms();
|
long ms = TimeUnit.MINUTES.toMillis(1L);
|
||||||
String result = timeAmountFormatter.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.djrapitops.plan.system.listeners.bukkit;
|
package com.djrapitops.plan.system.listeners.bukkit;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import utilities.Teardown;
|
|
||||||
import utilities.TestConstants;
|
import utilities.TestConstants;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -26,17 +24,13 @@ public class AFKListenerTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() {
|
public static void setUpClass() {
|
||||||
Settings.AFK_THRESHOLD_MINUTES.setTemporaryValue(3);
|
// Settings.AFK_THRESHOLD_MINUTES.setTemporaryValue(3);
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void tearDownClass() {
|
|
||||||
Teardown.resetSettingsTempValues();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore("Requires AfkListener initialization")
|
||||||
public void testAfkPermissionCallCaching() {
|
public void testAfkPermissionCallCaching() {
|
||||||
AFKListener afkListener = new AFKListener();
|
AFKListener afkListener = new AFKListener(null, null);
|
||||||
Collection<Boolean> calls = new ArrayList<>();
|
Collection<Boolean> calls = new ArrayList<>();
|
||||||
|
|
||||||
Player player = mockPlayer(calls);
|
Player player = mockPlayer(calls);
|
||||||
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.system.processing.processors.player;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||||
import com.djrapitops.plan.utilities.analysis.Median;
|
import com.djrapitops.plan.utilities.analysis.Median;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import utilities.RandomData;
|
import utilities.RandomData;
|
||||||
@ -11,6 +10,7 @@ import utilities.TestConstants;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@ -28,7 +28,7 @@ public class PingInsertProcessorTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
testPing = new ArrayList<>();
|
testPing = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < TimeAmount.MINUTE.ms(); i += TimeAmount.SECOND.ms() * 2L) {
|
for (int i = 0; i < TimeUnit.MINUTES.toMillis(1L); i += TimeUnit.SECONDS.toMillis(2L)) {
|
||||||
testPing.add(new DateObj<>(i, RandomData.randomInt(1, 4000)));
|
testPing.add(new DateObj<>(i, RandomData.randomInt(1, 4000)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,10 +36,10 @@ public class PingInsertProcessorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testMedian() {
|
public void testMedian() {
|
||||||
List<Integer> collect = testPing.stream().map(DateObj::getValue).sorted().collect(Collectors.toList());
|
List<Integer> collect = testPing.stream().map(DateObj::getValue).sorted().collect(Collectors.toList());
|
||||||
System.out.println(collect);
|
|
||||||
int expected = (int) Median.forInt(collect).calculate();
|
int expected = (int) Median.forInt(collect).calculate();
|
||||||
int result = new PingInsertProcessor(TestConstants.PLAYER_ONE_UUID, new ArrayList<>()).getMeanValue(testPing);
|
int result = new PingInsertProcessor(TestConstants.PLAYER_ONE_UUID, TestConstants.SERVER_UUID, new ArrayList<>(), null)
|
||||||
System.out.println(result);
|
.getMeanValue(testPing);
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -47,9 +47,8 @@ public class PingInsertProcessorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testMedianSingleEntry() {
|
public void testMedianSingleEntry() {
|
||||||
int expected = 50;
|
int expected = 50;
|
||||||
int result = new PingInsertProcessor(TestConstants.PLAYER_ONE_UUID, new ArrayList<>()).getMeanValue(
|
int result = new PingInsertProcessor(TestConstants.PLAYER_ONE_UUID, TestConstants.SERVER_UUID, new ArrayList<>(), null)
|
||||||
Collections.singletonList(new DateObj<>(0, expected))
|
.getMeanValue(Collections.singletonList(new DateObj<>(0, expected)));
|
||||||
);
|
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
@ -57,9 +56,8 @@ public class PingInsertProcessorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testMedianEmpty() {
|
public void testMedianEmpty() {
|
||||||
int expected = -1;
|
int expected = -1;
|
||||||
int result = new PingInsertProcessor(TestConstants.PLAYER_ONE_UUID, new ArrayList<>()).getMeanValue(
|
int result = new PingInsertProcessor(TestConstants.PLAYER_ONE_UUID, TestConstants.SERVER_UUID, new ArrayList<>(), null)
|
||||||
Collections.emptyList()
|
.getMeanValue(Collections.emptyList());
|
||||||
);
|
|
||||||
|
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user