mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-06-25 22:24:47 +02:00
[#777] Configuration format change
- Added a new config updater that can move and remove config values - Updated the config format to be easier to understand and read. - Made config updater update old configs to the new format - Removed Settings enum - Added generics to Setting, changed from interface to a class - Created new classes that hold static Setting objects - Added generics to PlanConfig - Added PlanConfig#get for getting Setting with generic types. - Moved config calls made during object initialization, possibly eliminating bugs that ignored config settings on first boot - Added more export settings - Added JSON Export (#700) - Fixed Buycraft graph not following Locale setting for timestamps - Extracted PluginBridge Bridge interface for mocking during tests
This commit is contained in:
parent
82b8cc09df
commit
8161488747
|
@ -21,8 +21,8 @@ import com.djrapitops.plan.system.database.databases.sql.H2DB;
|
|||
import com.djrapitops.plan.system.database.databases.sql.MySQLDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
@ -61,7 +61,7 @@ public class BukkitDBSystem extends DBSystem {
|
|||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
String dbType = config.getString(Settings.DB_TYPE).toLowerCase().trim();
|
||||
String dbType = config.getString(DatabaseSettings.TYPE).toLowerCase().trim();
|
||||
db = getActiveDatabaseByName(dbType);
|
||||
super.enable();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ import com.djrapitops.plan.Plan;
|
|||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -77,8 +77,8 @@ public class CommandListener implements Listener {
|
|||
private void actOnCommandEvent(PlayerCommandPreprocessEvent event) {
|
||||
String commandName = event.getMessage().substring(1).split(" ")[0].toLowerCase();
|
||||
|
||||
boolean logUnknownCommands = config.isTrue(Settings.LOG_UNKNOWN_COMMANDS);
|
||||
boolean combineCommandAliases = config.isTrue(Settings.COMBINE_COMMAND_ALIASES);
|
||||
boolean logUnknownCommands = config.isTrue(DataGatheringSettings.LOG_UNKNOWN_COMMANDS);
|
||||
boolean combineCommandAliases = config.isTrue(DataGatheringSettings.COMBINE_COMMAND_ALIASES);
|
||||
|
||||
if (!logUnknownCommands || combineCommandAliases) {
|
||||
Command command = getBukkitCommand(commandName);
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.djrapitops.plan.system.cache.SessionCache;
|
|||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.status.Status;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
@ -142,7 +142,7 @@ public class PlayerOnlineListener implements Listener {
|
|||
String playerName = player.getName();
|
||||
String displayName = player.getDisplayName();
|
||||
|
||||
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
|
||||
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
|
||||
|
||||
processing.submitCritical(() -> sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, world, gm)));
|
||||
runnableFactory.create("Player Register: " + uuid,
|
||||
|
|
|
@ -18,8 +18,8 @@ package com.djrapitops.plan.system.tasks;
|
|||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.ShutdownHook;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.tasks.bukkit.BukkitTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.bukkit.PaperTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.bukkit.PingCountTimerBukkit;
|
||||
|
@ -77,7 +77,7 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
|||
super.enable();
|
||||
try {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(config.getNumber(Settings.PING_SERVER_ENABLE_DELAY), TimeUnit.SECONDS);
|
||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
||||
registerTask("PingCountTimer", pingCountTimer)
|
||||
.runTaskTimer(startDelay, 40L);
|
||||
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
||||
|
|
|
@ -26,8 +26,8 @@ package com.djrapitops.plan.system.tasks.bukkit;
|
|||
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.utilities.java.Reflection;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
|
@ -199,7 +199,7 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
|||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
}).runTaskLater(TimeAmount.toTicks(config.getNumber(Settings.PING_PLAYER_LOGIN_DELAY), TimeUnit.SECONDS));
|
||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -6,8 +6,8 @@ package com.djrapitops.plan;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
@ -34,7 +34,7 @@ public class BukkitSystemTest {
|
|||
PlanSystem bukkitSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bukkitSystem.getConfigSystem().getConfig();
|
||||
config.set(Settings.WEBSERVER_PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
bukkitSystem.enable();
|
||||
} finally {
|
||||
bukkitSystem.disable();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.djrapitops.plan.system.listeners;
|
||||
|
||||
import com.djrapitops.plan.system.listeners.bukkit.AFKListener;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -12,6 +12,8 @@ import org.junit.Test;
|
|||
import org.mockito.Mockito;
|
||||
import utilities.TestConstants;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +28,7 @@ public class AFKListenerTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
PlanConfig config = Mockito.mock(PlanConfig.class);
|
||||
when(config.getNumber(Settings.AFK_THRESHOLD_MINUTES)).thenReturn(3);
|
||||
when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
|
||||
underTest = new AFKListener(config, new ConsoleErrorLogger(new TestPluginLogger()));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package com.djrapitops.plan.modules.bungee;
|
|||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.system.info.server.properties.BungeeServerProperties;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
@ -37,6 +36,6 @@ public class BungeeServerPropertiesModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
ServerProperties provideServerProperties(PlanBungee plugin, PlanConfig config) {
|
||||
return new BungeeServerProperties(plugin.getProxy(), config.getString(Settings.BUNGEE_IP));
|
||||
return new BungeeServerProperties(plugin.getProxy(), config);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package com.djrapitops.plan.system.info.server.properties;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
/**
|
||||
|
@ -27,14 +29,14 @@ import net.md_5.bungee.api.ProxyServer;
|
|||
*/
|
||||
public class BungeeServerProperties extends ServerProperties {
|
||||
|
||||
public BungeeServerProperties(ProxyServer server, String ip) {
|
||||
public BungeeServerProperties(ProxyServer server, PlanConfig config) {
|
||||
super(
|
||||
server.getServers().toString(),
|
||||
"BungeeCord",
|
||||
-1,
|
||||
server.getVersion(),
|
||||
server.getVersion(),
|
||||
() -> ip,
|
||||
() -> config.get(ProxySettings.IP),
|
||||
server.getConfig().getPlayerLimit(),
|
||||
RedisCheck.isClassAvailable() ? new RedisPlayersOnlineSupplier() : server::getOnlineCount
|
||||
);
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.djrapitops.plan.system.cache.SessionCache;
|
|||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
|
@ -80,7 +80,7 @@ public class PlayerOnlineListener implements Listener {
|
|||
|
||||
sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, "", ""));
|
||||
|
||||
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
|
||||
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
|
||||
|
||||
processing.submit(processors.player().proxyRegisterProcessor(uuid, name, time,
|
||||
gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package com.djrapitops.plan.system.tasks;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
|
||||
import com.djrapitops.plan.system.tasks.bungee.PingCountTimerBungee;
|
||||
import com.djrapitops.plan.system.tasks.proxy.NetworkPageRefreshTask;
|
||||
|
@ -80,7 +80,7 @@ public class BungeeTaskSystem extends TaskSystem {
|
|||
}).runTaskAsynchronously();
|
||||
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(config.getNumber(Settings.PING_SERVER_ENABLE_DELAY), TimeUnit.SECONDS);
|
||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
||||
runnableFactory.create("PingCountTimer", pingCountTimer).runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL);
|
||||
|
||||
registerTask(playersPageRefreshTask)
|
||||
|
|
|
@ -26,8 +26,8 @@ package com.djrapitops.plan.system.tasks.bungee;
|
|||
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
@ -125,7 +125,7 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
|||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
}).runTaskLater(TimeAmount.toTicks(config.getNumber(Settings.PING_PLAYER_LOGIN_DELAY), TimeUnit.SECONDS));
|
||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -7,8 +7,9 @@ package com.djrapitops.plan;
|
|||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
|
@ -41,8 +42,8 @@ public class BungeeSystemTest {
|
|||
PlanSystem bungeeSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
||||
config.set(Settings.WEBSERVER_PORT, 9005);
|
||||
config.set(Settings.BUNGEE_IP, "8.8.8.8");
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(ProxySettings.IP, "8.8.8.8");
|
||||
|
||||
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
||||
dbSystem.setActiveDatabase(dbSystem.getSqLiteFactory().usingDefaultFile());
|
||||
|
@ -62,8 +63,8 @@ public class BungeeSystemTest {
|
|||
PlanSystem bungeeSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
||||
config.set(Settings.WEBSERVER_PORT, 9005);
|
||||
config.set(Settings.BUNGEE_IP, "0.0.0.0");
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(ProxySettings.IP, "0.0.0.0");
|
||||
|
||||
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
||||
dbSystem.setActiveDatabase(dbSystem.getSqLiteFactory().usingDefaultFile());
|
||||
|
@ -83,8 +84,8 @@ public class BungeeSystemTest {
|
|||
PlanSystem bungeeSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
||||
config.set(Settings.WEBSERVER_PORT, 9005);
|
||||
config.set(Settings.BUNGEE_IP, "8.8.8.8");
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(ProxySettings.IP, "8.8.8.8");
|
||||
|
||||
bungeeSystem.enable();
|
||||
} finally {
|
||||
|
|
|
@ -20,8 +20,8 @@ import com.djrapitops.plan.command.commands.*;
|
|||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
|
@ -128,7 +128,7 @@ public class PlanCommand extends TreeCmdNode {
|
|||
infoCommand,
|
||||
reloadCommand,
|
||||
manageCommand.get(),
|
||||
config.isTrue(Settings.DEV_MODE) ? devCommand : null
|
||||
config.isTrue(PluginSettings.DEV_MODE) ? devCommand : null
|
||||
};
|
||||
setNodeGroups(analyticsGroup, webGroup, manageGroup);
|
||||
commandsRegistered = true;
|
||||
|
|
|
@ -32,8 +32,8 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
|||
import com.djrapitops.plan.system.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
@ -138,8 +138,8 @@ public class QInspectCommand extends CommandNode {
|
|||
|
||||
ActivityIndex activityIndex = player.getActivityIndex(
|
||||
now,
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD)
|
||||
config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD)
|
||||
);
|
||||
Long registered = player.getValue(PlayerKeys.REGISTERED).orElse(0L);
|
||||
Long lastSeen = player.getValue(PlayerKeys.LAST_SEEN).orElse(0L);
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
|||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
@ -95,7 +95,7 @@ public class ManageHotSwapCommand extends CommandNode {
|
|||
}
|
||||
|
||||
try {
|
||||
config.set(Settings.DB_TYPE, dbName);
|
||||
config.set(DatabaseSettings.TYPE, dbName);
|
||||
config.save();
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
|
|
|
@ -24,8 +24,8 @@ import com.djrapitops.plan.system.locale.lang.CommandLang;
|
|||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
|
@ -101,8 +101,7 @@ public class ManageSetupCommand extends CommandNode {
|
|||
private void requestSetup(Sender sender, String address) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
config.set(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE, false);
|
||||
config.set(Settings.BUNGEE_COPY_CONFIG, true);
|
||||
config.set(PluginSettings.BUNGEE_COPY_CONFIG, true);
|
||||
|
||||
infoSystem.requestSetUp(address);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public class InspectContainer {
|
|||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return values.isEmpty() && html.isEmpty() && tables.isEmpty();
|
||||
return values.isEmpty() && hasOnlyValues();
|
||||
}
|
||||
|
||||
public final boolean hasValues() {
|
||||
|
|
|
@ -27,8 +27,9 @@ import com.djrapitops.plan.data.time.WorldTimes;
|
|||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
@ -137,10 +138,10 @@ public class AnalysisContainer extends DataContainer {
|
|||
putRawData(AnalysisKeys.VERSION, version);
|
||||
putSupplier(AnalysisKeys.TIME_ZONE, config::getTimeZoneOffsetHours);
|
||||
putRawData(AnalysisKeys.FIRST_DAY, 1);
|
||||
putRawData(AnalysisKeys.TPS_MEDIUM, config.getNumber(Settings.THEME_GRAPH_TPS_THRESHOLD_MED));
|
||||
putRawData(AnalysisKeys.TPS_HIGH, config.getNumber(Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH));
|
||||
putRawData(AnalysisKeys.DISK_MEDIUM, config.getNumber(Settings.THEME_GRAPH_DISK_THRESHOLD_MED));
|
||||
putRawData(AnalysisKeys.DISK_HIGH, config.getNumber(Settings.THEME_GRAPH_DISK_THRESHOLD_HIGH));
|
||||
putRawData(AnalysisKeys.TPS_MEDIUM, config.getNumber(DisplaySettings.GRAPH_TPS_THRESHOLD_MED));
|
||||
putRawData(AnalysisKeys.TPS_HIGH, config.getNumber(DisplaySettings.GRAPH_TPS_THRESHOLD_HIGH));
|
||||
putRawData(AnalysisKeys.DISK_MEDIUM, config.getNumber(DisplaySettings.GRAPH_DISK_THRESHOLD_MED));
|
||||
putRawData(AnalysisKeys.DISK_HIGH, config.getNumber(DisplaySettings.GRAPH_DISK_THRESHOLD_HIGH));
|
||||
|
||||
addServerProperties();
|
||||
addThemeColors();
|
||||
|
@ -258,8 +259,8 @@ public class AnalysisContainer extends DataContainer {
|
|||
putCachingSupplier(retentionDay, () -> getUnsafe(AnalysisKeys.PLAYERS_MUTATOR).compareAndFindThoseLikelyToBeRetained(
|
||||
getUnsafe(newDay).all(), getUnsafe(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO),
|
||||
getUnsafe(AnalysisKeys.PLAYERS_ONLINE_RESOLVER),
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD)
|
||||
config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD)
|
||||
).count()
|
||||
);
|
||||
putSupplier(AnalysisKeys.PLAYERS_RETAINED_DAY, () -> {
|
||||
|
@ -404,7 +405,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
getUnsafe(AnalysisKeys.NEW_PLAYERS_PER_DAY)
|
||||
).toCalendarSeries());
|
||||
|
||||
putCachingSupplier(AnalysisKeys.ACTIVITY_DATA, () -> getUnsafe(AnalysisKeys.PLAYERS_MUTATOR).toActivityDataMap(getUnsafe(AnalysisKeys.ANALYSIS_TIME), config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD), config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD)));
|
||||
putCachingSupplier(AnalysisKeys.ACTIVITY_DATA, () -> getUnsafe(AnalysisKeys.PLAYERS_MUTATOR).toActivityDataMap(getUnsafe(AnalysisKeys.ANALYSIS_TIME), config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD), config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD)));
|
||||
Key<StackGraph> activityStackGraph = new Key<>(StackGraph.class, "ACTIVITY_STACK_GRAPH");
|
||||
putCachingSupplier(activityStackGraph, () -> graphs.stack().activityStackGraph(getUnsafe(AnalysisKeys.ACTIVITY_DATA)));
|
||||
putSupplier(AnalysisKeys.ACTIVITY_STACK_CATEGORIES, () -> getUnsafe(activityStackGraph).toHighChartsLabels());
|
||||
|
@ -439,7 +440,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
|
||||
putCachingSupplier(AnalysisKeys.PLAYERS_ONLINE_RESOLVER, () -> new PlayersOnlineResolver(getUnsafe(AnalysisKeys.TPS_MUTATOR)));
|
||||
|
||||
int threshold = config.getNumber(Settings.THEME_GRAPH_TPS_THRESHOLD_MED);
|
||||
int threshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
|
||||
putSupplier(AnalysisKeys.TPS_SPIKE_MONTH, () -> getUnsafe(tpsMonth).lowTpsSpikeCount(threshold));
|
||||
putSupplier(AnalysisKeys.AVG_TPS_MONTH, () -> getUnsafe(tpsMonth).averageTPS());
|
||||
|
@ -483,9 +484,9 @@ public class AnalysisContainer extends DataContainer {
|
|||
putCachingSupplier(healthInformation, () -> new HealthInformation(
|
||||
this,
|
||||
locale,
|
||||
config.getNumber(Settings.THEME_GRAPH_TPS_THRESHOLD_MED),
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD),
|
||||
config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED),
|
||||
config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD),
|
||||
formatters.timeAmount(), formatters.decimals(), formatters.percentage()
|
||||
));
|
||||
putSupplier(AnalysisKeys.HEALTH_INDEX, () -> getUnsafe(healthInformation).getServerHealth());
|
||||
|
|
|
@ -26,8 +26,9 @@ import com.djrapitops.plan.data.store.mutators.health.NetworkHealthInformation;
|
|||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
@ -127,8 +128,8 @@ public class NetworkContainer extends DataContainer {
|
|||
putCachingSupplier(healthInformation, () -> new NetworkHealthInformation(
|
||||
this,
|
||||
locale,
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD),
|
||||
formatters.timeAmount(), formatters.decimals(), formatters.percentage()
|
||||
));
|
||||
putCachingSupplier(NetworkKeys.HEALTH_INDEX, () -> getUnsafe(healthInformation).getServerHealth());
|
||||
|
@ -148,7 +149,7 @@ public class NetworkContainer extends DataContainer {
|
|||
|
||||
putCachingSupplier(NetworkKeys.NETWORK_NAME, () ->
|
||||
Check.isBungeeAvailable() || Check.isVelocityAvailable() ?
|
||||
config.getString(Settings.BUNGEE_NETWORK_NAME) :
|
||||
config.getString(ProxySettings.NETWORK_NAME) :
|
||||
bungeeContainer.getValue(ServerKeys.NAME).orElse("Plan")
|
||||
);
|
||||
putSupplier(NetworkKeys.PLAYERS_ONLINE, serverProperties::getOnlinePlayers);
|
||||
|
@ -171,7 +172,7 @@ public class NetworkContainer extends DataContainer {
|
|||
graphs.line().playersOnlineGraph(TPSMutator.forContainer(bungeeContainer)).toHighChartsSeries()
|
||||
);
|
||||
Key<StackGraph> activityStackGraph = new Key<>(StackGraph.class, "ACTIVITY_STACK_GRAPH");
|
||||
putSupplier(NetworkKeys.ACTIVITY_DATA, () -> getUnsafe(NetworkKeys.PLAYERS_MUTATOR).toActivityDataMap(getUnsafe(NetworkKeys.REFRESH_TIME), config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD), config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD)));
|
||||
putSupplier(NetworkKeys.ACTIVITY_DATA, () -> getUnsafe(NetworkKeys.PLAYERS_MUTATOR).toActivityDataMap(getUnsafe(NetworkKeys.REFRESH_TIME), config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD), config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD)));
|
||||
putSupplier(activityStackGraph, () -> graphs.stack().activityStackGraph(getUnsafe(NetworkKeys.ACTIVITY_DATA)));
|
||||
putSupplier(NetworkKeys.ACTIVITY_STACK_CATEGORIES, () -> getUnsafe(activityStackGraph).toHighChartsLabels());
|
||||
putSupplier(NetworkKeys.ACTIVITY_STACK_SERIES, () -> getUnsafe(activityStackGraph).toHighChartsSeries());
|
||||
|
|
|
@ -38,8 +38,8 @@ public class PlayerContainer extends DataContainer {
|
|||
activityIndexCache = new HashMap<>();
|
||||
}
|
||||
|
||||
public ActivityIndex getActivityIndex(long date, int minuteThreshold, int loginThreshold) {
|
||||
return activityIndexCache.computeIfAbsent(date, time -> new ActivityIndex(this, time, minuteThreshold, loginThreshold));
|
||||
public ActivityIndex getActivityIndex(long date, long playtimeMsThreshold, int loginThreshold) {
|
||||
return activityIndexCache.computeIfAbsent(date, time -> new ActivityIndex(this, time, playtimeMsThreshold, loginThreshold));
|
||||
}
|
||||
|
||||
public boolean playedBetween(long after, long before) {
|
||||
|
|
|
@ -24,20 +24,19 @@ import com.djrapitops.plugin.api.TimeAmount;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ActivityIndex {
|
||||
|
||||
private final double value;
|
||||
|
||||
private final int playThreshold;
|
||||
private final long playtimeMsThreshold;
|
||||
private final int loginThreshold;
|
||||
|
||||
public ActivityIndex(
|
||||
DataContainer container, long date,
|
||||
int minuteThreshold, int loginThreshold
|
||||
long playtimeMsThreshold, int loginThreshold
|
||||
) {
|
||||
this.playThreshold = minuteThreshold;
|
||||
this.playtimeMsThreshold = playtimeMsThreshold;
|
||||
this.loginThreshold = loginThreshold;
|
||||
|
||||
value = calculate(container, date);
|
||||
|
@ -53,7 +52,7 @@ public class ActivityIndex {
|
|||
long twoWeeksAgo = date - 2L * week;
|
||||
long threeWeeksAgo = date - 3L * week;
|
||||
|
||||
long activePlayThreshold = TimeUnit.MINUTES.toMillis(playThreshold);
|
||||
long activePlayThreshold = playtimeMsThreshold;
|
||||
int activeLoginThreshold = loginThreshold;
|
||||
|
||||
Optional<List<Session>> sessionsValue = container.getValue(PlayerKeys.SESSIONS);
|
||||
|
|
|
@ -86,8 +86,8 @@ public class PlayersMutator {
|
|||
);
|
||||
}
|
||||
|
||||
public PlayersMutator filterActive(long date, int minuteThreshold, int loginThreshold, double limit) {
|
||||
return filterBy(player -> player.getActivityIndex(date, minuteThreshold, loginThreshold).getValue() >= limit);
|
||||
public PlayersMutator filterActive(long date, long msThreshold, int loginThreshold, double limit) {
|
||||
return filterBy(player -> player.getActivityIndex(date, msThreshold, loginThreshold).getValue() >= limit);
|
||||
}
|
||||
|
||||
public PlayersMutator filterPlayedOnServer(UUID serverUUID) {
|
||||
|
@ -139,7 +139,7 @@ public class PlayersMutator {
|
|||
return pingPerCountry;
|
||||
}
|
||||
|
||||
public TreeMap<Long, Map<String, Set<UUID>>> toActivityDataMap(long date, int minuteThreshold, int loginThreshold) {
|
||||
public TreeMap<Long, Map<String, Set<UUID>>> toActivityDataMap(long date, long msThreshold, int loginThreshold) {
|
||||
TreeMap<Long, Map<String, Set<UUID>>> activityData = new TreeMap<>();
|
||||
for (long time = date; time >= date - TimeAmount.MONTH.toMillis(2L); time -= TimeAmount.WEEK.toMillis(1L)) {
|
||||
Map<String, Set<UUID>> map = activityData.getOrDefault(time, new HashMap<>());
|
||||
|
@ -148,7 +148,7 @@ public class PlayersMutator {
|
|||
if (player.getValue(PlayerKeys.REGISTERED).orElse(0L) > time) {
|
||||
continue;
|
||||
}
|
||||
ActivityIndex activityIndex = player.getActivityIndex(time, minuteThreshold, loginThreshold);
|
||||
ActivityIndex activityIndex = player.getActivityIndex(time, msThreshold, loginThreshold);
|
||||
String activityGroup = activityIndex.getGroup();
|
||||
|
||||
Set<UUID> uuids = map.getOrDefault(activityGroup, new HashSet<>());
|
||||
|
@ -195,7 +195,7 @@ public class PlayersMutator {
|
|||
Iterable<PlayerContainer> compareTo,
|
||||
long dateLimit,
|
||||
PlayersOnlineResolver onlineResolver,
|
||||
int activityMinuteThreshold,
|
||||
long activityMsThreshold,
|
||||
int activityLoginThreshold
|
||||
) {
|
||||
Collection<PlayerContainer> retainedAfterMonth = new ArrayList<>();
|
||||
|
@ -223,10 +223,10 @@ public class PlayersMutator {
|
|||
}
|
||||
|
||||
List<RetentionData> retained = retainedAfterMonth.stream()
|
||||
.map(player -> new RetentionData(player, onlineResolver, activityMinuteThreshold, activityLoginThreshold))
|
||||
.map(player -> new RetentionData(player, onlineResolver, activityMsThreshold, activityLoginThreshold))
|
||||
.collect(Collectors.toList());
|
||||
List<RetentionData> notRetained = notRetainedAfterMonth.stream()
|
||||
.map(player -> new RetentionData(player, onlineResolver, activityMinuteThreshold, activityLoginThreshold))
|
||||
.map(player -> new RetentionData(player, onlineResolver, activityMsThreshold, activityLoginThreshold))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
RetentionData avgRetained = RetentionData.average(retained);
|
||||
|
@ -234,7 +234,7 @@ public class PlayersMutator {
|
|||
|
||||
List<PlayerContainer> toBeRetained = new ArrayList<>();
|
||||
for (PlayerContainer player : compareTo) {
|
||||
RetentionData retentionData = new RetentionData(player, onlineResolver, activityMinuteThreshold, activityLoginThreshold);
|
||||
RetentionData retentionData = new RetentionData(player, onlineResolver, activityMsThreshold, activityLoginThreshold);
|
||||
if (retentionData.distance(avgRetained) < retentionData.distance(avgNotRetained)) {
|
||||
toBeRetained.add(player);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class RetentionData {
|
|||
public RetentionData(
|
||||
PlayerContainer player,
|
||||
PlayersOnlineResolver onlineOnJoin,
|
||||
int activityMinuteThreshold,
|
||||
long activityMsThreshold,
|
||||
int activityLoginThreshold
|
||||
) {
|
||||
Optional<Long> registeredValue = player.getValue(PlayerKeys.REGISTERED);
|
||||
|
@ -68,7 +68,7 @@ public class RetentionData {
|
|||
.map(registered -> new ActivityIndex(
|
||||
player,
|
||||
registered + TimeUnit.DAYS.toMillis(1L),
|
||||
activityMinuteThreshold,
|
||||
activityMsThreshold,
|
||||
activityLoginThreshold
|
||||
).getValue())
|
||||
.orElse(0.0);
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class AbstractHealthInfo {
|
|||
protected double serverHealth;
|
||||
|
||||
protected final Locale locale;
|
||||
protected final int activeMinuteThreshold;
|
||||
protected final long activeMsThreshold;
|
||||
protected final int activeLoginThreshold;
|
||||
protected final Formatter<Long> timeAmountFormatter;
|
||||
protected final Formatter<Double> decimalFormatter;
|
||||
|
@ -46,7 +46,8 @@ public abstract class AbstractHealthInfo {
|
|||
|
||||
public AbstractHealthInfo(
|
||||
long now, long monthAgo,
|
||||
Locale locale, int activeMinuteThreshold,
|
||||
Locale locale,
|
||||
long activeMsThreshold,
|
||||
int activeLoginThreshold,
|
||||
Formatter<Long> timeAmountFormatter,
|
||||
Formatter<Double> decimalFormatter,
|
||||
|
@ -55,7 +56,7 @@ public abstract class AbstractHealthInfo {
|
|||
this.now = now;
|
||||
this.monthAgo = monthAgo;
|
||||
this.locale = locale;
|
||||
this.activeMinuteThreshold = activeMinuteThreshold;
|
||||
this.activeMsThreshold = activeMsThreshold;
|
||||
this.activeLoginThreshold = activeLoginThreshold;
|
||||
this.timeAmountFormatter = timeAmountFormatter;
|
||||
this.decimalFormatter = decimalFormatter;
|
||||
|
@ -139,7 +140,7 @@ public abstract class AbstractHealthInfo {
|
|||
}
|
||||
|
||||
protected void activePlayerPlaytimeChange(PlayersMutator playersMutator) {
|
||||
PlayersMutator currentlyActive = playersMutator.filterActive(now, activeMinuteThreshold, activeLoginThreshold, 1.75);
|
||||
PlayersMutator currentlyActive = playersMutator.filterActive(now, activeMsThreshold, activeLoginThreshold, 1.75);
|
||||
long twoWeeksAgo = now - ((now - monthAgo) / 2L);
|
||||
|
||||
long totalFourToTwoWeeks = 0;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class HealthInformation extends AbstractHealthInfo {
|
|||
AnalysisContainer analysisContainer,
|
||||
Locale locale,
|
||||
int lowTPSThreshold,
|
||||
int activeMinuteThreshold,
|
||||
long activeMsThreshold,
|
||||
int activeLoginThreshold,
|
||||
Formatter<Long> timeAmountFormatter,
|
||||
Formatter<Double> decimalFormatter,
|
||||
|
@ -57,7 +57,7 @@ public class HealthInformation extends AbstractHealthInfo {
|
|||
analysisContainer.getUnsafe(AnalysisKeys.ANALYSIS_TIME),
|
||||
analysisContainer.getUnsafe(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO),
|
||||
locale,
|
||||
activeMinuteThreshold, activeLoginThreshold,
|
||||
activeMsThreshold, activeLoginThreshold,
|
||||
timeAmountFormatter, decimalFormatter, percentageFormatter
|
||||
);
|
||||
this.analysisContainer = analysisContainer;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo {
|
|||
public NetworkHealthInformation(
|
||||
NetworkContainer container,
|
||||
Locale locale,
|
||||
int activeMinuteThreshold,
|
||||
long activeMsThreshold,
|
||||
int activeLoginThreshold,
|
||||
Formatter<Long> timeAmountFormatter,
|
||||
Formatter<Double> decimalFormatter,
|
||||
|
@ -49,7 +49,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo {
|
|||
container.getUnsafe(NetworkKeys.REFRESH_TIME),
|
||||
container.getUnsafe(NetworkKeys.REFRESH_TIME_MONTH_AGO),
|
||||
locale,
|
||||
activeMinuteThreshold, activeLoginThreshold,
|
||||
activeMsThreshold, activeLoginThreshold,
|
||||
timeAmountFormatter, decimalFormatter, percentageFormatter
|
||||
);
|
||||
this.container = container;
|
||||
|
|
|
@ -18,11 +18,10 @@ package com.djrapitops.plan.system.afk;
|
|||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Keeps track how long player has been afk during a session
|
||||
|
@ -33,12 +32,12 @@ public class AFKTracker {
|
|||
|
||||
private final Set<UUID> usedAFKCommand;
|
||||
private final Map<UUID, Long> lastMovement;
|
||||
private final long afkThresholdMs;
|
||||
private final PlanConfig config;
|
||||
|
||||
public AFKTracker(PlanConfig config) {
|
||||
this.config = config;
|
||||
usedAFKCommand = new HashSet<>();
|
||||
lastMovement = new HashMap<>();
|
||||
afkThresholdMs = TimeUnit.MINUTES.toMillis(config.getNumber(Settings.AFK_THRESHOLD_MINUTES));
|
||||
}
|
||||
|
||||
public void hasIgnorePermission(UUID uuid) {
|
||||
|
@ -47,7 +46,7 @@ public class AFKTracker {
|
|||
|
||||
public void usedAfkCommand(UUID uuid, long time) {
|
||||
usedAFKCommand.add(uuid);
|
||||
lastMovement.put(uuid, time - afkThresholdMs);
|
||||
lastMovement.put(uuid, time - config.get(TimeSettings.AFK_THRESHOLD));
|
||||
}
|
||||
|
||||
public void performedAction(UUID uuid, long time) {
|
||||
|
@ -58,12 +57,12 @@ public class AFKTracker {
|
|||
lastMovement.put(uuid, time);
|
||||
|
||||
try {
|
||||
if (time - lastMoved < afkThresholdMs) {
|
||||
if (time - lastMoved < config.get(TimeSettings.AFK_THRESHOLD)) {
|
||||
// Threshold not crossed, no action required.
|
||||
return;
|
||||
}
|
||||
|
||||
long removeAfkCommandEffect = usedAFKCommand.contains(uuid) ? afkThresholdMs : 0;
|
||||
long removeAfkCommandEffect = usedAFKCommand.contains(uuid) ? config.get(TimeSettings.AFK_THRESHOLD) : 0;
|
||||
long timeAFK = time - lastMoved - removeAfkCommandEffect;
|
||||
|
||||
Optional<Session> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -90,6 +89,6 @@ public class AFKTracker {
|
|||
if (lastMoved == null || lastMoved == -1) {
|
||||
return false;
|
||||
}
|
||||
return time - lastMoved > afkThresholdMs;
|
||||
return time - lastMoved > config.get(TimeSettings.AFK_THRESHOLD);
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ import com.djrapitops.plan.system.SubSystem;
|
|||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.maxmind.geoip2.DatabaseReader;
|
||||
|
@ -82,7 +82,7 @@ public class GeolocationCache implements SubSystem {
|
|||
@Override
|
||||
public void enable() throws EnableException {
|
||||
geolocationDB = files.getFileFromPluginFolder("GeoIP.dat");
|
||||
if (config.isTrue(Settings.DATA_GEOLOCATIONS)) {
|
||||
if (config.isTrue(DataGatheringSettings.GEOLOCATIONS)) {
|
||||
try {
|
||||
checkDB();
|
||||
} catch (UnknownHostException e) {
|
||||
|
|
|
@ -22,8 +22,8 @@ import com.djrapitops.plan.system.database.databases.DBType;
|
|||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
|
@ -92,8 +92,8 @@ public class H2DB extends SQLDB {
|
|||
}
|
||||
|
||||
private Connection getConnectionFor(String dbFilePath) throws SQLException {
|
||||
String username = config.getString(Settings.DB_USER);
|
||||
String password = config.getString(Settings.DB_PASS);
|
||||
String username = config.getString(DatabaseSettings.MYSQL_USER);
|
||||
String password = config.getString(DatabaseSettings.MYSQL_PASS);
|
||||
|
||||
JdbcDataSource jdbcDataSource = new JdbcDataSource();
|
||||
jdbcDataSource.setURL("jdbc:h2:file:" + dbFilePath + ";mode=MySQL");
|
||||
|
|
|
@ -23,8 +23,8 @@ import com.djrapitops.plan.system.database.databases.DBType;
|
|||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -81,18 +81,18 @@ public class MySQLDB extends SQLDB {
|
|||
try {
|
||||
HikariConfig hikariConfig = new HikariConfig();
|
||||
|
||||
String host = config.getString(Settings.DB_HOST);
|
||||
String port = config.getString(Settings.DB_PORT);
|
||||
String database = config.getString(Settings.DB_DATABASE);
|
||||
String launchOptions = config.getString(Settings.DB_LAUNCH_OPTIONS);
|
||||
String host = config.getString(DatabaseSettings.MYSQL_HOST);
|
||||
String port = config.getString(DatabaseSettings.MYSQL_PORT);
|
||||
String database = config.getString(DatabaseSettings.MYSQL_DATABASE);
|
||||
String launchOptions = config.getString(DatabaseSettings.MYSQL_LAUNCH_OPTIONS);
|
||||
if (launchOptions.isEmpty() || !launchOptions.startsWith("?") || launchOptions.endsWith("&")) {
|
||||
launchOptions = "?rewriteBatchedStatements=true&useSSL=false";
|
||||
logger.error(locale.getString(PluginLang.DB_MYSQL_LAUNCH_OPTIONS_FAIL, launchOptions));
|
||||
}
|
||||
hikariConfig.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/" + database + launchOptions);
|
||||
|
||||
String username = config.getString(Settings.DB_USER);
|
||||
String password = config.getString(Settings.DB_PASS);
|
||||
String username = config.getString(DatabaseSettings.MYSQL_USER);
|
||||
String password = config.getString(DatabaseSettings.MYSQL_PASS);
|
||||
|
||||
hikariConfig.setUsername(username);
|
||||
hikariConfig.setPassword(password);
|
||||
|
|
|
@ -28,8 +28,9 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryStateme
|
|||
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
|
@ -171,7 +172,10 @@ public abstract class SQLDB extends Database {
|
|||
cancel();
|
||||
}
|
||||
}
|
||||
}).runTaskTimerAsynchronously(TimeAmount.toTicks(secondsDelay, TimeUnit.SECONDS), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
}).runTaskTimerAsynchronously(
|
||||
TimeAmount.toTicks(secondsDelay, TimeUnit.SECONDS),
|
||||
TimeAmount.toTicks(config.get(TimeSettings.CLEAN_DATABASE_PERIOD), TimeUnit.MILLISECONDS)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +270,7 @@ public abstract class SQLDB extends Database {
|
|||
pingTable.clean();
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
long keepActiveAfter = now - TimeUnit.DAYS.toMillis(config.getNumber(Settings.KEEP_INACTIVE_PLAYERS_DAYS));
|
||||
long keepActiveAfter = now - config.get(TimeSettings.KEEP_INACTIVE_PLAYERS);
|
||||
|
||||
List<UUID> inactivePlayers = sessionsTable.getLastSeenForAllPlayers().entrySet().stream()
|
||||
.filter(entry -> entry.getValue() < keepActiveAfter)
|
||||
|
@ -296,7 +300,7 @@ public abstract class SQLDB extends Database {
|
|||
try {
|
||||
connection = getConnection();
|
||||
// Inject Timings to the statement for benchmarking
|
||||
if (config.isTrue(Settings.DEV_MODE)) {
|
||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||
statement.setTimings(timings);
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(statement.getSql())) {
|
||||
|
@ -324,7 +328,7 @@ public abstract class SQLDB extends Database {
|
|||
try {
|
||||
execute(statement);
|
||||
} catch (DBOpException e) {
|
||||
if (config.isTrue(Settings.DEV_MODE)) {
|
||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +344,7 @@ public abstract class SQLDB extends Database {
|
|||
try {
|
||||
connection = getConnection();
|
||||
// Inject Timings to the statement for benchmarking
|
||||
if (config.isTrue(Settings.DEV_MODE)) {
|
||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||
statement.setTimings(timings);
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(statement.getSql())) {
|
||||
|
@ -362,7 +366,7 @@ public abstract class SQLDB extends Database {
|
|||
try {
|
||||
connection = getConnection();
|
||||
// Inject Timings to the statement for benchmarking
|
||||
if (config.isTrue(Settings.DEV_MODE)) {
|
||||
if (config.isTrue(PluginSettings.DEV_MODE)) {
|
||||
statement.setTimings(timings);
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(statement.getSql())) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -46,7 +46,7 @@ public abstract class Patch {
|
|||
return db.query(query);
|
||||
}
|
||||
|
||||
public boolean hasTable(String tableName) {
|
||||
protected boolean hasTable(String tableName) {
|
||||
boolean secondParameter;
|
||||
|
||||
String sql;
|
||||
|
@ -66,7 +66,7 @@ public abstract class Patch {
|
|||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, tableName);
|
||||
if (secondParameter) {
|
||||
statement.setString(2, db.getConfig().getString(Settings.DB_DATABASE));
|
||||
statement.setString(2, db.getConfig().getString(DatabaseSettings.MYSQL_DATABASE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public abstract class Patch {
|
|||
statement.setString(1, tableName);
|
||||
statement.setString(2, columnName);
|
||||
if (dbType != DBType.H2) {
|
||||
statement.setString(3, db.getConfig().getString(Settings.DB_DATABASE));
|
||||
statement.setString(3, db.getConfig().getString(DatabaseSettings.MYSQL_DATABASE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
package com.djrapitops.plan.system.export;
|
||||
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
import com.djrapitops.plan.system.settings.paths.ExportSettings;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -36,22 +37,39 @@ public class ExportSystem implements SubSystem {
|
|||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final HtmlExport htmlExport;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
@Inject
|
||||
public ExportSystem(
|
||||
PlanConfig config,
|
||||
Processing processing,
|
||||
HtmlExport htmlExport
|
||||
HtmlExport htmlExport,
|
||||
ConnectionSystem connectionSystem
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.htmlExport = htmlExport;
|
||||
this.connectionSystem = connectionSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
|
||||
processing.submitNonCritical(htmlExport);
|
||||
if (Check.isBukkitAvailable() && connectionSystem.isServerAvailable()) {
|
||||
return;
|
||||
}
|
||||
if (config.isTrue(ExportSettings.JS_AND_CSS)) {
|
||||
processing.submitNonCritical(htmlExport::exportJs);
|
||||
processing.submitNonCritical(htmlExport::exportCss);
|
||||
processing.submitNonCritical(htmlExport::exportPlugins);
|
||||
}
|
||||
if (config.isTrue(ExportSettings.PLAYERS_PAGE)) {
|
||||
processing.submitNonCritical(htmlExport::exportPlayersPage);
|
||||
}
|
||||
if (config.isTrue(ExportSettings.PLAYER_PAGES)) {
|
||||
processing.submitNonCritical(htmlExport::exportAvailablePlayers);
|
||||
}
|
||||
if (config.isTrue(ExportSettings.SERVER_PAGE)) {
|
||||
processing.submitNonCritical(htmlExport::exportAvailableServerPages);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.file.export;
|
||||
package com.djrapitops.plan.system.export;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
|||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ExportSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
|
@ -52,6 +53,7 @@ import java.util.*;
|
|||
public class HtmlExport extends SpecificExport {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final PlanConfig config;
|
||||
private final Theme theme;
|
||||
private final Processing processing;
|
||||
private final PlanFiles files;
|
||||
|
@ -73,8 +75,9 @@ public class HtmlExport extends SpecificExport {
|
|||
ConnectionSystem connectionSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(files, config, serverInfo);
|
||||
super(files, serverInfo);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.processing = processing;
|
||||
this.files = files;
|
||||
|
@ -84,18 +87,23 @@ public class HtmlExport extends SpecificExport {
|
|||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPath() {
|
||||
return config.get(ExportSettings.HTML_EXPORT_PATH);
|
||||
}
|
||||
|
||||
public void exportServer(UUID serverUUID) {
|
||||
if (Check.isBukkitAvailable() && connectionSystem.isServerAvailable()) {
|
||||
return;
|
||||
}
|
||||
Optional<String> serverName = dbSystem.getDatabase().fetch().getServerName(serverUUID);
|
||||
serverName.ifPresent(name -> processing.submitNonCritical(() -> {
|
||||
serverName.ifPresent(name -> {
|
||||
try {
|
||||
exportAvailableServerPage(serverUUID, name);
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public void exportPlayer(UUID uuid) {
|
||||
|
@ -104,65 +112,56 @@ public class HtmlExport extends SpecificExport {
|
|||
}
|
||||
String playerName = dbSystem.getDatabase().fetch().getPlayerName(uuid);
|
||||
if (playerName != null) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
exportAvailablePlayerPage(uuid, playerName);
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
try {
|
||||
exportAvailablePlayerPage(uuid, playerName);
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void exportPlayersPage() {
|
||||
try {
|
||||
if (Check.isBukkitAvailable() && connectionSystem.isServerAvailable()) {
|
||||
return;
|
||||
}
|
||||
String html = pageFactory.playersPage().toHtml()
|
||||
.replace("href=\"plugins/", "href=\"../plugins/")
|
||||
.replace("href=\"css/", "href=\"../css/")
|
||||
.replace("src=\"plugins/", "src=\"../plugins/")
|
||||
.replace("src=\"js/", "src=\"../js/");
|
||||
List<String> lines = Arrays.asList(html.split("\n"));
|
||||
|
||||
exportCss();
|
||||
exportJs();
|
||||
exportPlugins();
|
||||
|
||||
exportAvailableServerPages();
|
||||
exportAvailablePlayers();
|
||||
exportPlayersPage();
|
||||
File htmlLocation = new File(getFolder(), "players");
|
||||
Verify.isTrue(htmlLocation.exists() && htmlLocation.isDirectory() || htmlLocation.mkdirs(),
|
||||
() -> new FileNotFoundException("Output folder could not be created at" + htmlLocation.getAbsolutePath()));
|
||||
File exportFile = new File(htmlLocation, "index.html");
|
||||
export(exportFile, lines);
|
||||
} catch (IOException | DBOpException | ParseException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportPlayersPage() throws IOException, ParseException {
|
||||
String html = pageFactory.playersPage().toHtml()
|
||||
.replace("href=\"plugins/", "href=\"../plugins/")
|
||||
.replace("href=\"css/", "href=\"../css/")
|
||||
.replace("src=\"plugins/", "src=\"../plugins/")
|
||||
.replace("src=\"js/", "src=\"../js/");
|
||||
List<String> lines = Arrays.asList(html.split("\n"));
|
||||
|
||||
File htmlLocation = new File(outputFolder, "players");
|
||||
Verify.isTrue(htmlLocation.exists() && htmlLocation.isDirectory() || htmlLocation.mkdirs(),
|
||||
() -> new FileNotFoundException("Output folder could not be created at" + htmlLocation.getAbsolutePath()));
|
||||
File exportFile = new File(htmlLocation, "index.html");
|
||||
export(exportFile, lines);
|
||||
}
|
||||
|
||||
private void exportAvailablePlayers() throws IOException {
|
||||
for (Map.Entry<UUID, UserInfo> entry : dbSystem.getDatabase().fetch().getUsers().entrySet()) {
|
||||
exportAvailablePlayerPage(entry.getKey(), entry.getValue().getName());
|
||||
public void exportAvailablePlayers() {
|
||||
try {
|
||||
for (Map.Entry<UUID, UserInfo> entry : dbSystem.getDatabase().fetch().getUsers().entrySet()) {
|
||||
exportAvailablePlayerPage(entry.getKey(), entry.getValue().getName());
|
||||
}
|
||||
} catch (IOException | DBOpException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportAvailableServerPages() throws IOException {
|
||||
Map<UUID, String> serverNames = dbSystem.getDatabase().fetch().getServerNames();
|
||||
public void exportAvailableServerPages() {
|
||||
try {
|
||||
Map<UUID, String> serverNames = dbSystem.getDatabase().fetch().getServerNames();
|
||||
|
||||
for (Map.Entry<UUID, String> entry : serverNames.entrySet()) {
|
||||
exportAvailableServerPage(entry.getKey(), entry.getValue());
|
||||
for (Map.Entry<UUID, String> entry : serverNames.entrySet()) {
|
||||
exportAvailableServerPage(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} catch (IOException | DBOpException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportCss() {
|
||||
public void exportCss() {
|
||||
String[] resources = new String[]{
|
||||
"web/css/main.css",
|
||||
"web/css/materialize.css",
|
||||
|
@ -172,7 +171,7 @@ public class HtmlExport extends SpecificExport {
|
|||
copyFromJar(resources);
|
||||
}
|
||||
|
||||
private void exportJs() {
|
||||
public void exportJs() {
|
||||
String[] resources = new String[]{
|
||||
"web/js/demo.js",
|
||||
"web/js/admin.js",
|
||||
|
@ -203,7 +202,7 @@ public class HtmlExport extends SpecificExport {
|
|||
String demo = files.readFromResourceFlat("web/js/demo.js")
|
||||
.replace("${defaultTheme}", theme.getValue(ThemeVal.THEME_DEFAULT));
|
||||
List<String> lines = Arrays.asList(demo.split("\n"));
|
||||
File outputFolder = new File(this.outputFolder, "js");
|
||||
File outputFolder = new File(getFolder(), "js");
|
||||
Verify.isTrue(outputFolder.exists() && outputFolder.isDirectory() || outputFolder.mkdirs(),
|
||||
() -> new FileNotFoundException("Output folder could not be created at" + outputFolder.getAbsolutePath()));
|
||||
export(new File(outputFolder, "demo.js"), lines);
|
||||
|
@ -212,7 +211,7 @@ public class HtmlExport extends SpecificExport {
|
|||
}
|
||||
}
|
||||
|
||||
private void exportPlugins() {
|
||||
public void exportPlugins() {
|
||||
String[] resources = new String[]{
|
||||
"web/plugins/bootstrap/css/bootstrap.css",
|
||||
"web/plugins/node-waves/waves.css",
|
||||
|
@ -244,7 +243,7 @@ public class HtmlExport extends SpecificExport {
|
|||
String possibleFile = resource.replace("web/", "").replace("/", File.separator);
|
||||
List<String> lines = FileUtil.lines(plugin, new File(plugin.getDataFolder(), possibleFile), resource);
|
||||
String outputFile = possibleFile.replace("web/", "");
|
||||
File to = new File(outputFolder, outputFile);
|
||||
File to = new File(getFolder(), outputFile);
|
||||
File locationFolder = to.getParentFile();
|
||||
Verify.isTrue(locationFolder.exists() && locationFolder.isDirectory() || locationFolder.mkdirs(),
|
||||
() -> new FileNotFoundException("Output folder could not be created at" + locationFolder.getAbsolutePath()));
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.export;
|
||||
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ExportSettings;
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Class in charge of exporting json files.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class JSONExport extends SpecificExport {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
private final ResponseFactory responseFactory;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public JSONExport(
|
||||
PlanFiles files,
|
||||
PlanConfig config,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
ResponseFactory responseFactory,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(files, serverInfo);
|
||||
this.config = config;
|
||||
this.dbSystem = dbSystem;
|
||||
this.responseFactory = responseFactory;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPath() {
|
||||
return config.get(ExportSettings.JSON_EXPORT_PATH);
|
||||
}
|
||||
|
||||
public void exportPlayerJSON(UUID uuid) {
|
||||
String json = responseFactory.rawPlayerPageResponse(uuid).getContent();
|
||||
String playerName = dbSystem.getDatabase().fetch().getPlayerName(uuid);
|
||||
if (playerName != null) {
|
||||
try {
|
||||
File htmlLocation = getPlayerFolder();
|
||||
htmlLocation.mkdirs();
|
||||
File exportFile = new File(htmlLocation, playerName.replace(" ", "%20").replace(".", "%2E") + ".json");
|
||||
|
||||
export(exportFile, Collections.singletonList(json));
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exportServerJSON(UUID serverUUID) {
|
||||
String json = responseFactory.rawServerPageResponse(serverUUID).getContent();
|
||||
Optional<String> serverName = dbSystem.getDatabase().fetch().getServerName(serverUUID);
|
||||
serverName.ifPresent(name -> {
|
||||
try {
|
||||
File htmlLocation = getServerFolder();
|
||||
htmlLocation.mkdirs();
|
||||
File exportFile = new File(htmlLocation, name.replace(" ", "%20").replace(".", "%2E") + ".json");
|
||||
|
||||
export(exportFile, Collections.singletonList(json));
|
||||
} catch (IOException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -14,12 +14,10 @@
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.file.export;
|
||||
package com.djrapitops.plan.system.export;
|
||||
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
|
@ -39,31 +37,26 @@ import java.util.UUID;
|
|||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class SpecificExport implements Runnable {
|
||||
public abstract class SpecificExport {
|
||||
|
||||
private final PlanFiles files;
|
||||
private final PlanConfig config;
|
||||
private final ServerInfo serverInfo;
|
||||
|
||||
protected final File outputFolder;
|
||||
private final boolean usingProxy;
|
||||
|
||||
protected SpecificExport(
|
||||
PlanFiles files,
|
||||
PlanConfig config,
|
||||
ServerInfo serverInfo
|
||||
) {
|
||||
this.files = files;
|
||||
this.config = config;
|
||||
this.serverInfo = serverInfo;
|
||||
outputFolder = getFolder();
|
||||
usingProxy = Check.isBungeeAvailable() || Check.isVelocityAvailable();
|
||||
}
|
||||
|
||||
protected File getFolder() {
|
||||
File folder;
|
||||
|
||||
String path = config.getString(Settings.ANALYSIS_EXPORT_PATH);
|
||||
String path = getPath();
|
||||
boolean isAbsolute = Paths.get(path).isAbsolute();
|
||||
if (isAbsolute) {
|
||||
folder = new File(path);
|
||||
|
@ -78,18 +71,20 @@ public abstract class SpecificExport implements Runnable {
|
|||
return folder;
|
||||
}
|
||||
|
||||
protected abstract String getPath();
|
||||
|
||||
protected void export(File to, List<String> lines) throws IOException {
|
||||
Files.write(to.toPath(), lines, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
protected File getServerFolder() {
|
||||
File server = new File(outputFolder, "server");
|
||||
File server = new File(getFolder(), "server");
|
||||
server.mkdirs();
|
||||
return server;
|
||||
}
|
||||
|
||||
protected File getPlayerFolder() {
|
||||
File player = new File(outputFolder, "player");
|
||||
File player = new File(getFolder(), "player");
|
||||
player.mkdirs();
|
||||
return player;
|
||||
}
|
||||
|
@ -126,7 +121,7 @@ public abstract class SpecificExport implements Runnable {
|
|||
File htmlLocation;
|
||||
if (usingProxy) {
|
||||
if (serverUUID.equals(serverInfo.getServerUUID())) {
|
||||
htmlLocation = new File(outputFolder, "network");
|
||||
htmlLocation = new File(getFolder(), "network");
|
||||
} else {
|
||||
htmlLocation = new File(getServerFolder(), serverName.replace(" ", "%20").replace(".", "%2E"));
|
||||
html = html.replace("../", "../../");
|
|
@ -27,8 +27,8 @@ import com.djrapitops.plan.system.info.server.ServerInfo;
|
|||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -135,7 +135,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
|||
|
||||
@Override
|
||||
public boolean isServerAvailable() {
|
||||
return mainServer != null && config.isFalse(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE);
|
||||
return mainServer != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,7 +150,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
|||
refreshServerMap();
|
||||
|
||||
boolean usingBungeeWebServer = isServerAvailable();
|
||||
boolean usingAlternativeIP = config.isTrue(Settings.SHOW_ALTERNATIVE_IP);
|
||||
boolean usingAlternativeIP = config.isTrue(WebserverSettings.SHOW_ALTERNATIVE_IP);
|
||||
|
||||
if (!usingAlternativeIP && serverInfo.getServerProperties().getIp().isEmpty()) {
|
||||
pluginLogger.log(L.INFO_COLOR, "§e" + locale.getString(PluginLang.ENABLE_NOTIFY_EMPTY_IP));
|
||||
|
|
|
@ -18,16 +18,17 @@ package com.djrapitops.plan.system.info.request;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.export.HtmlExport;
|
||||
import com.djrapitops.plan.system.export.JSONExport;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ExportSettings;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -43,6 +44,7 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final HtmlExport htmlExport;
|
||||
private final JSONExport jsonExport;
|
||||
|
||||
private final UUID networkUUID;
|
||||
|
||||
|
@ -53,10 +55,12 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
PlanConfig config,
|
||||
Processing processing,
|
||||
HtmlExport htmlExport,
|
||||
JSONExport jsonExport,
|
||||
UUID networkUUID
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.jsonExport = jsonExport;
|
||||
this.networkUUID = networkUUID;
|
||||
this.htmlExport = htmlExport;
|
||||
}
|
||||
|
@ -66,10 +70,12 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
PlanConfig config,
|
||||
Processing processing,
|
||||
HtmlExport htmlExport,
|
||||
JSONExport jsonExport,
|
||||
UUID networkUUID
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.jsonExport = jsonExport;
|
||||
this.networkUUID = networkUUID;
|
||||
this.htmlExport = htmlExport;
|
||||
|
||||
|
@ -98,9 +104,12 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
|||
ResponseCache.clearResponse(PageId.SERVER.of(networkUUID));
|
||||
}
|
||||
|
||||
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
|
||||
if (config.get(ExportSettings.SERVER_PAGE)) {
|
||||
processing.submitNonCritical(() -> htmlExport.exportServer(serverUUID));
|
||||
}
|
||||
if (config.get(ExportSettings.SERVER_JSON)) {
|
||||
processing.submitNonCritical(() -> jsonExport.exportServerJSON(serverUUID));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,17 +18,18 @@ package com.djrapitops.plan.system.info.request;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.export.HtmlExport;
|
||||
import com.djrapitops.plan.system.export.JSONExport;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ExportSettings;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
|
||||
|
@ -47,6 +48,7 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
|
|||
private final Processing processing;
|
||||
private final ServerInfo serverInfo;
|
||||
private final HtmlExport htmlExport;
|
||||
private final JSONExport jsonExport;
|
||||
|
||||
private UUID player;
|
||||
private String html;
|
||||
|
@ -55,12 +57,14 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
|
|||
PlanConfig config,
|
||||
Processing processing,
|
||||
ServerInfo serverInfo,
|
||||
HtmlExport htmlExport
|
||||
HtmlExport htmlExport,
|
||||
JSONExport jsonExport
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.serverInfo = serverInfo;
|
||||
this.htmlExport = htmlExport;
|
||||
this.jsonExport = jsonExport;
|
||||
}
|
||||
|
||||
CacheInspectPageRequest(
|
||||
|
@ -68,12 +72,14 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
|
|||
PlanConfig config,
|
||||
Processing processing,
|
||||
ServerInfo serverInfo,
|
||||
HtmlExport htmlExport
|
||||
HtmlExport htmlExport,
|
||||
JSONExport jsonExport
|
||||
) {
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.serverInfo = serverInfo;
|
||||
this.htmlExport = htmlExport;
|
||||
this.jsonExport = jsonExport;
|
||||
|
||||
Verify.nullCheck(player, html);
|
||||
variables.put("player", player.toString());
|
||||
|
@ -101,9 +107,12 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
|
|||
|
||||
private void cache(UUID uuid, String html) {
|
||||
ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(uuid, html));
|
||||
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
|
||||
if (config.get(ExportSettings.PLAYER_PAGES)) {
|
||||
processing.submitNonCritical(() -> htmlExport.exportPlayer(uuid));
|
||||
}
|
||||
if (config.get(ExportSettings.PLAYER_JSON)) {
|
||||
processing.submitNonCritical(() -> jsonExport.exportPlayerJSON(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
package com.djrapitops.plan.system.info.request;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.export.HtmlExport;
|
||||
import com.djrapitops.plan.system.export.JSONExport;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||
import com.djrapitops.plan.utilities.html.pages.PageFactory;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
|
@ -50,6 +51,7 @@ public class InfoRequestFactory {
|
|||
private final Lazy<ResponseFactory> responseFactory;
|
||||
private final Lazy<PageFactory> pageFactory;
|
||||
private final Lazy<HtmlExport> htmlExport;
|
||||
private final Lazy<JSONExport> jsonExport;
|
||||
private final Lazy<PluginLogger> logger;
|
||||
private final Lazy<RunnableFactory> runnableFactory;
|
||||
|
||||
|
@ -64,6 +66,7 @@ public class InfoRequestFactory {
|
|||
Lazy<ResponseFactory> responseFactory,
|
||||
Lazy<PageFactory> pageFactory,
|
||||
Lazy<HtmlExport> htmlExport,
|
||||
Lazy<JSONExport> jsonExport,
|
||||
Lazy<PluginLogger> logger,
|
||||
Lazy<RunnableFactory> runnableFactory
|
||||
) {
|
||||
|
@ -76,16 +79,27 @@ public class InfoRequestFactory {
|
|||
this.responseFactory = responseFactory;
|
||||
this.pageFactory = pageFactory;
|
||||
this.htmlExport = htmlExport;
|
||||
this.jsonExport = jsonExport;
|
||||
this.logger = logger;
|
||||
this.runnableFactory = runnableFactory;
|
||||
}
|
||||
|
||||
public CacheRequest cacheAnalysisPageRequest(UUID serverUUID, String html) {
|
||||
return new CacheAnalysisPageRequest(serverUUID, html, config.get(), processing.get(), htmlExport.get(), serverInfo.get().getServerUUID());
|
||||
return new CacheAnalysisPageRequest(
|
||||
serverUUID, html,
|
||||
config.get(), processing.get(),
|
||||
htmlExport.get(), jsonExport.get(),
|
||||
serverInfo.get().getServerUUID()
|
||||
);
|
||||
}
|
||||
|
||||
public CacheRequest cacheInspectPageRequest(UUID uuid, String html) {
|
||||
return new CacheInspectPageRequest(uuid, html, config.get(), processing.get(), serverInfo.get(), htmlExport.get());
|
||||
return new CacheInspectPageRequest(
|
||||
uuid, html,
|
||||
config.get(), processing.get(),
|
||||
serverInfo.get(),
|
||||
htmlExport.get(), jsonExport.get()
|
||||
);
|
||||
}
|
||||
|
||||
public CacheRequest cacheInspectPluginsTabRequest(UUID uuid, String nav, String html) {
|
||||
|
@ -135,6 +149,7 @@ public class InfoRequestFactory {
|
|||
factory.config.get(),
|
||||
factory.processing.get(),
|
||||
factory.htmlExport.get(),
|
||||
factory.jsonExport.get(),
|
||||
factory.serverInfo.get().getServerUUID()
|
||||
);
|
||||
}
|
||||
|
@ -144,7 +159,8 @@ public class InfoRequestFactory {
|
|||
factory.config.get(),
|
||||
factory.processing.get(),
|
||||
factory.serverInfo.get(),
|
||||
factory.htmlExport.get()
|
||||
factory.htmlExport.get(),
|
||||
factory.jsonExport.get()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@ import com.djrapitops.plan.PlanPlugin;
|
|||
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.InternalErrorException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
|
||||
|
@ -59,12 +60,12 @@ public class SaveDBSettingsRequest extends InfoRequestWithVariables implements S
|
|||
this.logger = logger;
|
||||
this.runnableFactory = runnableFactory;
|
||||
|
||||
variables.put("DB_TYPE", "mysql"); // Settings.DB_TYPE
|
||||
variables.put("DB_HOST", config.getString(Settings.DB_HOST));
|
||||
variables.put("DB_USER", config.getString(Settings.DB_USER));
|
||||
variables.put("DB_PASS", config.getString(Settings.DB_PASS));
|
||||
variables.put("DB_DATABASE", config.getString(Settings.DB_DATABASE));
|
||||
variables.put("DB_PORT", config.getString(Settings.DB_PORT));
|
||||
variables.put("DB_TYPE", "mysql"); // DatabaseSettings.TYPE
|
||||
variables.put("DB_HOST", config.getString(DatabaseSettings.MYSQL_HOST));
|
||||
variables.put("DB_USER", config.getString(DatabaseSettings.MYSQL_USER));
|
||||
variables.put("DB_PASS", config.getString(DatabaseSettings.MYSQL_PASS));
|
||||
variables.put("DB_DATABASE", config.getString(DatabaseSettings.MYSQL_DATABASE));
|
||||
variables.put("DB_PORT", config.getString(DatabaseSettings.MYSQL_PORT));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,7 +81,7 @@ public class SaveDBSettingsRequest extends InfoRequestWithVariables implements S
|
|||
if (Check.isVelocityAvailable()) {
|
||||
return new BadRequestResponse("Not supposed to be called on a Velocity server");
|
||||
}
|
||||
if (config.isFalse(Settings.BUNGEE_COPY_CONFIG) || config.isTrue(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE)) {
|
||||
if (config.isFalse(PluginSettings.BUNGEE_COPY_CONFIG)) {
|
||||
return new BadRequestResponse("Bungee config settings overridden on this server.");
|
||||
}
|
||||
|
||||
|
@ -116,15 +117,15 @@ public class SaveDBSettingsRequest extends InfoRequestWithVariables implements S
|
|||
Verify.nullCheck(portS, () -> new BadRequestException("DB_PORT not specified in the request."));
|
||||
|
||||
try {
|
||||
config.set(Settings.DB_PORT, Integer.valueOf(portS));
|
||||
config.set(DatabaseSettings.MYSQL_PORT, portS);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new BadRequestException("DB_PORT was not a number.");
|
||||
}
|
||||
config.set(Settings.DB_TYPE, type);
|
||||
config.set(Settings.DB_HOST, host);
|
||||
config.set(Settings.DB_USER, user);
|
||||
config.set(Settings.DB_PASS, pass);
|
||||
config.set(Settings.DB_DATABASE, database);
|
||||
config.set(DatabaseSettings.TYPE, type);
|
||||
config.set(DatabaseSettings.MYSQL_HOST, host);
|
||||
config.set(DatabaseSettings.MYSQL_USER, user);
|
||||
config.set(DatabaseSettings.MYSQL_PASS, pass);
|
||||
config.set(DatabaseSettings.MYSQL_DATABASE, database);
|
||||
try {
|
||||
config.save();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -19,8 +19,10 @@ package com.djrapitops.plan.system.info.request;
|
|||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.BadRequestResponse;
|
||||
|
@ -64,9 +66,9 @@ public class SendDBSettingsRequest extends InfoRequestWithVariables implements S
|
|||
|
||||
Verify.nullCheck(webServerAddress, () -> new IllegalArgumentException("webServerAddress can not be null."));
|
||||
variables.put("address", webServerAddress);
|
||||
variables.put("WebServerPort", config.getString(Settings.WEBSERVER_PORT));
|
||||
variables.put("ServerName", config.getString(Settings.SERVER_NAME).replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
variables.put("ThemeBase", config.getString(Settings.THEME_BASE));
|
||||
variables.put("WebServerPort", config.get(WebserverSettings.PORT).toString());
|
||||
variables.put("ServerName", config.get(PluginSettings.SERVER_NAME).replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
variables.put("ThemeBase", config.get(DisplaySettings.THEME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
|||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import dagger.Lazy;
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class ServerServerInfo extends ServerInfo {
|
|||
if (!serverID.isPresent()) {
|
||||
return registerServer(serverUUID);
|
||||
}
|
||||
String name = config.getString(Settings.SERVER_NAME).replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
String name = config.getString(PluginSettings.SERVER_NAME).replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
String webAddress = webServer.get().getAccessAddress();
|
||||
if ("plan".equalsIgnoreCase(name)) {
|
||||
name = "Server " + serverID.get();
|
||||
|
@ -109,7 +109,7 @@ public class ServerServerInfo extends ServerInfo {
|
|||
|
||||
private Server registerServer(UUID serverUUID) throws IOException {
|
||||
String webAddress = webServer.get().getAccessAddress();
|
||||
String name = config.getString(Settings.SERVER_NAME).replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
String name = config.getString(PluginSettings.SERVER_NAME).replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
int maxPlayers = serverProperties.getMaxPlayers();
|
||||
|
||||
Server server = new Server(-1, serverUUID, name, webAddress, maxPlayers);
|
||||
|
|
|
@ -20,8 +20,8 @@ import com.djrapitops.plan.PlanPlugin;
|
|||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.locale.lang.*;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.webserver.auth.FailReason;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -95,7 +95,7 @@ public class LocaleSystem implements SubSystem {
|
|||
public void enable() {
|
||||
File localeFile = files.getLocaleFile();
|
||||
|
||||
if (config.isTrue(Settings.WRITE_NEW_LOCALE)) {
|
||||
if (config.isTrue(PluginSettings.WRITE_NEW_LOCALE)) {
|
||||
writeNewDefaultLocale(localeFile);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class LocaleSystem implements SubSystem {
|
|||
|
||||
private void resetWriteConfigSetting() {
|
||||
try {
|
||||
config.set(Settings.WRITE_NEW_LOCALE, false);
|
||||
config.set(PluginSettings.WRITE_NEW_LOCALE, false);
|
||||
config.save();
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
logger.error("Failed set WriteNewLocaleFileOnEnable back to false");
|
||||
|
@ -130,12 +130,12 @@ public class LocaleSystem implements SubSystem {
|
|||
|
||||
private Optional<Locale> loadSettingLocale() {
|
||||
try {
|
||||
String setting = config.getString(Settings.LOCALE);
|
||||
String setting = config.getString(PluginSettings.LOCALE);
|
||||
if (!setting.equalsIgnoreCase("default")) {
|
||||
return Optional.of(Locale.forLangCodeString(plugin, setting));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to read locale from jar: " + config.getString(Settings.LOCALE) + ", " + e.toString());
|
||||
logger.warn("Failed to read locale from jar: " + config.getString(PluginSettings.LOCALE) + ", " + e.toString());
|
||||
logger.warn("Using Default Locale as a fallback (EN)");
|
||||
}
|
||||
return Optional.empty();
|
||||
|
|
|
@ -18,6 +18,10 @@ package com.djrapitops.plan.system.settings;
|
|||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import dagger.Lazy;
|
||||
|
@ -37,6 +41,7 @@ import java.util.UUID;
|
|||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
@Deprecated
|
||||
public class ServerSpecificSettings {
|
||||
|
||||
private final Lazy<PlanPlugin> plugin;
|
||||
|
@ -115,40 +120,35 @@ public class ServerSpecificSettings {
|
|||
planConfig.save();
|
||||
}
|
||||
|
||||
private String getPath(UUID serverUUID, Settings setting) {
|
||||
private String getPath(UUID serverUUID, Setting setting) {
|
||||
String path = "Servers." + serverUUID;
|
||||
switch (setting) {
|
||||
case WEBSERVER_PORT:
|
||||
path += ".WebServerPort";
|
||||
break;
|
||||
case SERVER_NAME:
|
||||
path += ".ServerName";
|
||||
break;
|
||||
case THEME_BASE:
|
||||
path += ".ThemeBase";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
if (setting.equals(WebserverSettings.PORT)) {
|
||||
path += ".WebServerPort";
|
||||
} else if (setting.equals(PluginSettings.SERVER_NAME)) {
|
||||
path += ".ServerName";
|
||||
} else if (setting.equals(DisplaySettings.THEME)) {
|
||||
path += ".ThemeBase";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public boolean getBoolean(UUID serverUUID, Settings setting) {
|
||||
public boolean getBoolean(UUID serverUUID, Setting setting) {
|
||||
String path = getPath(serverUUID, setting);
|
||||
return config.get().getBoolean(path);
|
||||
}
|
||||
|
||||
public String getString(UUID serverUUID, Settings setting) {
|
||||
public String getString(UUID serverUUID, Setting setting) {
|
||||
String path = getPath(serverUUID, setting);
|
||||
return config.get().getString(path);
|
||||
}
|
||||
|
||||
public Integer getInt(UUID serverUUID, Settings setting) {
|
||||
public Integer getInt(UUID serverUUID, Setting setting) {
|
||||
String path = getPath(serverUUID, setting);
|
||||
return config.get().getInt(path);
|
||||
}
|
||||
|
||||
public void set(UUID serverUUID, Settings setting, Object value) throws IOException {
|
||||
public void set(UUID serverUUID, Setting setting, Object value) throws IOException {
|
||||
String path = getPath(serverUUID, setting);
|
||||
PlanConfig planConfig = config.get();
|
||||
planConfig.set(path, value);
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.settings;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.Setting;
|
||||
|
||||
/**
|
||||
* This enum contains all of the config settings used by the plugin for easier
|
||||
* access.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 2.3.2
|
||||
*/
|
||||
public enum Settings implements Setting {
|
||||
// Boolean
|
||||
BUNGEE_COPY_CONFIG("Plugin.Bungee-Override.CopyBungeeConfig"),
|
||||
BUNGEE_OVERRIDE_STANDALONE_MODE("Plugin.Bungee-Override.StandaloneMode"),
|
||||
ANALYSIS_EXPORT("Analysis.Export.Enabled"),
|
||||
ANALYSIS_LOG("Analysis.LogProgress"),
|
||||
SHOW_ALTERNATIVE_IP("Commands.AlternativeIP.Enabled"),
|
||||
LOG_UNKNOWN_COMMANDS("Data.Commands.LogUnknownCommands"),
|
||||
COMBINE_COMMAND_ALIASES("Data.Commands.CombineCommandAliases"),
|
||||
WRITE_NEW_LOCALE("Plugin.WriteNewLocaleFileOnEnable"),
|
||||
DEV_MODE("Plugin.Dev"),
|
||||
USE_SERVER_TIME("Customization.UseServerTime"),
|
||||
DISPLAY_SESSIONS_AS_TABLE("Customization.Display.SessionsAsTable"),
|
||||
APPEND_WORLD_PERC("Customization.Display.LargestWorldPercInSessionTitle"),
|
||||
ORDER_WORLD_PIE_BY_PERC("Customization.Display.OrderWorldPieByPercentage"),
|
||||
PLAYERTABLE_FOOTER("Customization.Display.PlayerTableFooter"),
|
||||
WEBSERVER_DISABLED("WebServer.DisableWebServer"),
|
||||
FORMAT_DATE_RECENT_DAYS("Customization.Formatting.Dates.RecentDays"),
|
||||
DISPLAY_PLAYER_IPS("Customization.Display.PlayerIPs"),
|
||||
DISPLAY_GAPS_IN_GRAPH_DATA("Customization.Display.GapsInGraphData"),
|
||||
DATA_GEOLOCATIONS("Data.Geolocations"),
|
||||
NOTIFY_ABOUT_DEV_RELEASES("Plugin.Notify-About-DEV-Releases"),
|
||||
CHECK_FOR_UPDATES("Plugin.Check-for-updates"),
|
||||
|
||||
// Integer
|
||||
WEBSERVER_PORT("WebServer.Port"),
|
||||
DB_PORT("Database.MySQL.Port"),
|
||||
ANALYSIS_AUTO_REFRESH("Analysis.AutoRefreshPeriod"),
|
||||
ACTIVE_PLAY_THRESHOLD("Analysis.Active.PlaytimeThreshold"),
|
||||
ACTIVE_LOGIN_THRESHOLD("Analysis.Active.LoginThreshold"),
|
||||
MAX_SESSIONS("Customization.Display.MaxSessions"),
|
||||
MAX_PLAYERS("Customization.Display.MaxPlayers"),
|
||||
MAX_PLAYERS_PLAYERS_PAGE("Customization.Display.MaxPlayersPlayersPage"),
|
||||
AFK_THRESHOLD_MINUTES("Data.AFKThresholdMinutes"),
|
||||
KEEP_LOGS_DAYS("Plugin.KeepLogsForXDays"),
|
||||
KEEP_INACTIVE_PLAYERS_DAYS("Data.KeepInactivePlayerDataForDays"),
|
||||
PING_SERVER_ENABLE_DELAY("Data.Ping.ServerEnableDelaySeconds"),
|
||||
PING_PLAYER_LOGIN_DELAY("Data.Ping.PlayerLoginDelaySeconds"),
|
||||
|
||||
// String
|
||||
DEBUG("Plugin.Debug"),
|
||||
ALTERNATIVE_IP("Commands.AlternativeIP.Link"),
|
||||
DB_TYPE("Database.Type"),
|
||||
DB_HOST("Database.MySQL.Host"),
|
||||
DB_USER("Database.MySQL.User"),
|
||||
DB_PASS("Database.MySQL.Password"),
|
||||
DB_DATABASE("Database.MySQL.Database"),
|
||||
DB_LAUNCH_OPTIONS("Database.MySQL.LaunchOptions"),
|
||||
LOCALE("Plugin.Locale"),
|
||||
WEBSERVER_IP("WebServer.InternalIP"),
|
||||
ANALYSIS_EXPORT_PATH("Analysis.Export.DestinationFolder"),
|
||||
WEBSERVER_CERTIFICATE_PATH("WebServer.Security.SSL-Certificate.KeyStorePath"),
|
||||
WEBSERVER_CERTIFICATE_KEYPASS("WebServer.Security.SSL-Certificate.KeyPass"),
|
||||
WEBSERVER_CERTIFICATE_STOREPASS("WebServer.Security.SSL-Certificate.StorePass"),
|
||||
WEBSERVER_CERTIFICATE_ALIAS("WebServer.Security.SSL-Certificate.Alias"),
|
||||
EXTERNAL_WEBSERVER_LINK("WebServer.ExternalWebServerAddress"),
|
||||
PLUGIN_BUYCRAFT_SECRET("Plugins.BuyCraft.Secret"),
|
||||
|
||||
SERVER_NAME("Server.ServerName"),
|
||||
|
||||
FORMAT_DATE_FULL("Customization.Formatting.Dates.Full"),
|
||||
FORMAT_DATE_NO_SECONDS("Customization.Formatting.Dates.NoSeconds"),
|
||||
FORMAT_DATE_CLOCK("Customization.Formatting.Dates.JustClock"),
|
||||
FORMAT_DATE_RECENT_DAYS_PATTERN("Customization.Formatting.Dates.RecentDays.DatePattern"),
|
||||
FORMAT_YEAR("Customization.Formatting.TimeAmount.Year"),
|
||||
FORMAT_YEARS("Customization.Formatting.TimeAmount.Years"),
|
||||
FORMAT_MONTH("Customization.Formatting.TimeAmount.Month"),
|
||||
FORMAT_MONTHS("Customization.Formatting.TimeAmount.Months"),
|
||||
FORMAT_DAY("Customization.Formatting.TimeAmount.Day"),
|
||||
FORMAT_DAYS("Customization.Formatting.TimeAmount.Days"),
|
||||
FORMAT_HOURS("Customization.Formatting.TimeAmount.Hours"),
|
||||
FORMAT_MINUTES("Customization.Formatting.TimeAmount.Minutes"),
|
||||
FORMAT_SECONDS("Customization.Formatting.TimeAmount.Seconds"),
|
||||
FORMAT_ZERO_SECONDS("Customization.Formatting.TimeAmount.Zero"),
|
||||
FORMAT_DECIMALS("Customization.Formatting.DecimalPoints"),
|
||||
|
||||
COLOR_MAIN("Commands.Colors.Main"),
|
||||
COLOR_SEC("Commands.Colors.Secondary"),
|
||||
COLOR_TER("Commands.Colors.Highlight"),
|
||||
|
||||
THEME_BASE("Theme.Base"),
|
||||
THEME_GRAPH_TPS_THRESHOLD_HIGH("Theme.Graphs.TPS.High-Threshold"),
|
||||
THEME_GRAPH_TPS_THRESHOLD_MED("Theme.Graphs.TPS.Medium-Threshold"),
|
||||
THEME_GRAPH_DISK_THRESHOLD_HIGH("Theme.Graphs.Disk.High-Threshold"),
|
||||
THEME_GRAPH_DISK_THRESHOLD_MED("Theme.Graphs.Disk.Medium-Threshold"),
|
||||
|
||||
// StringList
|
||||
HIDE_FACTIONS("Plugins.Factions.HideFactions"),
|
||||
HIDE_TOWNS("Plugins.Towny.HideTowns"),
|
||||
// Config section
|
||||
WORLD_ALIASES("Customization.WorldAliases"),
|
||||
|
||||
// Bungee
|
||||
BUNGEE_IP("Server.IP"),
|
||||
BUNGEE_NETWORK_NAME("Network.Name");
|
||||
|
||||
private final String configPath;
|
||||
|
||||
Settings(String path) {
|
||||
this.configPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return What getPath returns
|
||||
* @deprecated Old access method used to return string value in config. Use {@link com.djrapitops.plan.system.settings.config.PlanConfig#getString(Setting)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public String toString() {
|
||||
return getPath();
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import com.djrapitops.plan.data.time.GMTimes;
|
|||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
@ -66,7 +67,7 @@ public class WorldAliasSettings {
|
|||
}
|
||||
|
||||
private ConfigNode getAliasSection() {
|
||||
return config.get().getConfigNode(Settings.WORLD_ALIASES);
|
||||
return config.get().get(DisplaySettings.WORLD_ALIASES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.settings.changes;
|
||||
|
||||
import com.djrapitops.plugin.config.Config;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Represents a change made to the config structure.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface ConfigChange {
|
||||
|
||||
boolean hasBeenApplied(Config config);
|
||||
|
||||
void apply(Config config);
|
||||
|
||||
String getAppliedMessage();
|
||||
|
||||
class Moved extends Removed {
|
||||
|
||||
private final String newPath;
|
||||
|
||||
public Moved(String oldPath, String newPath) {
|
||||
super(oldPath);
|
||||
this.newPath = newPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Config config) {
|
||||
ConfigNode newNode = config.getConfigNode(newPath);
|
||||
ConfigNode oldNode = config.getConfigNode(oldPath);
|
||||
newNode.copyDefaults(oldNode);
|
||||
newNode.set(oldNode.getValue());
|
||||
super.apply(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppliedMessage() {
|
||||
return "Moved " + oldPath + " to " + newPath;
|
||||
}
|
||||
}
|
||||
|
||||
class Copied extends Removed {
|
||||
|
||||
private final String newPath;
|
||||
|
||||
public Copied(String oldPath, String newPath) {
|
||||
super(oldPath);
|
||||
this.newPath = newPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Config config) {
|
||||
ConfigNode newNode = config.getConfigNode(newPath);
|
||||
ConfigNode oldNode = config.getConfigNode(oldPath);
|
||||
newNode.copyDefaults(oldNode);
|
||||
newNode.set(oldNode.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppliedMessage() {
|
||||
return "Copied value of " + oldPath + " to " + newPath;
|
||||
}
|
||||
}
|
||||
|
||||
class Removed implements ConfigChange {
|
||||
final String oldPath;
|
||||
|
||||
public Removed(String oldPath) {
|
||||
this.oldPath = oldPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBeenApplied(Config config) {
|
||||
return !config.contains(oldPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void apply(Config config) {
|
||||
ConfigNode node = config.getConfigNode(oldPath);
|
||||
ConfigNode parent = node.getParent();
|
||||
String key = node.getKey(false);
|
||||
parent.getChildren().remove(key);
|
||||
|
||||
// Remove the child from child order, since it is otherwise trying to save null.
|
||||
try {
|
||||
Field field = ConfigNode.class.getDeclaredField("childOrder");
|
||||
field.setAccessible(true);
|
||||
Collection<String> childOrder = (Collection<String>) field.get(parent);
|
||||
childOrder.remove(key);
|
||||
field.set(parent, childOrder);
|
||||
field.setAccessible(false);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
throw new IllegalStateException("Error removing config node", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppliedMessage() {
|
||||
return "Removed " + oldPath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.settings.changes;
|
||||
|
||||
import com.djrapitops.plugin.config.Config;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Class in charge of updating config.yml.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ConfigUpdater {
|
||||
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public ConfigUpdater(
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public void applyConfigUpdate(Config config) throws IOException {
|
||||
ConfigChange[] configEnhancementsPatch = new ConfigChange[]{
|
||||
new ConfigChange.Moved("Plugin.Locale", "Plugin.Logging.Locale"),
|
||||
new ConfigChange.Moved("Plugin.WriteNewLocaleFileOnEnable", "Plugin.Logging.Create_new_locale_file_on_next_enable"),
|
||||
new ConfigChange.Moved("Plugin.Debug", "Plugin.Logging.Debug"),
|
||||
new ConfigChange.Moved("Plugin.Dev", "Plugin.Logging.Dev"),
|
||||
new ConfigChange.Moved("Plugin.KeepLogsForXDays", "Plugin.Logging.Delete_logs_after_days"),
|
||||
|
||||
new ConfigChange.Moved("Plugin.Check-for-updates", "Plugin.Update_notifications.Check_for_updates"),
|
||||
new ConfigChange.Moved("Plugin.Notify-About-DEV-Releases", "Plugin.Update_notifications.Notify_about_DEV_releases"),
|
||||
new ConfigChange.Removed("Plugin.Allow-Update-Command"),
|
||||
|
||||
new ConfigChange.Moved("Plugin.Bungee-Override.CopyBungeeConfig", "Plugin.Configuration.Allow_bungeecord_to_manage_settings"),
|
||||
new ConfigChange.Removed("Plugin.Bungee-Override"),
|
||||
new ConfigChange.Moved("Database.MySQL.LaunchOptions", "Database.MySQL.Launch_options"),
|
||||
|
||||
new ConfigChange.Moved("WebServer", "Webserver"),
|
||||
new ConfigChange.Moved("Commands.AlternativeIP.Enabled", "Webserver.Alternative_IP"),
|
||||
new ConfigChange.Moved("Commands.AlternativeIP.Link", "Webserver.Alternative_IP.Address"),
|
||||
new ConfigChange.Moved("Webserver.InternalIP", "Webserver.Internal_IP"),
|
||||
new ConfigChange.Moved("Webserver.Security.SSL-Certificate", "Webserver.Security.SSL_certificate"),
|
||||
new ConfigChange.Moved("Webserver.Security.SSL_certificate.KeyStorePath", "Webserver.Security.SSL_certificate.KeyStore_path"),
|
||||
new ConfigChange.Moved("Webserver.Security.SSL_certificate.KeyPass", "Webserver.Security.SSL_certificate.Key_pass"),
|
||||
new ConfigChange.Moved("Webserver.Security.SSL_certificate.StorePass", "Webserver.Security.SSL_certificate.Store_pass"),
|
||||
new ConfigChange.Moved("Webserver.DisableWebServer", "Webserver.Disable_Webserver"),
|
||||
new ConfigChange.Moved("Webserver.ExternalWebServerAddress", "Webserver.External_Webserver_address"),
|
||||
|
||||
new ConfigChange.Moved("Data.Geolocations", "Data_gathering.Geolocations"),
|
||||
new ConfigChange.Moved("Data.Commands.LogUnknownCommands", "Data_gathering.Commands.Log_unknown"),
|
||||
new ConfigChange.Moved("Data.Commands.CombineCommandAliases", "Data_gathering.Commands.Log_aliases_as_main_command"),
|
||||
|
||||
new ConfigChange.Moved("Customization.UseServerTime", "Time.Use_server_timezone"),
|
||||
new ConfigChange.Moved("Data.Ping.ServerEnableDelaySeconds", "Time.Delays.Ping_server_enable_delay"),
|
||||
new ConfigChange.Moved("Data.Ping.PlayerLoginDelaySeconds", "Time.Delays.Ping_player_join_delay"),
|
||||
new ConfigChange.Moved("Data.AFKThresholdMinutes", "Time.Thresholds.AFK_threshold"),
|
||||
new ConfigChange.Moved("Analysis.Active.LoginThreshold", "Time.Thresholds.Activity_index.Login_threshold"),
|
||||
new ConfigChange.Moved("Analysis.Active.PlaytimeThreshold", "Time.Thresholds.Activity_index.Playtime_threshold"),
|
||||
new ConfigChange.Moved("Data.KeepInactivePlayerDataForDays", "Time.Thresholds.Remove_inactive_player_data_after"),
|
||||
new ConfigChange.Removed("Analysis.LogProgress"),
|
||||
new ConfigChange.Moved("Analysis.AutoRefreshPeriod", "Time.Periodic_tasks.Analysis_refresh_every"),
|
||||
|
||||
new ConfigChange.Moved("Theme.Base", "Display_options.Theme"),
|
||||
new ConfigChange.Moved("Customization.Display.SessionsAsTable", "Display_options.Sessions.Replace_accordion_with_table"),
|
||||
new ConfigChange.Moved("Customization.Display.LargestWorldPercInSessionTitle", "Display_options.Sessions.Show_most_played_world_in_title"),
|
||||
new ConfigChange.Moved("Customization.Display.MaxSessions", "Display_options.Sessions.Show_on_page"),
|
||||
new ConfigChange.Moved("Customization.Display.OrderWorldPieByPercentage", "Display_options.Sessions.Order_world_pies_by_percentage"),
|
||||
new ConfigChange.Moved("Customization.Display.MaxPlayers", "Display_options.Players_table.Show_on_server_page"),
|
||||
new ConfigChange.Moved("Customization.Display.MaxPlayersPlayersPage", "Display_options.Players_table.Show_on_players_page"),
|
||||
new ConfigChange.Removed("Customization.Display.PlayerTableFooter"),
|
||||
new ConfigChange.Moved("Customization.Display.PlayerIPs", "Display_options.Show_player_IPs"),
|
||||
new ConfigChange.Moved("Customization.Display.GapsInGraphData", "Display_options.Graphs.Show_gaps_in_data"),
|
||||
new ConfigChange.Moved("Theme.Graphs.TPS.High-Threshold", "Display_options.Graphs.TPS.High_threshold"),
|
||||
new ConfigChange.Moved("Theme.Graphs.TPS.Medium-Threshold", "Display_options.Graphs.TPS.Medium_threshold"),
|
||||
new ConfigChange.Moved("Theme.Graphs.Disk.High-Threshold", "Display_options.Graphs.Disk_space.High_threshold"),
|
||||
new ConfigChange.Moved("Theme.Graphs.Disk.Medium-Threshold", "Display_options.Graphs.Disk_space.Medium_threshold"),
|
||||
new ConfigChange.Moved("Commands.Colors", "Display_options.Command_colors"),
|
||||
|
||||
new ConfigChange.Moved("Customization.Formatting", "Formatting"),
|
||||
new ConfigChange.Moved("Formatting.DecimalPoints", "Formatting.Decimal_points"),
|
||||
new ConfigChange.Moved("Formatting.TimeAmount", "Formatting.Time_amount"),
|
||||
new ConfigChange.Moved("Formatting.Dates.RecentDays", "Formatting.Dates.Show_recent_day_names"),
|
||||
|
||||
new ConfigChange.Moved("Customization.WorldAliases", "World_aliases"),
|
||||
new ConfigChange.Moved("Analysis.Export.DestinationFolder", "Export.HTML_Export_path"),
|
||||
new ConfigChange.Copied("Analysis.Export.Enabled", "Export.Parts.JavaScript_and_CSS"),
|
||||
new ConfigChange.Copied("Analysis.Export.Enabled", "Export.Parts.Player_pages"),
|
||||
new ConfigChange.Copied("Analysis.Export.Enabled", "Export.Parts.Players_page"),
|
||||
new ConfigChange.Moved("Analysis.Export.Enabled", "Export.Parts.Server_page"),
|
||||
|
||||
new ConfigChange.Removed("Commands"),
|
||||
new ConfigChange.Removed("Analysis"),
|
||||
new ConfigChange.Removed("Data"),
|
||||
new ConfigChange.Removed("Customization"),
|
||||
new ConfigChange.Removed("Theme")
|
||||
};
|
||||
for (ConfigChange change : configEnhancementsPatch) {
|
||||
try {
|
||||
if (!change.hasBeenApplied(config)) {
|
||||
change.apply(config);
|
||||
logger.info("Config: " + change.getAppliedMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), new IllegalStateException("Failed to apply config update: '" + change.getAppliedMessage() + "'", e));
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
package com.djrapitops.plan.system.settings.config;
|
||||
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.changes.ConfigUpdater;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
@ -35,19 +36,24 @@ import java.io.IOException;
|
|||
@Singleton
|
||||
public class BukkitConfigSystem extends ConfigSystem {
|
||||
|
||||
private final ConfigUpdater configUpdater;
|
||||
|
||||
@Inject
|
||||
public BukkitConfigSystem(
|
||||
PlanFiles files,
|
||||
PlanConfig config,
|
||||
ConfigUpdater configUpdater,
|
||||
Theme theme,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(files, config, theme, logger, errorHandler);
|
||||
this.configUpdater = configUpdater;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyDefaults() throws IOException {
|
||||
configUpdater.applyConfigUpdate(config);
|
||||
config.copyDefaults(files.readFromResource("config.yml"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.djrapitops.plan.system.settings.config;
|
|||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -82,7 +82,7 @@ public abstract class ConfigSystem implements SubSystem {
|
|||
}
|
||||
|
||||
private void setDebugMode() {
|
||||
String debugMode = config.getString(Settings.DEBUG);
|
||||
String debugMode = config.getString(PluginSettings.DEBUG);
|
||||
|
||||
List<DebugLogger> loggers = new ArrayList<>();
|
||||
if (Verify.equalsOne(debugMode, "true", "both", "console")) {
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
package com.djrapitops.plan.system.settings.config;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.PluginsConfigSection;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.WorldAliasSettings;
|
||||
import com.djrapitops.plan.system.settings.network.NetworkSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plugin.config.Config;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public class PlanConfig extends Config {
|
|||
}
|
||||
|
||||
public int getTimeZoneOffsetHours() {
|
||||
if (isTrue(Settings.USE_SERVER_TIME)) {
|
||||
if (isTrue(TimeSettings.USE_SERVER_TIME)) {
|
||||
int offset = TimeZone.getDefault().getOffset(System.currentTimeMillis());
|
||||
int hourMs = (int) TimeUnit.HOURS.toMillis(1L);
|
||||
return -offset / hourMs;
|
||||
|
@ -66,11 +67,20 @@ public class PlanConfig extends Config {
|
|||
return 0; // UTC
|
||||
}
|
||||
|
||||
public boolean isTrue(Setting setting) {
|
||||
return getBoolean(setting.getPath());
|
||||
public <T> T get(Setting<T> setting) {
|
||||
T value = setting.getValueFrom(this);
|
||||
boolean valid = setting.isValid(value);
|
||||
if (!valid) {
|
||||
throw new IllegalStateException("Config value for " + setting.getPath() + " has a bad value: '" + value + "'");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isFalse(Setting setting) {
|
||||
public boolean isTrue(Setting<Boolean> setting) {
|
||||
return get(setting);
|
||||
}
|
||||
|
||||
public boolean isFalse(Setting<Boolean> setting) {
|
||||
return !isTrue(setting);
|
||||
}
|
||||
|
||||
|
@ -79,8 +89,8 @@ public class PlanConfig extends Config {
|
|||
*
|
||||
* @return String value of the config setting.
|
||||
*/
|
||||
public String getString(Setting setting) {
|
||||
return getString(setting.getPath());
|
||||
public String getString(Setting<String> setting) {
|
||||
return get(setting);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,19 +98,19 @@ public class PlanConfig extends Config {
|
|||
*
|
||||
* @return Integer value of the config setting
|
||||
*/
|
||||
public int getNumber(Setting setting) {
|
||||
return getInt(setting.getPath());
|
||||
public int getNumber(Setting<Integer> setting) {
|
||||
return get(setting);
|
||||
}
|
||||
|
||||
public List<String> getStringList(Setting setting) {
|
||||
return getStringList(setting.getPath());
|
||||
public List<String> getStringList(Setting<List<String>> setting) {
|
||||
return get(setting);
|
||||
}
|
||||
|
||||
public ConfigNode getConfigNode(Setting setting) {
|
||||
return getConfigNode(setting.getPath());
|
||||
public ConfigNode getConfigNode(Setting<ConfigNode> setting) {
|
||||
return get(setting);
|
||||
}
|
||||
|
||||
public void set(Setting setting, Object value) {
|
||||
public <T> void set(Setting<T> setting, T value) {
|
||||
set(setting.getPath(), value);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package com.djrapitops.plan.system.settings.config;
|
||||
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.changes.ConfigUpdater;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
@ -35,19 +36,24 @@ import java.io.IOException;
|
|||
@Singleton
|
||||
public class ProxyConfigSystem extends ConfigSystem {
|
||||
|
||||
private final ConfigUpdater configUpdater;
|
||||
|
||||
@Inject
|
||||
public ProxyConfigSystem(
|
||||
PlanFiles files,
|
||||
PlanConfig config,
|
||||
ConfigUpdater configUpdater,
|
||||
Theme theme,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(files, config, theme, logger, errorHandler);
|
||||
this.configUpdater = configUpdater;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyDefaults() throws IOException {
|
||||
configUpdater.applyConfigUpdate(config);
|
||||
config.copyDefaults(files.readFromResource("bungeeconfig.yml"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.settings.config;
|
||||
|
||||
/**
|
||||
* Represents a path to a config value.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface Setting {
|
||||
|
||||
/**
|
||||
* Used to get the String path of a the config setting.
|
||||
* <p>
|
||||
* Path separates nested levels with a dot.
|
||||
*
|
||||
* @return Example: Settings.WebServer.Enabled
|
||||
*/
|
||||
String getPath();
|
||||
|
||||
}
|
|
@ -18,7 +18,9 @@ package com.djrapitops.plan.system.settings.config;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.changes.ConfigUpdater;
|
||||
import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
@ -41,11 +43,12 @@ public class SpongeConfigSystem extends BukkitConfigSystem {
|
|||
public SpongeConfigSystem(
|
||||
PlanFiles files,
|
||||
PlanConfig config,
|
||||
ConfigUpdater configUpdater,
|
||||
Theme theme,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(files, config, theme, logger, errorHandler);
|
||||
super(files, config, configUpdater, theme, logger, errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,11 +62,11 @@ public class SpongeConfigSystem extends BukkitConfigSystem {
|
|||
super.copyDefaults();
|
||||
if (firstInstall) {
|
||||
logger.info("§eWebServer and Geolocations disabled by default on Sponge servers. You can enable them in the config:");
|
||||
logger.info("§e " + Settings.WEBSERVER_DISABLED.getPath());
|
||||
logger.info("§e " + Settings.DATA_GEOLOCATIONS.getPath());
|
||||
logger.info("§e " + WebserverSettings.DISABLED.getPath());
|
||||
logger.info("§e " + DataGatheringSettings.GEOLOCATIONS.getPath());
|
||||
|
||||
config.set(Settings.WEBSERVER_DISABLED, true);
|
||||
config.set(Settings.DATA_GEOLOCATIONS, false);
|
||||
config.set(WebserverSettings.DISABLED, true);
|
||||
config.set(DataGatheringSettings.GEOLOCATIONS, false);
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ import com.djrapitops.plan.system.database.DBSystem;
|
|||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.ServerSpecificSettings;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.*;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
|
@ -38,14 +39,13 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.system.settings.Settings.*;
|
||||
|
||||
/**
|
||||
* Class for managing Config setting transfer from Bungee to Bukkit servers.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
@Deprecated
|
||||
public class NetworkSettings {
|
||||
|
||||
private static final String SPLIT = ";;SETTING;;";
|
||||
|
@ -84,7 +84,7 @@ public class NetworkSettings {
|
|||
}
|
||||
|
||||
PlanConfig planConfig = config.get();
|
||||
if (planConfig.isTrue(BUNGEE_OVERRIDE_STANDALONE_MODE) || planConfig.isFalse(BUNGEE_COPY_CONFIG)) {
|
||||
if (planConfig.isFalse(PluginSettings.BUNGEE_COPY_CONFIG)) {
|
||||
// Don't load settings if they are overridden.
|
||||
return;
|
||||
}
|
||||
|
@ -175,65 +175,64 @@ public class NetworkSettings {
|
|||
private Map<String, Object> getConfigValues() {
|
||||
logger.debug("NetworkSettings: Loading Config Values..");
|
||||
Map<String, Object> configValues = new HashMap<>();
|
||||
addConfigValue(configValues, DB_TYPE, "mysql");
|
||||
Settings[] sameStrings = new Settings[]{
|
||||
DB_HOST,
|
||||
DB_USER,
|
||||
DB_PASS,
|
||||
DB_DATABASE,
|
||||
DB_LAUNCH_OPTIONS,
|
||||
FORMAT_DECIMALS,
|
||||
FORMAT_SECONDS,
|
||||
FORMAT_DAY,
|
||||
FORMAT_DAYS,
|
||||
FORMAT_HOURS,
|
||||
FORMAT_MINUTES,
|
||||
FORMAT_MONTHS,
|
||||
FORMAT_MONTH,
|
||||
FORMAT_YEAR,
|
||||
FORMAT_YEARS,
|
||||
FORMAT_ZERO_SECONDS,
|
||||
USE_SERVER_TIME,
|
||||
DISPLAY_SESSIONS_AS_TABLE,
|
||||
APPEND_WORLD_PERC,
|
||||
ORDER_WORLD_PIE_BY_PERC,
|
||||
MAX_SESSIONS,
|
||||
MAX_PLAYERS,
|
||||
MAX_PLAYERS_PLAYERS_PAGE,
|
||||
PLAYERTABLE_FOOTER,
|
||||
FORMAT_DATE_RECENT_DAYS,
|
||||
FORMAT_DATE_RECENT_DAYS_PATTERN,
|
||||
FORMAT_DATE_CLOCK,
|
||||
FORMAT_DATE_NO_SECONDS,
|
||||
FORMAT_DATE_FULL,
|
||||
DISPLAY_PLAYER_IPS,
|
||||
ACTIVE_LOGIN_THRESHOLD,
|
||||
ACTIVE_PLAY_THRESHOLD,
|
||||
DISPLAY_GAPS_IN_GRAPH_DATA,
|
||||
AFK_THRESHOLD_MINUTES,
|
||||
DATA_GEOLOCATIONS,
|
||||
KEEP_LOGS_DAYS,
|
||||
KEEP_INACTIVE_PLAYERS_DAYS,
|
||||
PING_SERVER_ENABLE_DELAY,
|
||||
PING_PLAYER_LOGIN_DELAY
|
||||
addConfigValue(configValues, DatabaseSettings.TYPE, "mysql");
|
||||
Setting[] sameStrings = new Setting[]{
|
||||
DatabaseSettings.MYSQL_HOST,
|
||||
DatabaseSettings.MYSQL_USER,
|
||||
DatabaseSettings.MYSQL_PASS,
|
||||
DatabaseSettings.MYSQL_DATABASE,
|
||||
DatabaseSettings.MYSQL_LAUNCH_OPTIONS,
|
||||
FormatSettings.DECIMALS,
|
||||
FormatSettings.SECONDS,
|
||||
FormatSettings.DAY,
|
||||
FormatSettings.DAYS,
|
||||
FormatSettings.HOURS,
|
||||
FormatSettings.MINUTES,
|
||||
FormatSettings.MONTHS,
|
||||
FormatSettings.MONTH,
|
||||
FormatSettings.YEAR,
|
||||
FormatSettings.YEARS,
|
||||
FormatSettings.ZERO_SECONDS,
|
||||
TimeSettings.USE_SERVER_TIME,
|
||||
DisplaySettings.REPLACE_SESSION_ACCORDION_WITH_TABLE,
|
||||
DisplaySettings.SESSION_MOST_PLAYED_WORLD_IN_TITLE,
|
||||
DisplaySettings.ORDER_WORLD_PIE_BY_PERC,
|
||||
DisplaySettings.SESSIONS_PER_PAGE,
|
||||
DisplaySettings.PLAYERS_PER_SERVER_PAGE,
|
||||
DisplaySettings.PLAYERS_PER_PLAYERS_PAGE,
|
||||
FormatSettings.DATE_RECENT_DAYS,
|
||||
FormatSettings.DATE_RECENT_DAYS_PATTERN,
|
||||
FormatSettings.DATE_CLOCK,
|
||||
FormatSettings.DATE_NO_SECONDS,
|
||||
FormatSettings.DATE_FULL,
|
||||
DisplaySettings.PLAYER_IPS,
|
||||
TimeSettings.ACTIVE_LOGIN_THRESHOLD,
|
||||
TimeSettings.ACTIVE_PLAY_THRESHOLD,
|
||||
DisplaySettings.GAPS_IN_GRAPH_DATA,
|
||||
TimeSettings.AFK_THRESHOLD,
|
||||
DataGatheringSettings.GEOLOCATIONS,
|
||||
PluginSettings.KEEP_LOGS_DAYS,
|
||||
TimeSettings.KEEP_INACTIVE_PLAYERS,
|
||||
TimeSettings.PING_SERVER_ENABLE_DELAY,
|
||||
TimeSettings.PING_PLAYER_LOGIN_DELAY
|
||||
};
|
||||
logger.debug("NetworkSettings: Adding Config Values..");
|
||||
PlanConfig planConfig = config.get();
|
||||
for (Settings setting : sameStrings) {
|
||||
addConfigValue(configValues, setting, planConfig.getString(setting));
|
||||
for (Setting setting : sameStrings) {
|
||||
addConfigValue(configValues, setting, planConfig.get(setting));
|
||||
}
|
||||
addConfigValue(configValues, DB_PORT, planConfig.getNumber(DB_PORT));
|
||||
addConfigValue(configValues, DatabaseSettings.MYSQL_PORT, planConfig.get(DatabaseSettings.MYSQL_PORT));
|
||||
addServerSpecificValues(configValues);
|
||||
return configValues;
|
||||
}
|
||||
|
||||
private void addConfigValue(Map<String, Object> configValues, Settings setting, Object value) {
|
||||
private void addConfigValue(Map<String, Object> configValues, Setting setting, Object value) {
|
||||
if (value != null) {
|
||||
configValues.put(setting.getPath(), value);
|
||||
}
|
||||
}
|
||||
|
||||
private void addConfigValue(Map<String, Object> configValues, UUID serverUUID, Settings setting, Object value) {
|
||||
private void addConfigValue(Map<String, Object> configValues, UUID serverUUID, Setting setting, Object value) {
|
||||
if (value != null) {
|
||||
configValues.put(serverUUID + ":" + setting.getPath(), value);
|
||||
}
|
||||
|
@ -243,18 +242,18 @@ public class NetworkSettings {
|
|||
logger.debug("NetworkSettings: Adding Server-specific Config Values..");
|
||||
|
||||
for (UUID serverUUID : dbSystem.get().getDatabase().fetch().getServerUUIDs()) {
|
||||
String theme = serverSpecificSettings.getString(serverUUID, THEME_BASE);
|
||||
Integer port = serverSpecificSettings.getInt(serverUUID, WEBSERVER_PORT);
|
||||
String name = serverSpecificSettings.getString(serverUUID, SERVER_NAME);
|
||||
String theme = serverSpecificSettings.getString(serverUUID, DisplaySettings.THEME);
|
||||
Integer port = serverSpecificSettings.getInt(serverUUID, WebserverSettings.PORT);
|
||||
String name = serverSpecificSettings.getString(serverUUID, PluginSettings.SERVER_NAME);
|
||||
|
||||
if (!Verify.isEmpty(theme)) {
|
||||
addConfigValue(configValues, serverUUID, THEME_BASE, theme);
|
||||
addConfigValue(configValues, serverUUID, DisplaySettings.THEME, theme);
|
||||
}
|
||||
if (port != null && port != 0) {
|
||||
addConfigValue(configValues, serverUUID, WEBSERVER_PORT, port);
|
||||
addConfigValue(configValues, serverUUID, WebserverSettings.PORT, port);
|
||||
}
|
||||
if (!Verify.isEmpty(name)) {
|
||||
addConfigValue(configValues, serverUUID, SERVER_NAME, name);
|
||||
addConfigValue(configValues, serverUUID, PluginSettings.SERVER_NAME, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Data_gathering" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DataGatheringSettings {
|
||||
|
||||
public static final Setting<Boolean> GEOLOCATIONS = new BooleanSetting("Data_gathering.Geolocations");
|
||||
public static final Setting<Boolean> LOG_UNKNOWN_COMMANDS = new BooleanSetting("Data_gathering.Commands.Log_unknown");
|
||||
public static final Setting<Boolean> COMBINE_COMMAND_ALIASES = new BooleanSetting("Data_gathering.Commands.Log_aliases_as_main_command");
|
||||
|
||||
private DataGatheringSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.database.databases.DBType;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Database" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DatabaseSettings {
|
||||
|
||||
public static final Setting<String> TYPE = new StringSetting("Database.Type", DBType::exists);
|
||||
public static final Setting<String> MYSQL_HOST = new StringSetting("Database.MySQL.Host");
|
||||
public static final Setting<String> MYSQL_PORT = new StringSetting("Database.MySQL.Port", NumberUtils::isParsable);
|
||||
public static final Setting<String> MYSQL_USER = new StringSetting("Database.MySQL.User");
|
||||
public static final Setting<String> MYSQL_PASS = new StringSetting("Database.MySQL.Password");
|
||||
public static final Setting<String> MYSQL_DATABASE = new StringSetting("Database.MySQL.Database");
|
||||
public static final Setting<String> MYSQL_LAUNCH_OPTIONS = new StringSetting("Database.MySQL.Launch_options");
|
||||
|
||||
private DatabaseSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.IntegerSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Display_options" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DisplaySettings {
|
||||
|
||||
public static final Setting<String> THEME = new StringSetting("Display_options.Theme");
|
||||
public static final Setting<Boolean> REPLACE_SESSION_ACCORDION_WITH_TABLE = new BooleanSetting("Display_options.Sessions.Replace_accordion_with_table");
|
||||
public static final Setting<Integer> SESSIONS_PER_PAGE = new IntegerSetting("Display_options.Sessions.Show_on_page");
|
||||
public static final Setting<Boolean> SESSION_MOST_PLAYED_WORLD_IN_TITLE = new BooleanSetting("Display_options.Sessions.Show_most_played_world_in_title");
|
||||
public static final Setting<Boolean> ORDER_WORLD_PIE_BY_PERC = new BooleanSetting("Display_options.Sessions.Order_world_pies_by_percentage");
|
||||
public static final Setting<Integer> PLAYERS_PER_SERVER_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_server_page");
|
||||
public static final Setting<Integer> PLAYERS_PER_PLAYERS_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_players_page");
|
||||
public static final Setting<Boolean> PLAYER_IPS = new BooleanSetting("Display_options.Show_player_IPs");
|
||||
public static final Setting<Boolean> GAPS_IN_GRAPH_DATA = new BooleanSetting("Display_options.Graphs.Show_gaps_in_data");
|
||||
public static final Setting<Integer> GRAPH_TPS_THRESHOLD_HIGH = new IntegerSetting("Display_options.Graphs.TPS.High_threshold");
|
||||
public static final Setting<Integer> GRAPH_TPS_THRESHOLD_MED = new IntegerSetting("Display_options.Graphs.TPS.Medium_threshold");
|
||||
public static final Setting<Integer> GRAPH_DISK_THRESHOLD_HIGH = new IntegerSetting("Display_options.Graphs.Disk_space.High_threshold");
|
||||
public static final Setting<Integer> GRAPH_DISK_THRESHOLD_MED = new IntegerSetting("Display_options.Graphs.Disk_space.Medium_threshold");
|
||||
public static final Setting<String> CMD_COLOR_MAIN = new StringSetting("Display_options.Command_colors.Main");
|
||||
public static final Setting<String> CMD_COLOR_SECONDARY = new StringSetting("Display_options.Command_colors.Secondary");
|
||||
public static final Setting<String> CMD_COLOR_TERTIARY = new StringSetting("Display_options.Command_colors.Highlight");
|
||||
public static final Setting<ConfigNode> WORLD_ALIASES = new Setting<ConfigNode>("World_aliases", ConfigNode.class) {
|
||||
@Override
|
||||
public ConfigNode getValueFrom(ConfigNode node) {
|
||||
return node.getConfigNode(path);
|
||||
}
|
||||
};
|
||||
|
||||
private DisplaySettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Export" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExportSettings {
|
||||
|
||||
public static final Setting<String> HTML_EXPORT_PATH = new StringSetting("Export.HTML_Export_path");
|
||||
public static final Setting<String> JSON_EXPORT_PATH = new StringSetting("Export.JSON_Export_path");
|
||||
public static final Setting<Boolean> JS_AND_CSS = new BooleanSetting("Export.Parts.JavaScript_and_CSS");
|
||||
public static final Setting<Boolean> PLAYER_PAGES = new BooleanSetting("Export.Parts.Player_pages");
|
||||
public static final Setting<Boolean> PLAYER_JSON = new BooleanSetting("Export.Parts.Player_JSON");
|
||||
public static final Setting<Boolean> PLAYERS_PAGE = new BooleanSetting("Export.Parts.Players_page");
|
||||
public static final Setting<Boolean> SERVER_PAGE = new BooleanSetting("Export.Parts.Server_page");
|
||||
public static final Setting<Boolean> SERVER_JSON = new BooleanSetting("Export.Parts.Server_JSON");
|
||||
|
||||
private ExportSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Formatting" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class FormatSettings {
|
||||
|
||||
public static final Setting<String> DECIMALS = new StringSetting("Formatting.Decimal_points");
|
||||
public static final Setting<Boolean> DATE_RECENT_DAYS = new BooleanSetting("Formatting.Dates.Show_recent_day_names");
|
||||
public static final Setting<String> DATE_RECENT_DAYS_PATTERN = new StringSetting("Formatting.Dates.Show_recent_day_names.DatePattern");
|
||||
public static final Setting<String> DATE_FULL = new StringSetting("Formatting.Dates.Full");
|
||||
public static final Setting<String> DATE_NO_SECONDS = new StringSetting("Formatting.Dates.NoSeconds");
|
||||
public static final Setting<String> DATE_CLOCK = new StringSetting("Formatting.Dates.JustClock");
|
||||
public static final Setting<String> YEAR = new StringSetting("Formatting.Time_amount.Year");
|
||||
public static final Setting<String> YEARS = new StringSetting("Formatting.Time_amount.Years");
|
||||
public static final Setting<String> MONTH = new StringSetting("Formatting.Time_amount.Month");
|
||||
public static final Setting<String> MONTHS = new StringSetting("Formatting.Time_amount.Months");
|
||||
public static final Setting<String> DAY = new StringSetting("Formatting.Time_amount.Day");
|
||||
public static final Setting<String> DAYS = new StringSetting("Formatting.Time_amount.Days");
|
||||
public static final Setting<String> HOURS = new StringSetting("Formatting.Time_amount.Hours");
|
||||
public static final Setting<String> MINUTES = new StringSetting("Formatting.Time_amount.Minutes");
|
||||
public static final Setting<String> SECONDS = new StringSetting("Formatting.Time_amount.Seconds");
|
||||
public static final Setting<String> ZERO_SECONDS = new StringSetting("Formatting.Time_amount.Zero");
|
||||
|
||||
private FormatSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringListSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Plugins" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PluginDataSettings {
|
||||
|
||||
public static final Setting<String> PLUGIN_BUYCRAFT_SECRET = new StringSetting("Plugins.BuyCraft.Secret");
|
||||
public static final Setting<List<String>> HIDE_FACTIONS = new StringListSetting("Plugins.Factions.HideFactions");
|
||||
public static final Setting<List<String>> HIDE_TOWNS = new StringListSetting("Plugins.Towny.HideTowns");
|
||||
|
||||
private PluginDataSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.IntegerSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Server" or "Plugin" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PluginSettings {
|
||||
|
||||
public static final Setting<String> SERVER_NAME = new StringSetting("Server.ServerName");
|
||||
public static final Setting<String> LOCALE = new StringSetting("Plugin.Logging.Locale");
|
||||
public static final Setting<Boolean> WRITE_NEW_LOCALE = new BooleanSetting("Plugin.Logging.Create_new_locale_file_on_next_enable");
|
||||
public static final Setting<String> DEBUG = new StringSetting("Plugin.Logging.Debug");
|
||||
public static final Setting<Boolean> DEV_MODE = new BooleanSetting("Plugin.Logging.Dev");
|
||||
public static final Setting<Integer> KEEP_LOGS_DAYS = new IntegerSetting("Plugin.Logging.Delete_logs_after_days", Setting::timeValidator);
|
||||
public static final Setting<Boolean> CHECK_FOR_UPDATES = new BooleanSetting("Plugin.Update_notifications.Check_for_updates");
|
||||
public static final Setting<Boolean> NOTIFY_ABOUT_DEV_RELEASES = new BooleanSetting("Plugin.Update_notifications.Notify_about_DEV_releases");
|
||||
public static final Setting<Boolean> BUNGEE_COPY_CONFIG = new BooleanSetting("Plugin.Configuration.Allow_bungeecord_to_manage_settings");
|
||||
|
||||
private PluginSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Database" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ProxySettings {
|
||||
|
||||
public static final Setting<String> IP = new StringSetting("Server.IP");
|
||||
public static final Setting<String> NETWORK_NAME = new StringSetting("Network.Name");
|
||||
|
||||
private ProxySettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.IntegerSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.TimeSetting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Time" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class TimeSettings {
|
||||
|
||||
public static final Setting<Boolean> USE_SERVER_TIME = new BooleanSetting("Time.Use_server_timezone");
|
||||
public static final Setting<Long> PING_SERVER_ENABLE_DELAY = new TimeSetting("Time.Delays.Ping_server_enable_delay");
|
||||
public static final Setting<Long> PING_PLAYER_LOGIN_DELAY = new TimeSetting("Time.Delays.Ping_player_join_delay");
|
||||
public static final Setting<Long> AFK_THRESHOLD = new TimeSetting("Time.Thresholds.AFK_threshold");
|
||||
public static final Setting<Integer> ACTIVE_LOGIN_THRESHOLD = new IntegerSetting("Time.Thresholds.Activity_index.Login_threshold", Setting::timeValidator);
|
||||
public static final Setting<Long> ACTIVE_PLAY_THRESHOLD = new TimeSetting("Time.Thresholds.Activity_index.Playtime_threshold");
|
||||
public static final Setting<Long> KEEP_INACTIVE_PLAYERS = new TimeSetting("Time.Thresholds.Remove_inactive_player_data_after");
|
||||
public static final Setting<Long> ANALYSIS_REFRESH_PERIOD = new TimeSetting("Time.Periodic_tasks.Analysis_refresh_every");
|
||||
public static final Setting<Long> CLEAN_CACHE_PERIOD = new TimeSetting("Time.Periodic_tasks.Clean_caches_every");
|
||||
public static final Setting<Long> CLEAN_DATABASE_PERIOD = new TimeSetting("Time.Periodic_tasks.Clean_Database_every");
|
||||
|
||||
private TimeSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.djrapitops.plan.system.settings.paths;
|
||||
|
||||
import com.djrapitops.plan.system.settings.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.IntegerSetting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.Setting;
|
||||
import com.djrapitops.plan.system.settings.paths.key.StringSetting;
|
||||
|
||||
/**
|
||||
* {@link Setting} values that are in "Webserver" section.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebserverSettings {
|
||||
|
||||
public static final Setting<Integer> PORT = new IntegerSetting("Webserver.Port");
|
||||
public static final Setting<Boolean> SHOW_ALTERNATIVE_IP = new BooleanSetting("Webserver.Alternative_IP");
|
||||
public static final Setting<String> ALTERNATIVE_IP = new StringSetting("Webserver.Alternative_IP.Address");
|
||||
public static final Setting<String> INTERNAL_IP = new StringSetting("Webserver.Internal_IP");
|
||||
public static final Setting<String> CERTIFICATE_PATH = new StringSetting("Webserver.Security.SSL_certificate.KeyStore_path");
|
||||
public static final Setting<String> CERTIFICATE_KEYPASS = new StringSetting("Webserver.Security.SSL_certificate.Key_pass");
|
||||
public static final Setting<String> CERTIFICATE_STOREPASS = new StringSetting("Webserver.Security.SSL_certificate.Store_pass");
|
||||
public static final Setting<String> CERTIFICATE_ALIAS = new StringSetting("Webserver.Security.SSL_certificate.Alias");
|
||||
public static final Setting<Boolean> DISABLED = new BooleanSetting("Webserver.Disable_Webserver");
|
||||
public static final Setting<String> EXTERNAL_LINK = new StringSetting("Webserver.External_Webserver_address");
|
||||
|
||||
private WebserverSettings() {
|
||||
/* static variable class */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.djrapitops.plan.system.settings.paths.key;
|
||||
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Setting implementation for String value settings.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class BooleanSetting extends Setting<Boolean> {
|
||||
|
||||
public BooleanSetting(String path) {
|
||||
super(path, Boolean.class);
|
||||
}
|
||||
|
||||
public BooleanSetting(String path, Predicate<Boolean> validator) {
|
||||
super(path, Boolean.class, validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValueFrom(ConfigNode node) {
|
||||
return node.contains(path) && node.getBoolean(path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.djrapitops.plan.system.settings.paths.key;
|
||||
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Setting implementation for String value settings.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class IntegerSetting extends Setting<Integer> {
|
||||
|
||||
public IntegerSetting(String path) {
|
||||
super(path, Integer.class);
|
||||
}
|
||||
|
||||
public IntegerSetting(String path, Predicate<Integer> validator) {
|
||||
super(path, Integer.class, validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValueFrom(ConfigNode node) {
|
||||
return node.contains(path) ? node.getInt(path) : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.settings.paths.key;
|
||||
|
||||
import com.djrapitops.plan.data.store.Type;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Represents a path to a config value.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class Setting<T> {
|
||||
|
||||
protected final String path;
|
||||
private final Type<T> type;
|
||||
private final Predicate<T> validator;
|
||||
|
||||
public Setting(String path, Class<T> type) {
|
||||
this(path, type, Setting::nullValidator);
|
||||
}
|
||||
|
||||
public Setting(String path, Class<T> type, Predicate<T> validator) {
|
||||
this(path, Type.ofClass(type), ((Predicate<T>) Setting::nullValidator).and(validator));
|
||||
}
|
||||
|
||||
public Setting(String path, Type<T> type) {
|
||||
this(path, type, Setting::nullValidator);
|
||||
}
|
||||
|
||||
public Setting(String path, Type<T> type, Predicate<T> validator) {
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
public static <T> boolean nullValidator(T value) {
|
||||
return value != null;
|
||||
}
|
||||
|
||||
public static boolean timeValidator(Number number) {
|
||||
return number.doubleValue() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the String path of a the config setting.
|
||||
* <p>
|
||||
* Path separates nested levels with a dot.
|
||||
*
|
||||
* @return Example: Settings.WebServer.Enabled
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public abstract T getValueFrom(ConfigNode node);
|
||||
|
||||
public boolean isValid(T value) {
|
||||
return validator.test(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.djrapitops.plan.system.settings.paths.key;
|
||||
|
||||
import com.djrapitops.plan.data.store.Type;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Setting implementation for String value settings.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class StringListSetting extends Setting<List<String>> {
|
||||
|
||||
public StringListSetting(String path) {
|
||||
super(path, new Type<List<String>>() {});
|
||||
}
|
||||
|
||||
public StringListSetting(String path, Predicate<List<String>> validator) {
|
||||
super(path, new Type<List<String>>() {}, validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getValueFrom(ConfigNode node) {
|
||||
return node.contains(path) ? node.getStringList(path) : Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.djrapitops.plan.system.settings.paths.key;
|
||||
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Setting implementation for String value settings.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class StringSetting extends Setting<String> {
|
||||
|
||||
public StringSetting(String path) {
|
||||
super(path, String.class);
|
||||
}
|
||||
|
||||
public StringSetting(String path, Predicate<String> validator) {
|
||||
super(path, String.class, validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueFrom(ConfigNode node) {
|
||||
return node.contains(path) ? node.getString(path) : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.djrapitops.plan.system.settings.paths.key;
|
||||
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Setting implementation for settings that use {@link java.util.concurrent.TimeUnit} under the value.
|
||||
* <p>
|
||||
* All values return milliseconds.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class TimeSetting extends Setting<Long> {
|
||||
|
||||
public TimeSetting(String path) {
|
||||
super(path, Long.class, Setting::timeValidator);
|
||||
}
|
||||
|
||||
public TimeSetting(String path, Predicate<Long> validator) {
|
||||
super(path, Long.class, validator.and(Setting::timeValidator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getValueFrom(ConfigNode node) {
|
||||
long duration = node.getLong(path);
|
||||
String unitName = node.getString(path + ".Unit");
|
||||
try {
|
||||
TimeUnit unit = TimeUnit.valueOf(unitName.toUpperCase());
|
||||
return unit.toMillis(duration);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package com.djrapitops.plan.system.settings.theme;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -35,9 +35,9 @@ public class PlanColorScheme extends ColorScheme {
|
|||
|
||||
public static PlanColorScheme create(PlanConfig config, PluginLogger logger) {
|
||||
try {
|
||||
String main = "§" + config.getString(Settings.COLOR_MAIN).charAt(1);
|
||||
String secondary = "§" + config.getString(Settings.COLOR_SEC).charAt(1);
|
||||
String tertiary = "§" + config.getString(Settings.COLOR_TER).charAt(1);
|
||||
String main = "§" + config.get(DisplaySettings.CMD_COLOR_MAIN).charAt(1);
|
||||
String secondary = "§" + config.get(DisplaySettings.CMD_COLOR_SECONDARY).charAt(1);
|
||||
String tertiary = "§" + config.get(DisplaySettings.CMD_COLOR_TERTIARY).charAt(1);
|
||||
|
||||
return new PlanColorScheme(main, secondary, tertiary);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -18,6 +18,8 @@ package com.djrapitops.plan.system.settings.theme;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
|
@ -37,11 +39,15 @@ import static com.djrapitops.plan.system.settings.theme.ThemeVal.*;
|
|||
@Singleton
|
||||
public class Theme implements SubSystem {
|
||||
|
||||
private final ThemeConfig config;
|
||||
private final PlanFiles files;
|
||||
private final PlanConfig config;
|
||||
private final PluginLogger logger;
|
||||
|
||||
private ThemeConfig themeConfig;
|
||||
|
||||
@Inject
|
||||
public Theme(ThemeConfig config, PluginLogger logger) {
|
||||
public Theme(PlanFiles files, PlanConfig config, PluginLogger logger) {
|
||||
this.files = files;
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
@ -57,7 +63,8 @@ public class Theme implements SubSystem {
|
|||
@Override
|
||||
public void enable() throws EnableException {
|
||||
try {
|
||||
config.save();
|
||||
themeConfig = new ThemeConfig(files, config, logger);
|
||||
themeConfig.save();
|
||||
} catch (IOException e) {
|
||||
throw new EnableException("theme.yml could not be saved.", e);
|
||||
}
|
||||
|
@ -71,7 +78,7 @@ public class Theme implements SubSystem {
|
|||
private String getColor(ThemeVal variable) {
|
||||
String path = variable.getThemePath();
|
||||
try {
|
||||
String value = config.getString(path);
|
||||
String value = themeConfig.getString(path);
|
||||
|
||||
if (value.contains(".")) {
|
||||
return "url(\"" + value + "\")";
|
||||
|
@ -115,6 +122,6 @@ public class Theme implements SubSystem {
|
|||
}
|
||||
|
||||
private String getThemeValue(ThemeVal color) {
|
||||
return config.getString(color.getThemePath());
|
||||
return themeConfig.getString(color.getThemePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,12 @@
|
|||
package com.djrapitops.plan.system.settings.theme;
|
||||
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plugin.config.Config;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -35,10 +33,8 @@ import java.util.List;
|
|||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ThemeConfig extends Config {
|
||||
|
||||
@Inject
|
||||
public ThemeConfig(PlanFiles files, PlanConfig config, PluginLogger logger) {
|
||||
this(getConfigFile(files), getDefaults(files, config, logger));
|
||||
}
|
||||
|
@ -56,7 +52,7 @@ public class ThemeConfig extends Config {
|
|||
}
|
||||
|
||||
private static List<String> getDefaults(PlanFiles files, PlanConfig config, PluginLogger logger) {
|
||||
String fileName = config.getString(Settings.THEME_BASE);
|
||||
String fileName = config.get(DisplaySettings.THEME);
|
||||
String fileLocation = getFileLocation(fileName);
|
||||
|
||||
try {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package com.djrapitops.plan.system.tasks;
|
||||
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
|
||||
|
@ -38,9 +38,8 @@ import java.util.concurrent.TimeUnit;
|
|||
@Singleton
|
||||
public class LogsFolderCleanTask extends AbsRunnable {
|
||||
|
||||
private final int keepLogDayThreshold;
|
||||
|
||||
private final File folder;
|
||||
private final PlanConfig config;
|
||||
private final PluginLogger logger;
|
||||
|
||||
@Inject
|
||||
|
@ -50,7 +49,7 @@ public class LogsFolderCleanTask extends AbsRunnable {
|
|||
PluginLogger logger
|
||||
) {
|
||||
this.folder = files.getLogsFolder();
|
||||
this.keepLogDayThreshold = config.getNumber(Settings.KEEP_LOGS_DAYS);
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
@ -75,7 +74,7 @@ public class LogsFolderCleanTask extends AbsRunnable {
|
|||
private void cleanFolder() {
|
||||
long now = System.currentTimeMillis();
|
||||
for (File file : Objects.requireNonNull(folder.listFiles())) {
|
||||
long forDaysMs = TimeUnit.DAYS.toMillis(keepLogDayThreshold);
|
||||
long forDaysMs = TimeUnit.DAYS.toMillis(config.get(PluginSettings.KEEP_LOGS_DAYS));
|
||||
if (now - file.lastModified() > (forDaysMs > 0 ? forDaysMs : TimeUnit.DAYS.toMillis(1L))) {
|
||||
try {
|
||||
Files.delete(file.toPath());
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package com.djrapitops.plan.system.tasks;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
|
||||
import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
@ -62,9 +62,9 @@ public abstract class ServerTaskSystem extends TaskSystem {
|
|||
|
||||
private void registerTasks() {
|
||||
// Analysis refresh settings
|
||||
int analysisRefreshMinutes = config.getNumber(Settings.ANALYSIS_AUTO_REFRESH);
|
||||
boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0;
|
||||
long analysisPeriod = TimeAmount.toTicks(analysisRefreshMinutes, TimeUnit.MINUTES);
|
||||
long analysisRefreshMs = config.get(TimeSettings.ANALYSIS_REFRESH_PERIOD);
|
||||
boolean analysisRefreshTaskIsEnabled = analysisRefreshMs > 0;
|
||||
long analysisPeriod = TimeAmount.toTicks(analysisRefreshMs, TimeUnit.MILLISECONDS);
|
||||
|
||||
registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.toTicks(1L, TimeUnit.SECONDS));
|
||||
registerTask(bootAnalysisTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||
|
|
|
@ -19,8 +19,8 @@ package com.djrapitops.plan.system.update;
|
|||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plugin.api.utility.Version;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -67,12 +67,12 @@ public class VersionCheckSystem implements SubSystem {
|
|||
|
||||
@Override
|
||||
public void enable() {
|
||||
if (config.isFalse(Settings.CHECK_FOR_UPDATES)) {
|
||||
if (config.isFalse(PluginSettings.CHECK_FOR_UPDATES)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<VersionInfo> versions = VersionInfoLoader.load();
|
||||
if (config.isFalse(Settings.NOTIFY_ABOUT_DEV_RELEASES)) {
|
||||
if (config.isFalse(PluginSettings.NOTIFY_ABOUT_DEV_RELEASES)) {
|
||||
versions = versions.stream().filter(VersionInfo::isRelease).collect(Collectors.toList());
|
||||
}
|
||||
VersionInfo newestVersion = versions.get(0);
|
||||
|
|
|
@ -19,8 +19,8 @@ package com.djrapitops.plan.system.webserver;
|
|||
import com.djrapitops.plan.system.DebugChannels;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.system.webserver.auth.BasicAuthentication;
|
||||
|
@ -89,7 +89,7 @@ public class RequestHandler implements HttpHandler {
|
|||
timings.start(requestString);
|
||||
int responseCode = -1;
|
||||
|
||||
boolean inDevMode = config.isTrue(Settings.DEV_MODE);
|
||||
boolean inDevMode = config.isTrue(PluginSettings.DEV_MODE);
|
||||
try {
|
||||
Response response = responseHandler.getResponse(request);
|
||||
responseCode = response.getCode();
|
||||
|
|
|
@ -22,8 +22,8 @@ import com.djrapitops.plan.system.file.PlanFiles;
|
|||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
|
@ -94,7 +94,7 @@ public class WebServer implements SubSystem {
|
|||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
this.port = config.getNumber(Settings.WEBSERVER_PORT);
|
||||
this.port = config.getNumber(WebserverSettings.PORT);
|
||||
|
||||
initServer();
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class WebServer implements SubSystem {
|
|||
if (Check.isBungeeAvailable() || Check.isVelocityAvailable()) {
|
||||
throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_NO_WEB_SERVER_BUNGEE));
|
||||
}
|
||||
if (config.isTrue(Settings.WEBSERVER_DISABLED)) {
|
||||
if (config.isTrue(WebserverSettings.DISABLED)) {
|
||||
logger.warn(locale.getString(PluginLang.ENABLE_NOTIFY_WEB_SERVER_DISABLED));
|
||||
} else {
|
||||
logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_PORT_BIND, port));
|
||||
|
@ -116,7 +116,7 @@ public class WebServer implements SubSystem {
|
|||
* Starts up the WebServer in a new Thread Pool.
|
||||
*/
|
||||
private void initServer() {
|
||||
if (!(Check.isBungeeAvailable() || Check.isVelocityAvailable()) && config.isTrue(Settings.WEBSERVER_DISABLED)) {
|
||||
if (!(Check.isBungeeAvailable() || Check.isVelocityAvailable()) && config.isTrue(WebserverSettings.DISABLED)) {
|
||||
// Bukkit WebServer has been disabled.
|
||||
return;
|
||||
}
|
||||
|
@ -133,10 +133,10 @@ public class WebServer implements SubSystem {
|
|||
|
||||
if (!usingHttps) {
|
||||
logger.log(L.INFO_COLOR, "§e" + locale.getString(PluginLang.WEB_SERVER_NOTIFY_HTTP_USER_AUTH));
|
||||
server = HttpServer.create(new InetSocketAddress(config.getString(Settings.WEBSERVER_IP), port), 10);
|
||||
server = HttpServer.create(new InetSocketAddress(config.getString(WebserverSettings.INTERNAL_IP), port), 10);
|
||||
} else if (server == null) {
|
||||
logger.log(L.INFO_COLOR, "§eWebServer: Proxy HTTPS Override enabled. HTTP Server in use, make sure that your Proxy webserver is routing with HTTPS and AlternativeIP.Link points to the Proxy");
|
||||
server = HttpServer.create(new InetSocketAddress(config.getString(Settings.WEBSERVER_IP), port), 10);
|
||||
server = HttpServer.create(new InetSocketAddress(config.getString(WebserverSettings.INTERNAL_IP), port), 10);
|
||||
}
|
||||
server.createContext("/", requestHandler);
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class WebServer implements SubSystem {
|
|||
}
|
||||
|
||||
private boolean startHttpsServer() {
|
||||
String keyStorePath = config.getString(Settings.WEBSERVER_CERTIFICATE_PATH);
|
||||
String keyStorePath = config.getString(WebserverSettings.CERTIFICATE_PATH);
|
||||
|
||||
if (keyStorePath.equalsIgnoreCase("proxy")) {
|
||||
return true;
|
||||
|
@ -172,9 +172,9 @@ public class WebServer implements SubSystem {
|
|||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
|
||||
char[] storepass = config.getString(Settings.WEBSERVER_CERTIFICATE_STOREPASS).toCharArray();
|
||||
char[] keypass = config.getString(Settings.WEBSERVER_CERTIFICATE_KEYPASS).toCharArray();
|
||||
String alias = config.getString(Settings.WEBSERVER_CERTIFICATE_ALIAS);
|
||||
char[] storepass = config.getString(WebserverSettings.CERTIFICATE_STOREPASS).toCharArray();
|
||||
char[] keypass = config.getString(WebserverSettings.CERTIFICATE_KEYPASS).toCharArray();
|
||||
String alias = config.getString(WebserverSettings.CERTIFICATE_ALIAS);
|
||||
|
||||
boolean startSuccessful = false;
|
||||
try (FileInputStream fIn = new FileInputStream(keyStorePath)) {
|
||||
|
@ -195,7 +195,7 @@ public class WebServer implements SubSystem {
|
|||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509");
|
||||
trustManagerFactory.init(keystore);
|
||||
|
||||
server = HttpsServer.create(new InetSocketAddress(config.getString(Settings.WEBSERVER_IP), port), 10);
|
||||
server = HttpsServer.create(new InetSocketAddress(config.getString(WebserverSettings.INTERNAL_IP), port), 10);
|
||||
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||
sslContext.init(keyManagerFactory.getKeyManagers(), null/*trustManagerFactory.getTrustManagers()*/, null);
|
||||
|
||||
|
@ -281,12 +281,12 @@ public class WebServer implements SubSystem {
|
|||
}
|
||||
|
||||
public String getAccessAddress() {
|
||||
return isEnabled() ? getProtocol() + "://" + getIP() : config.getString(Settings.EXTERNAL_WEBSERVER_LINK);
|
||||
return isEnabled() ? getProtocol() + "://" + getIP() : config.getString(WebserverSettings.EXTERNAL_LINK);
|
||||
}
|
||||
|
||||
private String getIP() {
|
||||
return config.isTrue(Settings.SHOW_ALTERNATIVE_IP)
|
||||
? config.getString(Settings.ALTERNATIVE_IP).replace("%port%", String.valueOf(port))
|
||||
return config.isTrue(WebserverSettings.SHOW_ALTERNATIVE_IP)
|
||||
? config.getString(WebserverSettings.ALTERNATIVE_IP).replace("%port%", String.valueOf(port))
|
||||
: serverProperties.getIp() + ":" + port;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,16 +73,14 @@ public class RawDataResponse extends Response {
|
|||
return values;
|
||||
}
|
||||
|
||||
private List handleList(List object) {
|
||||
List<Object> list = object;
|
||||
private List handleList(List list) {
|
||||
if (list.stream().findAny().orElse(null) instanceof DataContainer) {
|
||||
return list.stream().map((obj) -> mapToNormalMap((DataContainer) obj)).collect(Collectors.toList());
|
||||
return ((List<Object>) list.stream().map((obj) -> mapToNormalMap((DataContainer) obj)).collect(Collectors.toList()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Map handleMap(Map object) {
|
||||
Map<Object, Object> map = object;
|
||||
private Map handleMap(Map map) {
|
||||
if (map.values().stream().findAny().orElse(null) instanceof DataContainer) {
|
||||
Map<Object, Object> newMap = new HashMap<>();
|
||||
map.forEach((key, value) -> newMap.put(key, mapToNormalMap((DataContainer) value)));
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
@ -28,14 +28,15 @@ import java.text.DecimalFormat;
|
|||
*/
|
||||
public class DecimalFormatter implements Formatter<Double> {
|
||||
|
||||
private volatile DecimalFormat decimalFormat;
|
||||
private final PlanConfig config;
|
||||
|
||||
public DecimalFormatter(PlanConfig config) {
|
||||
decimalFormat = new DecimalFormat(config.getString(Settings.FORMAT_DECIMALS));
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Double value) {
|
||||
return decimalFormat.format(value);
|
||||
// DecimalFormat is initialized here because config is not fully enabled in the constructor
|
||||
return new DecimalFormat(config.getString(FormatSettings.DECIMALS)).format(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
|
||||
/**
|
||||
* Formatter for a timestamp that only includes a clock.
|
||||
|
@ -37,7 +37,7 @@ public class ClockFormatter extends DateFormatter {
|
|||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = config.getString(Settings.FORMAT_DATE_CLOCK);
|
||||
String format = config.getString(FormatSettings.DATE_CLOCK);
|
||||
|
||||
return format(date, format);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ package com.djrapitops.plan.utilities.formatting.time;
|
|||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.PluginSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -45,8 +47,8 @@ public abstract class DateFormatter implements Formatter<Long> {
|
|||
public abstract String apply(Long value);
|
||||
|
||||
protected String format(long epochMs, String format) {
|
||||
boolean useServerTime = config.isTrue(Settings.USE_SERVER_TIME);
|
||||
String locale = config.getString(Settings.LOCALE);
|
||||
boolean useServerTime = config.isTrue(TimeSettings.USE_SERVER_TIME);
|
||||
String locale = config.getString(PluginSettings.LOCALE);
|
||||
java.util.Locale usedLocale = locale.equalsIgnoreCase("default")
|
||||
? java.util.Locale.ENGLISH
|
||||
: java.util.Locale.forLanguageTag(locale);
|
||||
|
@ -57,7 +59,7 @@ public abstract class DateFormatter implements Formatter<Long> {
|
|||
}
|
||||
|
||||
protected String replaceRecentDays(long epochMs, String format) {
|
||||
return replaceRecentDays(epochMs, format, config.getString(Settings.FORMAT_DATE_RECENT_DAYS_PATTERN));
|
||||
return replaceRecentDays(epochMs, format, config.getString(FormatSettings.DATE_RECENT_DAYS_PATTERN));
|
||||
}
|
||||
|
||||
protected String replaceRecentDays(long epochMs, String format, String pattern) {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
|
||||
/**
|
||||
* Formatter for a timestamp which includes days as the smallest entry.
|
||||
|
@ -39,7 +39,7 @@ public class DayFormatter extends DateFormatter {
|
|||
private String format(Long date) {
|
||||
String format = "MMMMM d";
|
||||
|
||||
if (config.isTrue(Settings.FORMAT_DATE_RECENT_DAYS)) {
|
||||
if (config.isTrue(FormatSettings.DATE_RECENT_DAYS)) {
|
||||
format = replaceRecentDays(date, format, "MMMMM");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
|
||||
/**
|
||||
* Formatter for timestamp which includes seconds as the smallest entry.
|
||||
|
@ -37,9 +37,9 @@ public class SecondFormatter extends DateFormatter {
|
|||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = config.getString(Settings.FORMAT_DATE_FULL);
|
||||
String format = config.getString(FormatSettings.DATE_FULL);
|
||||
|
||||
if (config.isTrue(Settings.FORMAT_DATE_RECENT_DAYS)) {
|
||||
if (config.isTrue(FormatSettings.DATE_RECENT_DAYS)) {
|
||||
format = replaceRecentDays(date, format);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -66,9 +66,9 @@ public class TimeAmountFormatter implements Formatter<Long> {
|
|||
appendMonths(builder, months);
|
||||
appendDays(builder, days);
|
||||
|
||||
String hourFormat = config.getString(Settings.FORMAT_HOURS);
|
||||
String minuteFormat = config.getString(Settings.FORMAT_MINUTES);
|
||||
String secondFormat = config.getString(Settings.FORMAT_SECONDS);
|
||||
String hourFormat = config.getString(FormatSettings.HOURS);
|
||||
String minuteFormat = config.getString(FormatSettings.MINUTES);
|
||||
String secondFormat = config.getString(FormatSettings.SECONDS);
|
||||
|
||||
appendHours(builder, hours, hourFormat);
|
||||
appendMinutes(builder, minutes, hours, hourFormat, minuteFormat);
|
||||
|
@ -76,7 +76,7 @@ public class TimeAmountFormatter implements Formatter<Long> {
|
|||
|
||||
String formattedTime = StringUtils.remove(builder.toString(), ZERO_PH);
|
||||
if (formattedTime.isEmpty()) {
|
||||
return config.getString(Settings.FORMAT_ZERO_SECONDS);
|
||||
return config.getString(FormatSettings.ZERO_SECONDS);
|
||||
}
|
||||
return formattedTime;
|
||||
}
|
||||
|
@ -124,21 +124,21 @@ public class TimeAmountFormatter implements Formatter<Long> {
|
|||
}
|
||||
|
||||
private void appendDays(StringBuilder builder, long days) {
|
||||
String singular = config.getString(Settings.FORMAT_DAY);
|
||||
String plural = config.getString(Settings.FORMAT_DAYS);
|
||||
String singular = config.getString(FormatSettings.DAY);
|
||||
String plural = config.getString(FormatSettings.DAYS);
|
||||
appendValue(builder, days, singular, plural, DAYS_PH);
|
||||
}
|
||||
|
||||
private void appendMonths(StringBuilder builder, long months) {
|
||||
String singular = config.getString(Settings.FORMAT_MONTH);
|
||||
String plural = config.getString(Settings.FORMAT_MONTHS);
|
||||
String singular = config.getString(FormatSettings.MONTH);
|
||||
String plural = config.getString(FormatSettings.MONTHS);
|
||||
|
||||
appendValue(builder, months, singular, plural, MONTHS_PH);
|
||||
}
|
||||
|
||||
private void appendYears(StringBuilder builder, long years) {
|
||||
String singular = config.getString(Settings.FORMAT_YEAR);
|
||||
String plural = config.getString(Settings.FORMAT_YEARS);
|
||||
String singular = config.getString(FormatSettings.YEAR);
|
||||
String plural = config.getString(FormatSettings.YEARS);
|
||||
|
||||
appendValue(builder, years, singular, plural, YEARS_PH);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.FormatSettings;
|
||||
|
||||
/**
|
||||
* Formatter for a timestamp which includes year, but not seconds.
|
||||
|
@ -37,9 +37,9 @@ public class YearFormatter extends DateFormatter {
|
|||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = config.getString(Settings.FORMAT_DATE_NO_SECONDS);
|
||||
String format = config.getString(FormatSettings.DATE_NO_SECONDS);
|
||||
|
||||
if (config.isTrue(Settings.FORMAT_DATE_RECENT_DAYS)) {
|
||||
if (config.isTrue(FormatSettings.DATE_RECENT_DAYS)) {
|
||||
format = replaceRecentDays(date, format);
|
||||
}
|
||||
return format(date, format);
|
||||
|
|
|
@ -18,8 +18,8 @@ package com.djrapitops.plan.utilities.html.graphs.line;
|
|||
|
||||
import com.djrapitops.plan.data.container.Ping;
|
||||
import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -43,38 +43,42 @@ public class LineGraphFactory {
|
|||
}
|
||||
|
||||
public LineGraph lineGraph(List<Point> points) {
|
||||
return new LineGraph(points, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new LineGraph(points, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph chunkGraph(TPSMutator mutator) {
|
||||
return new ChunkGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new ChunkGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph cpuGraph(TPSMutator mutator) {
|
||||
return new CPUGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new CPUGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph entityGraph(TPSMutator mutator) {
|
||||
return new EntityGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new EntityGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph playersOnlineGraph(TPSMutator mutator) {
|
||||
return new PlayersOnlineGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new PlayersOnlineGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public PingGraph pingGraph(List<Ping> pingList) {
|
||||
return new PingGraph(pingList, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new PingGraph(pingList, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph ramGraph(TPSMutator mutator) {
|
||||
return new RamGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new RamGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph tpsGraph(TPSMutator mutator) {
|
||||
return new TPSGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new TPSGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
public LineGraph diskGraph(TPSMutator mutator) {
|
||||
return new DiskGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
|
||||
return new DiskGraph(mutator, shouldDisplayGapsInData());
|
||||
}
|
||||
|
||||
private boolean shouldDisplayGapsInData() {
|
||||
return config.isTrue(DisplaySettings.GAPS_IN_GRAPH_DATA);
|
||||
}
|
||||
}
|
|
@ -18,9 +18,9 @@ package com.djrapitops.plan.utilities.html.graphs.pie;
|
|||
|
||||
import com.djrapitops.plan.data.time.GMTimes;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.WorldAliasSettings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class PieGraphFactory {
|
|||
Map<String, Long> playtimePerAlias = worldAliasSettings.getPlaytimePerAlias(worldTimes);
|
||||
Map<String, GMTimes> gmTimesPerAlias = worldAliasSettings.getGMTimesPerAlias(worldTimes);
|
||||
String[] colors = theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(", ");
|
||||
boolean orderByPercentage = config.isTrue(Settings.ORDER_WORLD_PIE_BY_PERC);
|
||||
boolean orderByPercentage = config.isTrue(DisplaySettings.ORDER_WORLD_PIE_BY_PERC);
|
||||
return new WorldPie(playtimePerAlias, gmTimesPerAlias, colors, orderByPercentage);
|
||||
}
|
||||
}
|
|
@ -26,8 +26,10 @@ import com.djrapitops.plan.data.time.WorldTimes;
|
|||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
|
@ -191,7 +193,7 @@ public class InspectPage implements Page {
|
|||
if (allSessions.isEmpty()) {
|
||||
replacer.put("accordionSessions", "<div class=\"body\">" + "<p>No Sessions</p>" + "</div>");
|
||||
} else {
|
||||
if (config.isTrue(Settings.DISPLAY_SESSIONS_AS_TABLE)) {
|
||||
if (config.isTrue(DisplaySettings.REPLACE_SESSION_ACCORDION_WITH_TABLE)) {
|
||||
replacer.put("accordionSessions", tables.playerSessionTable(playerName, allSessions).parseHtml());
|
||||
} else {
|
||||
SessionAccordion sessionAccordion = accordions.playerSessionAccordion(allSessions, () -> serverNames);
|
||||
|
@ -233,7 +235,7 @@ public class InspectPage implements Page {
|
|||
pvpAndPve(replacer, sessionsMutator, weekSessionsMutator, monthSessionsMutator);
|
||||
|
||||
ActivityIndex activityIndex = player.getActivityIndex(
|
||||
now, config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD), config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD)
|
||||
now, config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD), config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD)
|
||||
);
|
||||
|
||||
replacer.put("activityIndexNumber", activityIndex.getFormattedValue(decimalFormatter));
|
||||
|
@ -247,7 +249,7 @@ public class InspectPage implements Page {
|
|||
String serverName = serverNames.get(serverUUID);
|
||||
replacer.put("networkName",
|
||||
serverName.equalsIgnoreCase("bungeecord")
|
||||
? config.getString(Settings.BUNGEE_NETWORK_NAME)
|
||||
? config.getString(ProxySettings.NETWORK_NAME)
|
||||
: serverName
|
||||
);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
|||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.utilities.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
||||
|
@ -76,7 +76,7 @@ public class PlayersPage implements Page {
|
|||
if (Check.isBukkitAvailable()) {
|
||||
placeholderReplacer.put("networkName", serverInfo.getServer().getName());
|
||||
} else {
|
||||
placeholderReplacer.put("networkName", config.getString(Settings.BUNGEE_NETWORK_NAME));
|
||||
placeholderReplacer.put("networkName", config.getString(ProxySettings.NETWORK_NAME));
|
||||
}
|
||||
|
||||
timings.start("Players page players table parsing");
|
||||
|
|
|
@ -18,8 +18,8 @@ package com.djrapitops.plan.utilities.html.structure;
|
|||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
|
@ -73,8 +73,8 @@ public class Accordions {
|
|||
List<Session> sessions,
|
||||
Supplier<Map<UUID, String>> serverNamesSupplier
|
||||
) {
|
||||
boolean appendWorldPercentage = config.isTrue(Settings.APPEND_WORLD_PERC);
|
||||
int maxSessions = config.getNumber(Settings.MAX_SESSIONS);
|
||||
boolean appendWorldPercentage = config.isTrue(DisplaySettings.SESSION_MOST_PLAYED_WORLD_IN_TITLE);
|
||||
int maxSessions = config.getNumber(DisplaySettings.SESSIONS_PER_PAGE);
|
||||
return new SessionAccordion(
|
||||
true, sessions,
|
||||
serverNamesSupplier, HashMap::new,
|
||||
|
@ -97,8 +97,8 @@ public class Accordions {
|
|||
Supplier<Map<UUID, String>> serverNamesSupplier,
|
||||
Supplier<Map<UUID, String>> playerNamesSupplier
|
||||
) {
|
||||
boolean appendWorldPercentage = config.isTrue(Settings.APPEND_WORLD_PERC);
|
||||
int maxSessions = config.getNumber(Settings.MAX_SESSIONS);
|
||||
boolean appendWorldPercentage = config.isTrue(DisplaySettings.SESSION_MOST_PLAYED_WORLD_IN_TITLE);
|
||||
int maxSessions = config.getNumber(DisplaySettings.SESSIONS_PER_PAGE);
|
||||
return new SessionAccordion(
|
||||
false, sessions,
|
||||
serverNamesSupplier, playerNamesSupplier,
|
||||
|
|
|
@ -23,8 +23,9 @@ import com.djrapitops.plan.data.plugin.PluginData;
|
|||
import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -81,7 +82,7 @@ public class HtmlTables {
|
|||
* @return a new {@link GeoInfoTable}.
|
||||
*/
|
||||
public TableContainer geoInfoTable(List<GeoInfo> geoInfo) {
|
||||
return new GeoInfoTable(geoInfo, config.isTrue(Settings.DISPLAY_PLAYER_IPS), formatters.year());
|
||||
return new GeoInfoTable(geoInfo, config.isTrue(DisplaySettings.PLAYER_IPS), formatters.year());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +127,7 @@ public class HtmlTables {
|
|||
public TableContainer playerSessionTable(String playerName, List<Session> sessions) {
|
||||
return new PlayerSessionTable(
|
||||
playerName, sessions,
|
||||
config.getNumber(Settings.MAX_SESSIONS), config.getWorldAliasSettings(), formatters.year(), formatters.timeAmount()
|
||||
config.get(DisplaySettings.SESSIONS_PER_PAGE), config.getWorldAliasSettings(), formatters.year(), formatters.timeAmount()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -140,7 +141,7 @@ public class HtmlTables {
|
|||
public TableContainer serverSessionTable(Map<UUID, String> playerNames, List<Session> sessions) {
|
||||
return new ServerSessionTable(
|
||||
playerNames, sessions,
|
||||
config.getNumber(Settings.MAX_SESSIONS), config.getWorldAliasSettings(), formatters.year(), formatters.timeAmount()
|
||||
config.get(DisplaySettings.SESSIONS_PER_PAGE), config.getWorldAliasSettings(), formatters.year(), formatters.timeAmount()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -153,9 +154,9 @@ public class HtmlTables {
|
|||
public TableContainer playerTableForServerPage(List<PlayerContainer> players) {
|
||||
return new PlayersTable(
|
||||
players,
|
||||
config.getNumber(Settings.MAX_PLAYERS),
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD),
|
||||
config.get(DisplaySettings.PLAYERS_PER_SERVER_PAGE),
|
||||
config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD),
|
||||
formatters.timeAmount(), formatters.yearLong(), formatters.decimals()
|
||||
);
|
||||
}
|
||||
|
@ -168,8 +169,10 @@ public class HtmlTables {
|
|||
*/
|
||||
public TableContainer playerTableForPlayersPage(List<PlayerContainer> players) {
|
||||
return new PlayersTable(
|
||||
players, config.getNumber(Settings.MAX_PLAYERS_PLAYERS_PAGE),
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD), config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD), formatters.timeAmount(), formatters.yearLong(), formatters.decimals()
|
||||
players, config.get(DisplaySettings.PLAYERS_PER_PLAYERS_PAGE),
|
||||
config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.get(TimeSettings.ACTIVE_LOGIN_THRESHOLD),
|
||||
formatters.timeAmount(), formatters.yearLong(), formatters.decimals()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -181,6 +184,6 @@ public class HtmlTables {
|
|||
* @return a new {@link PluginPlayersTable}.
|
||||
*/
|
||||
public TableContainer pluginPlayersTable(Map<PluginData, AnalysisContainer> containers, Collection<PlayerContainer> players) {
|
||||
return new PluginPlayersTable(containers, players, config.getNumber(Settings.MAX_PLAYERS));
|
||||
return new PluginPlayersTable(containers, players, config.get(DisplaySettings.PLAYERS_PER_SERVER_PAGE));
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ class PlayersTable extends TableContainer {
|
|||
|
||||
private final List<PlayerContainer> players;
|
||||
private final int maxPlayers;
|
||||
private final int activeMinuteThreshold;
|
||||
private final long activeMsThreshold;
|
||||
private final int activeLoginThreshold;
|
||||
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
@ -49,7 +49,7 @@ class PlayersTable extends TableContainer {
|
|||
PlayersTable(
|
||||
List<PlayerContainer> players,
|
||||
int maxPlayers,
|
||||
int activeMinuteThreshold,
|
||||
long activeMsThreshold,
|
||||
int activeLoginThreshold,
|
||||
Formatter<Long> timeAmountFormatter,
|
||||
Formatter<Long> yearLongFormatter,
|
||||
|
@ -66,7 +66,7 @@ class PlayersTable extends TableContainer {
|
|||
);
|
||||
this.players = players;
|
||||
this.maxPlayers = maxPlayers;
|
||||
this.activeMinuteThreshold = activeMinuteThreshold;
|
||||
this.activeMsThreshold = activeMsThreshold;
|
||||
this.activeLoginThreshold = activeLoginThreshold;
|
||||
this.decimalFormatter = decimalFormatter;
|
||||
useJqueryDataTables("player-table");
|
||||
|
@ -97,7 +97,7 @@ class PlayersTable extends TableContainer {
|
|||
long registered = player.getValue(PlayerKeys.REGISTERED).orElse(0L);
|
||||
long lastSeen = sessionsMutator.toLastSeen();
|
||||
|
||||
ActivityIndex activityIndex = player.getActivityIndex(now, activeMinuteThreshold, activeLoginThreshold);
|
||||
ActivityIndex activityIndex = player.getActivityIndex(now, activeMsThreshold, activeLoginThreshold);
|
||||
boolean isBanned = player.getValue(PlayerKeys.BANNED).orElse(false);
|
||||
String activityString = activityIndex.getFormattedValue(decimalFormatter)
|
||||
+ (isBanned ? " (<b>Banned</b>)" : " (" + activityIndex.getGroup() + ")");
|
||||
|
|
|
@ -8,27 +8,20 @@ Server:
|
|||
IP: 0.0.0.0
|
||||
Network:
|
||||
Name: Plan
|
||||
|
||||
# -----------------------------------------------------
|
||||
Plugin:
|
||||
Debug: 'false'
|
||||
Locale: default
|
||||
Check-for-updates: true
|
||||
Notify-About-DEV-Releases: false
|
||||
KeepLogsForXDays: 7
|
||||
|
||||
Logging:
|
||||
Locale: default
|
||||
Create_new_locale_file_on_next_enable: false
|
||||
Debug: false
|
||||
Dev: false
|
||||
Delete_logs_after_days: 7
|
||||
Update_notifications:
|
||||
# Display update notification on the website
|
||||
Check_for_updates: true
|
||||
Notify_about_DEV_releases: false
|
||||
# -----------------------------------------------------
|
||||
# More information about SSL Certificate Settings:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/SSL-Certificate-%28HTTPS%29-Set-Up
|
||||
# -----------------------------------------------------
|
||||
WebServer:
|
||||
Port: 8804
|
||||
InternalIP: 0.0.0.0
|
||||
Security:
|
||||
SSL-Certificate:
|
||||
KeyStorePath: 'SSLCertificate.keystore'
|
||||
KeyPass: 'default'
|
||||
StorePass: 'default'
|
||||
Alias: 'alias'
|
||||
# Supported databases: MySQL
|
||||
# -----------------------------------------------------
|
||||
Database:
|
||||
MySQL:
|
||||
|
@ -37,91 +30,129 @@ Database:
|
|||
User: root
|
||||
Password: minecraft
|
||||
Database: Plan
|
||||
# Launch options to append after driver address, for example
|
||||
LaunchOptions: "?rewriteBatchedStatements=true&useSSL=false"
|
||||
# Launch options to append after mysql driver address
|
||||
Launch_options: "?rewriteBatchedStatements=true&useSSL=false"
|
||||
# -----------------------------------------------------
|
||||
Commands:
|
||||
AlternativeIP:
|
||||
Enabled: false
|
||||
Link: your.domain.here:%port%
|
||||
Colors:
|
||||
# More information about SSL Certificate Settings:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/SSL-Certificate-%28HTTPS%29-Set-Up
|
||||
# -----------------------------------------------------
|
||||
Webserver:
|
||||
Port: 8804
|
||||
Alternative_IP: false
|
||||
# %port% is replaced automatically with Webserver.Port
|
||||
Address: your.domain.here:%port%
|
||||
# InternalIP usually does not need to be changed, only change it if you know what you're doing!
|
||||
# 0.0.0.0 allocates Internal (local) IP automatically for the WebServer.
|
||||
Internal_IP: 0.0.0.0
|
||||
Security:
|
||||
SSL_certificate:
|
||||
KeyStore_path: Cert.jks
|
||||
Key_pass: default
|
||||
Store_pass: default
|
||||
Alias: alias
|
||||
# For those that want to serve Html from their own WebServer instead.
|
||||
# Set up Html Export (https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/External-WebServer-Use)
|
||||
# ATTENTION: On BungeeCord systems it is not possible to disable the WebServer on the plugin due to connection requirements.
|
||||
# If the WebServer is disabled with this setting BungeeCord systems will cease to function.
|
||||
Disable_Webserver: false
|
||||
External_Webserver_address: "https://www.example.address"
|
||||
# -----------------------------------------------------
|
||||
Data_gathering:
|
||||
Geolocations: true
|
||||
# -----------------------------------------------------
|
||||
# Supported time units: MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS
|
||||
# -----------------------------------------------------
|
||||
Time:
|
||||
# UTC used if false. Only affects Timestamps and graphs.
|
||||
Use_server_timezone: true
|
||||
Delays:
|
||||
Ping_server_enable_delay: 300
|
||||
Unit: SECONDS
|
||||
Ping_player_join_delay: 30
|
||||
Unit: SECONDS
|
||||
Thresholds:
|
||||
# How long player needs to be idle until Plan considers them AFK
|
||||
AFK_threshold: 3
|
||||
Unit: MINUTES
|
||||
# Activity Index considers last 3 weeks and uses these thresholds in the calculation
|
||||
# The index is a number from 0 to 5.
|
||||
# These numbers were calibrated with data of 250 players (Small sample size).
|
||||
Activity_index:
|
||||
Login_threshold: 2
|
||||
Playtime_threshold: 30
|
||||
Unit: MINUTES
|
||||
Remove_inactive_player_data_after: 180
|
||||
Unit: DAYS
|
||||
Periodic_tasks:
|
||||
Clean_caches_every: 10
|
||||
Unit: MINUTES
|
||||
Clean_Database_every: 1
|
||||
Unit: HOURS
|
||||
# -----------------------------------------------------
|
||||
Display_options:
|
||||
# More information about Themes:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Themes
|
||||
Theme: default
|
||||
Sessions:
|
||||
Replace_accordion_with_table: false
|
||||
Show_most_played_world_in_title: true
|
||||
Show_on_page: 50
|
||||
# By Default World playtime pie is ordered alphabetically.
|
||||
# Colors will be determined alphabetically in any case.
|
||||
Order_world_pies_by_percentage: false
|
||||
Players_table:
|
||||
Show_on_players_page: 25000
|
||||
Show_player_IPs: true
|
||||
Graphs:
|
||||
Show_gaps_in_data: false
|
||||
Command_colors:
|
||||
Main: '&2'
|
||||
Secondary: '&7'
|
||||
Highlight: '&f'
|
||||
|
||||
Analysis:
|
||||
AutoRefreshPeriod: 60
|
||||
Active:
|
||||
# Minutes a player should play per week to be considered active
|
||||
PlaytimeThreshold: 30
|
||||
# How many days player should join per week to be considered active
|
||||
LoginThreshold: 2
|
||||
Export:
|
||||
Enabled: false
|
||||
DestinationFolder: 'Analysis Results'
|
||||
|
||||
Data:
|
||||
# How many minutes player has to stay still to be considered AFK
|
||||
AFKThresholdMinutes: 3
|
||||
Commands:
|
||||
LogUnknownCommands: false
|
||||
CombineCommandAliases: true
|
||||
Geolocations: true
|
||||
Ping:
|
||||
ServerEnableDelaySeconds: 300
|
||||
PlayerLoginDelaySeconds: 30
|
||||
KeepInactivePlayerDataForDays: 180
|
||||
# -----------------------------------------------------
|
||||
Customization:
|
||||
UseServerTime: true
|
||||
Display:
|
||||
SessionsAsTable: false
|
||||
LargestWorldPercInSessionTitle: false
|
||||
# By Default WorldPie is ordered alphabetically, colors are still determined alphabetically.
|
||||
OrderWorldPieByPercentage: false
|
||||
MaxSessions: 50
|
||||
MaxPlayers: 2500
|
||||
MaxPlayersPlayersPage: 25000
|
||||
PlayerTableFooter: true
|
||||
PlayerIPs: true
|
||||
GapsInGraphData: false
|
||||
Formatting:
|
||||
DecimalPoints: '#.##'
|
||||
Dates:
|
||||
# RecentDays replaces date with Today, Yesterday, Wednesday etc.
|
||||
RecentDays: true
|
||||
# Non-regex pattern to replace
|
||||
DatePattern: 'MMM d YYYY'
|
||||
Full: 'MMM d YYYY, HH:mm:ss'
|
||||
NoSeconds: 'MMM d YYYY, HH:mm'
|
||||
JustClock: 'HH:mm:ss'
|
||||
TimeAmount:
|
||||
Year: '1 year, '
|
||||
Years: '%years% years, '
|
||||
Month: '1 month, '
|
||||
Months: '%months% months, '
|
||||
Day: '1d '
|
||||
Days: '%days%d '
|
||||
Hours: '%hours%h '
|
||||
Minutes: '%minutes%m '
|
||||
Seconds: '%seconds%s'
|
||||
Zero: '0s'
|
||||
|
||||
Formatting:
|
||||
Decimal_points: '#.##'
|
||||
Time_amount:
|
||||
Year: '1 year, '
|
||||
Years: '%years% years, '
|
||||
Month: '1 month, '
|
||||
Months: '%months% months, '
|
||||
Day: '1d '
|
||||
Days: '%days%d '
|
||||
Hours: '%hours%h '
|
||||
Minutes: '%minutes%m '
|
||||
Seconds: '%seconds%s'
|
||||
Zero: '0s'
|
||||
# Dates settings use Java SimpleDateFormat.
|
||||
# You can find the patterns & examples here:
|
||||
# https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
Dates:
|
||||
# Show_recent_day_names replaces day number with Today, Yesterday, Wednesday etc.
|
||||
Show_recent_day_names: true
|
||||
# Non-regex pattern to replace
|
||||
DatePattern: 'MMM d YYYY'
|
||||
Full: 'MMM d YYYY, HH:mm:ss'
|
||||
NoSeconds: 'MMM d YYYY, HH:mm'
|
||||
JustClock: 'HH:mm:ss'
|
||||
# -----------------------------------------------------
|
||||
# More information about Themes:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Themes
|
||||
# These settings will make Plan write .js, .css, .json and .html files to some location on disk.
|
||||
# Relative path will render to /plugins/Plan/path
|
||||
# Make sure user running the server has write permissions to the path.
|
||||
# -----------------------------------------------------
|
||||
Theme:
|
||||
Base: Default
|
||||
Font:
|
||||
FontStyleSheet: https://fonts.googleapis.com/css?family=Quicksand:300,400
|
||||
FontFamily: "'Quicksand', sans-serif"
|
||||
Export:
|
||||
HTML_Export_path: 'Analysis Results'
|
||||
JSON_Export_path: 'Raw JSON'
|
||||
Parts:
|
||||
JavaScript_and_CSS: false
|
||||
# Player pages/JSON are only written on join/leave.
|
||||
Player_pages: false
|
||||
Player_JSON: false
|
||||
Players_page: false
|
||||
Server_page: false
|
||||
Server_JSON: false
|
||||
# -----------------------------------------------------
|
||||
Servers:
|
||||
Example:
|
||||
WebServerPort: 8034
|
||||
ServerName: Example
|
||||
ThemeBase: Default
|
||||
# These settings affect Plugin data integration.
|
||||
# If a plugin is causing issues the integration can be disabled by setting Plugin_name.Enabled: false
|
||||
# -----------------------------------------------------
|
||||
Plugins:
|
||||
BuyCraft:
|
||||
|
|
|
@ -5,43 +5,24 @@
|
|||
# -----------------------------------------------------
|
||||
Server:
|
||||
ServerName: 'Plan'
|
||||
|
||||
# -----------------------------------------------------
|
||||
# More information about Locale
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Localization
|
||||
# -----------------------------------------------------
|
||||
Plugin:
|
||||
Debug: false
|
||||
Locale: default
|
||||
WriteNewLocaleFileOnEnable: false
|
||||
Bungee-Override:
|
||||
StandaloneMode: false
|
||||
CopyBungeeConfig: true
|
||||
Check-for-updates: true
|
||||
Notify-About-DEV-Releases: false
|
||||
KeepLogsForXDays: 7
|
||||
|
||||
Logging:
|
||||
# More information about Locale
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Localization
|
||||
Locale: default
|
||||
Create_new_locale_file_on_next_enable: false
|
||||
Debug: false
|
||||
Dev: false
|
||||
Delete_logs_after_days: 7
|
||||
Update_notifications:
|
||||
# Display update notification on the website
|
||||
Check_for_updates: true
|
||||
Notify_about_DEV_releases: false
|
||||
Configuration:
|
||||
Allow_bungeecord_to_manage_settings: true
|
||||
# -----------------------------------------------------
|
||||
# More information about SSL Certificate Settings:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/SSL-Certificate-%28HTTPS%29-Set-Up
|
||||
# -----------------------------------------------------
|
||||
WebServer:
|
||||
Port: 8804
|
||||
# InternalIP usually does not need to be changed, only change it if you know what you're doing!
|
||||
# 0.0.0.0 allocates Internal (local) IP automatically for the WebServer.
|
||||
InternalIP: 0.0.0.0
|
||||
Security:
|
||||
SSL-Certificate:
|
||||
KeyStorePath: 'SSLCertificate.keystore'
|
||||
KeyPass: 'default'
|
||||
StorePass: 'default'
|
||||
Alias: 'alias'
|
||||
# For those that want to serve Html from their own WebServer instead.
|
||||
# Set up Html Export (https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/External-WebServer-Use)
|
||||
# ATTENTION: On BungeeCord systems it is not possible to disable the WebServer on the plugin due to connection requirements.
|
||||
# If the WebServer is disabled with this setting BungeeCord systems will cease to function.
|
||||
DisableWebServer: false
|
||||
ExternalWebServerAddress: "https://www.example.address"
|
||||
# Supported databases: SQLite, H2, MySQL
|
||||
# -----------------------------------------------------
|
||||
Database:
|
||||
Type: SQLite
|
||||
|
@ -51,105 +32,154 @@ Database:
|
|||
User: root
|
||||
Password: minecraft
|
||||
Database: Plan
|
||||
# Launch options to append after driver address, for example
|
||||
LaunchOptions: "?rewriteBatchedStatements=true&useSSL=false"
|
||||
# Launch options to append after mysql driver address
|
||||
Launch_options: "?rewriteBatchedStatements=true&useSSL=false"
|
||||
# -----------------------------------------------------
|
||||
Commands:
|
||||
AlternativeIP:
|
||||
Enabled: false
|
||||
Link: your.domain.here:%port%
|
||||
Colors:
|
||||
# More information about SSL Certificate Settings:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/SSL-Certificate-%28HTTPS%29-Set-Up
|
||||
# -----------------------------------------------------
|
||||
Webserver:
|
||||
Port: 8804
|
||||
Alternative_IP: false
|
||||
# %port% is replaced automatically with Webserver.Port
|
||||
Address: your.domain.here:%port%
|
||||
# InternalIP usually does not need to be changed, only change it if you know what you're doing!
|
||||
# 0.0.0.0 allocates Internal (local) IP automatically for the WebServer.
|
||||
Internal_IP: 0.0.0.0
|
||||
Security:
|
||||
SSL_certificate:
|
||||
KeyStore_path: Cert.jks
|
||||
Key_pass: default
|
||||
Store_pass: default
|
||||
Alias: alias
|
||||
# For those that want to serve Html from their own WebServer instead.
|
||||
# Set up Html Export (https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/External-WebServer-Use)
|
||||
# ATTENTION: On BungeeCord systems it is not possible to disable the WebServer on the plugin due to connection requirements.
|
||||
# If the WebServer is disabled with this setting BungeeCord systems will cease to function.
|
||||
Disable_Webserver: false
|
||||
External_Webserver_address: "https://www.example.address"
|
||||
# -----------------------------------------------------
|
||||
Data_gathering:
|
||||
Geolocations: true
|
||||
Commands:
|
||||
Log_unknown: false
|
||||
Log_aliases_as_main_command: true
|
||||
# -----------------------------------------------------
|
||||
# Supported time units: MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS
|
||||
# -----------------------------------------------------
|
||||
Time:
|
||||
# UTC used if false. Only affects Timestamps and graphs.
|
||||
Use_server_timezone: true
|
||||
Delays:
|
||||
Ping_server_enable_delay: 300
|
||||
Unit: SECONDS
|
||||
Ping_player_join_delay: 30
|
||||
Unit: SECONDS
|
||||
Thresholds:
|
||||
# How long player needs to be idle until Plan considers them AFK
|
||||
AFK_threshold: 3
|
||||
Unit: MINUTES
|
||||
# Activity Index considers last 3 weeks and uses these thresholds in the calculation
|
||||
# The index is a number from 0 to 5.
|
||||
# These numbers were calibrated with data of 250 players (Small sample size).
|
||||
Activity_index:
|
||||
Login_threshold: 2
|
||||
Playtime_threshold: 30
|
||||
Unit: MINUTES
|
||||
Remove_inactive_player_data_after: 180
|
||||
Unit: DAYS
|
||||
Periodic_tasks:
|
||||
Analysis_refresh_every: 60
|
||||
Unit: MINUTES
|
||||
Clean_caches_every: 10
|
||||
Unit: MINUTES
|
||||
Clean_Database_every: 1
|
||||
Unit: HOURS
|
||||
# -----------------------------------------------------
|
||||
Display_options:
|
||||
# More information about Themes:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Themes
|
||||
Theme: default
|
||||
Sessions:
|
||||
Replace_accordion_with_table: false
|
||||
Show_most_played_world_in_title: true
|
||||
Show_on_page: 50
|
||||
# By Default World playtime pie is ordered alphabetically.
|
||||
# Colors will be determined alphabetically in any case.
|
||||
Order_world_pies_by_percentage: false
|
||||
Players_table:
|
||||
Show_on_server_page: 2500
|
||||
Show_on_players_page: 25000
|
||||
Show_player_IPs: true
|
||||
Graphs:
|
||||
Show_gaps_in_data: false
|
||||
TPS:
|
||||
High_threshold: 18
|
||||
Medium_threshold: 10
|
||||
Disk_space:
|
||||
High_threshold: 500
|
||||
Medium_threshold: 100
|
||||
Command_colors:
|
||||
Main: '&2'
|
||||
Secondary: '&7'
|
||||
Highlight: '&f'
|
||||
|
||||
Analysis:
|
||||
AutoRefreshPeriod: 60
|
||||
Active:
|
||||
# Minutes a player should play per week to be considered active
|
||||
PlaytimeThreshold: 30
|
||||
# How many days player should join per week to be considered active
|
||||
LoginThreshold: 2
|
||||
LogProgress: true
|
||||
Export:
|
||||
Enabled: false
|
||||
DestinationFolder: 'Analysis Results'
|
||||
Data:
|
||||
# How many minutes player has to stay still to be considered AFK
|
||||
AFKThresholdMinutes: 3
|
||||
Commands:
|
||||
LogUnknownCommands: false
|
||||
CombineCommandAliases: true
|
||||
Geolocations: true
|
||||
Ping:
|
||||
ServerEnableDelaySeconds: 300
|
||||
PlayerLoginDelaySeconds: 30
|
||||
KeepInactivePlayerDataForDays: 180
|
||||
# -----------------------------------------------------
|
||||
Customization:
|
||||
UseServerTime: true
|
||||
Display:
|
||||
SessionsAsTable: false
|
||||
LargestWorldPercInSessionTitle: false
|
||||
# By Default WorldPie is ordered alphabetically, colors are still determined alphabetically.
|
||||
OrderWorldPieByPercentage: false
|
||||
MaxSessions: 50
|
||||
MaxPlayers: 2500
|
||||
MaxPlayersPlayersPage: 25000
|
||||
PlayerTableFooter: true
|
||||
PlayerIPs: true
|
||||
GapsInGraphData: false
|
||||
Formatting:
|
||||
DecimalPoints: '#.##'
|
||||
# Dates settings use Java SimpleDateFormat.
|
||||
# You can find the patterns & examples here:
|
||||
# https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
Dates:
|
||||
# RecentDays replaces date with Today, Yesterday, Wednesday etc.
|
||||
RecentDays: true
|
||||
# Non-regex pattern to replace
|
||||
DatePattern: 'MMM d YYYY'
|
||||
Full: 'MMM d YYYY, HH:mm:ss'
|
||||
NoSeconds: 'MMM d YYYY, HH:mm'
|
||||
JustClock: 'HH:mm:ss'
|
||||
TimeAmount:
|
||||
Year: '1 year, '
|
||||
Years: '%years% years, '
|
||||
Month: '1 month, '
|
||||
Months: '%months% months, '
|
||||
Day: '1d '
|
||||
Days: '%days%d '
|
||||
Hours: '%hours%h '
|
||||
Minutes: '%minutes%m '
|
||||
Seconds: '%seconds%s'
|
||||
Zero: '0s'
|
||||
WorldAliases:
|
||||
world: world
|
||||
|
||||
Formatting:
|
||||
Decimal_points: '#.##'
|
||||
Time_amount:
|
||||
Year: '1 year, '
|
||||
Years: '%years% years, '
|
||||
Month: '1 month, '
|
||||
Months: '%months% months, '
|
||||
Day: '1d '
|
||||
Days: '%days%d '
|
||||
Hours: '%hours%h '
|
||||
Minutes: '%minutes%m '
|
||||
Seconds: '%seconds%s'
|
||||
Zero: '0s'
|
||||
# Dates settings use Java SimpleDateFormat.
|
||||
# You can find the patterns & examples here:
|
||||
# https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
Dates:
|
||||
# Show_recent_day_names replaces day number with Today, Yesterday, Wednesday etc.
|
||||
Show_recent_day_names: true
|
||||
# Non-regex pattern to replace
|
||||
DatePattern: 'MMM d YYYY'
|
||||
Full: 'MMM d YYYY, HH:mm:ss'
|
||||
NoSeconds: 'MMM d YYYY, HH:mm'
|
||||
JustClock: 'HH:mm:ss'
|
||||
# -----------------------------------------------------
|
||||
# More information about Themes:
|
||||
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Themes
|
||||
#
|
||||
# Since 4.1.0 colors are set in theme.yml
|
||||
# World aliases can be used to rename worlds and to combine multiple worlds into a group.
|
||||
# -----------------------------------------------------
|
||||
Theme:
|
||||
Base: Default
|
||||
Graphs:
|
||||
TPS:
|
||||
High-Threshold: 18
|
||||
Medium-Threshold: 10
|
||||
# Free Disk space thresholds, in megabytes.
|
||||
Disk:
|
||||
High-Threshold: 500
|
||||
Medium-Threshold: 100
|
||||
World_aliases:
|
||||
world: world
|
||||
# -----------------------------------------------------
|
||||
# These settings will make Plan write .js, .css, .json and .html files to some location on disk.
|
||||
# Relative path will render to /plugins/Plan/path
|
||||
# Make sure user running the server has write permissions to the path.
|
||||
# -----------------------------------------------------
|
||||
Export:
|
||||
HTML_Export_path: 'Analysis Results'
|
||||
JSON_Export_path: 'Raw JSON'
|
||||
Parts:
|
||||
JavaScript_and_CSS: false
|
||||
# Player pages/JSON are only written on join/leave.
|
||||
Player_pages: false
|
||||
Player_JSON: false
|
||||
Players_page: false
|
||||
Server_page: false
|
||||
Server_JSON: false
|
||||
# -----------------------------------------------------
|
||||
# These settings affect Plugin data integration.
|
||||
# If a plugin is causing issues the integration can be disabled by setting Plugin_name.Enabled: false
|
||||
# -----------------------------------------------------
|
||||
Plugins:
|
||||
BuyCraft:
|
||||
# http://help.buycraft.net/article/36-where-to-find-the-secret-key
|
||||
Secret: "-"
|
||||
Factions:
|
||||
HideFactions:
|
||||
- ExampleFaction
|
||||
Towny:
|
||||
HideTowns:
|
||||
- ExampleTown
|
||||
BuyCraft:
|
||||
# http://help.buycraft.net/article/36-where-to-find-the-secret-key
|
||||
Secret: "-"
|
||||
- ExampleTown
|
|
@ -1,7 +1,7 @@
|
|||
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.plan.system.settings.paths.FormatSettings;
|
||||
import com.djrapitops.plan.utilities.formatting.DecimalFormatter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -22,7 +22,7 @@ public class DecimalFormatterTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
PlanConfig config = Mockito.mock(PlanConfig.class);
|
||||
when(config.getString(Settings.FORMAT_DECIMALS)).thenReturn("#.##");
|
||||
when(config.getString(FormatSettings.DECIMALS)).thenReturn("#.##");
|
||||
|
||||
underTest = new DecimalFormatter(config);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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.plan.system.settings.paths.FormatSettings;
|
||||
import com.djrapitops.plan.utilities.formatting.time.TimeAmountFormatter;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -24,18 +24,18 @@ public class TimeAmountFormatterDefaultTest {
|
|||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
PlanConfig config = Mockito.mock(PlanConfig.class);
|
||||
when(config.getString(Settings.FORMAT_YEAR)).thenReturn("1 year, ");
|
||||
when(config.getString(Settings.FORMAT_YEARS)).thenReturn("%years% years, ");
|
||||
when(config.getString(Settings.FORMAT_MONTH)).thenReturn("1 month, ");
|
||||
when(config.getString(Settings.FORMAT_YEAR)).thenReturn("1 year, ");
|
||||
when(config.getString(Settings.FORMAT_MONTH)).thenReturn("1 month, ");
|
||||
when(config.getString(Settings.FORMAT_MONTHS)).thenReturn("%months% months, ");
|
||||
when(config.getString(Settings.FORMAT_DAY)).thenReturn("1d ");
|
||||
when(config.getString(Settings.FORMAT_DAYS)).thenReturn("%days%d ");
|
||||
when(config.getString(Settings.FORMAT_HOURS)).thenReturn("%hours%h ");
|
||||
when(config.getString(Settings.FORMAT_MINUTES)).thenReturn("%minutes%m ");
|
||||
when(config.getString(Settings.FORMAT_SECONDS)).thenReturn("%seconds%s");
|
||||
when(config.getString(Settings.FORMAT_ZERO_SECONDS)).thenReturn("0s");
|
||||
when(config.getString(FormatSettings.YEAR)).thenReturn("1 year, ");
|
||||
when(config.getString(FormatSettings.YEARS)).thenReturn("%years% years, ");
|
||||
when(config.getString(FormatSettings.MONTH)).thenReturn("1 month, ");
|
||||
when(config.getString(FormatSettings.YEAR)).thenReturn("1 year, ");
|
||||
when(config.getString(FormatSettings.MONTH)).thenReturn("1 month, ");
|
||||
when(config.getString(FormatSettings.MONTHS)).thenReturn("%months% months, ");
|
||||
when(config.getString(FormatSettings.DAY)).thenReturn("1d ");
|
||||
when(config.getString(FormatSettings.DAYS)).thenReturn("%days%d ");
|
||||
when(config.getString(FormatSettings.HOURS)).thenReturn("%hours%h ");
|
||||
when(config.getString(FormatSettings.MINUTES)).thenReturn("%minutes%m ");
|
||||
when(config.getString(FormatSettings.SECONDS)).thenReturn("%seconds%s");
|
||||
when(config.getString(FormatSettings.ZERO_SECONDS)).thenReturn("0s");
|
||||
underTest = new TimeAmountFormatter(config);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user