mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
[Debt] Removed Settings isTrue method.
Moved MiscUtils.getTimeZoneOffsetHours to PlanConfig as non static. Affected issues: none
This commit is contained in:
parent
bff365de20
commit
b6cc713c01
|
@ -16,7 +16,6 @@ import com.djrapitops.plan.system.settings.Settings;
|
|||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.ServerBanDataReader;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
|
@ -100,7 +99,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> secondLongFormatter.apply(getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
|
||||
|
||||
putRawData(AnalysisKeys.VERSION, version);
|
||||
putSupplier(AnalysisKeys.TIME_ZONE, MiscUtils::getTimeZoneOffsetHours);
|
||||
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));
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.djrapitops.plan.system.settings.Settings;
|
|||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.graphs.bar.BarGraph;
|
||||
|
@ -90,7 +89,7 @@ public class NetworkContainer extends DataContainer {
|
|||
putSupplier(NetworkKeys.REFRESH_TIME_F, () -> secondLongFormatter.apply(getUnsafe(NetworkKeys.REFRESH_TIME)));
|
||||
|
||||
putRawData(NetworkKeys.VERSION, PlanPlugin.getInstance().getVersion());
|
||||
putSupplier(NetworkKeys.TIME_ZONE, MiscUtils::getTimeZoneOffsetHours);
|
||||
putSupplier(NetworkKeys.TIME_ZONE, config::getTimeZoneOffsetHours);
|
||||
|
||||
putSupplier(NetworkKeys.NETWORK_NAME, () ->
|
||||
Check.isBungeeAvailable() ?
|
||||
|
|
|
@ -110,19 +110,6 @@ public enum Settings implements Setting {
|
|||
this.configPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the settings is a boolean, this method should be used.
|
||||
*
|
||||
* @return Boolean value of the config setting, false if not boolean.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isTrue() {
|
||||
if (tempValue != null) {
|
||||
return (Boolean) tempValue;
|
||||
}
|
||||
return getConfig().getBoolean(configPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the settings is a number, this method should be used.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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.plugin.config.Config;
|
||||
|
@ -11,6 +12,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Plan configuration file.
|
||||
|
@ -38,6 +41,15 @@ public class PlanConfig extends Config {
|
|||
pluginsConfigSection = new PluginsConfigSection(this);
|
||||
}
|
||||
|
||||
public int getTimeZoneOffsetHours() {
|
||||
if (isTrue(Settings.USE_SERVER_TIME)) {
|
||||
int offset = TimeZone.getDefault().getOffset(System.currentTimeMillis());
|
||||
int hourMs = (int) TimeUnit.HOURS.toMillis(1L);
|
||||
return -offset / hourMs;
|
||||
}
|
||||
return 0; // UTC
|
||||
}
|
||||
|
||||
public boolean isTrue(Setting setting) {
|
||||
return getBoolean(setting.getPath());
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* Utility method class containing various static methods.
|
||||
|
@ -25,14 +22,6 @@ public class MiscUtils {
|
|||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int getTimeZoneOffsetHours() {
|
||||
if (Settings.USE_SERVER_TIME.isTrue()) {
|
||||
return -TimeZone.getDefault().getOffset(System.currentTimeMillis()) / (int) TimeAmount.HOUR.ms();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a players name that matches the given arguments or name of the sender.
|
||||
*
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.djrapitops.plan.system.settings.Settings;
|
|||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
|
@ -112,7 +111,7 @@ public class InspectPage implements Page {
|
|||
|
||||
replacer.put("refresh", clockLongFormatter.apply(now));
|
||||
replacer.put("version", version);
|
||||
replacer.put("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||
replacer.put("timeZone", config.getTimeZoneOffsetHours());
|
||||
|
||||
boolean online = false;
|
||||
Optional<Session> activeSession = SessionCache.getCachedSession(uuid);
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.djrapitops.plan.data.store.keys.SessionKeys;
|
|||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
|
@ -38,6 +39,7 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
private int maxSessions;
|
||||
|
||||
// TODO
|
||||
private PlanConfig config;
|
||||
private Theme theme;
|
||||
private Graphs graphs;
|
||||
private HtmlTables tables;
|
||||
|
@ -55,11 +57,8 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
this.playerNamesSupplier = playerNamesSupplier;
|
||||
viewScript = new StringBuilder();
|
||||
|
||||
maxSessions = Settings.MAX_SESSIONS.getNumber();
|
||||
if (maxSessions <= 0) {
|
||||
maxSessions = 50;
|
||||
}
|
||||
appendWorldPercentage = Settings.APPEND_WORLD_PERC.isTrue();
|
||||
maxSessions = config.getNumber(Settings.MAX_SESSIONS);
|
||||
appendWorldPercentage = config.isTrue(Settings.APPEND_WORLD_PERC);
|
||||
|
||||
addElements();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user