Compare commits

...
4 changed files with 93 additions and 9 deletions

No files matched your search

@@ -3,6 +3,7 @@ package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.utils.NumberUtil;
import org.bukkit.Material;
import org.bukkit.event.EventPriority;
import org.spongepowered.configurate.CommentedConfigurationNode;
@@ -18,6 +19,8 @@ import java.util.function.Predicate;
import java.util.regex.Pattern;
public interface ISettings extends IConf {
String DEBUG_FLAG_NAMESPACE = "net.essentialsx";
File getConfigFile();
boolean areSignsDisabled();
@@ -141,6 +144,10 @@ public interface ISettings extends IConf {
boolean isDebug();
boolean isDebug(DebugFlag flag);
Long getDebugLong(DebugFlag flag);
void setDebug(boolean debug);
boolean isEcoDisabled();
@@ -416,4 +423,52 @@ public interface ISettings extends IConf {
OFF
}
// TODO: consider separating out non-bool values? or replace this with an object-mapped class?
enum DebugFlag {
GENERIC("debug.generic", true),
USERMAP_PRINT_STACK("usermap.print-stack", false),
USERMAP_MAX_WARNS("usermap.max-warns", false),
;
private final String flagKey;
private final boolean isSetByGlobal;
DebugFlag(final String flagKey, final boolean isSetByGlobal) {
this.flagKey = flagKey;
this.isSetByGlobal = isSetByGlobal;
}
public String getFlagKey() {
return flagKey;
}
public boolean isSetByGlobal() {
return isSetByGlobal;
}
public String getSystemPropertyKey() {
return DEBUG_FLAG_NAMESPACE + "." + flagKey;
}
public String getConfigKey() {
return "debug." + (flagKey.replace("debug.", ""));
}
public String getSystemPropertyValue() {
return System.getProperty(getSystemPropertyKey(), "false");
}
public boolean getSystemPropertyBoolean() {
return Boolean.parseBoolean(getSystemPropertyValue());
}
public Long getSystemPropertyLong() {
final String value = getSystemPropertyValue();
if (NumberUtil.isLong(value)) {
return Long.parseLong(value);
}
return null;
}
}
}
@@ -855,12 +855,41 @@ public class Settings implements net.ess3.api.ISettings {
}
private boolean _isDebug() {
return config.getBoolean("debug", false);
if (config.isBoolean("debug")) {
return config.getBoolean("debug", false);
}
if (config.isBoolean("debug.enabled")) {
return config.getBoolean("debug.enabled", false);
}
return false;
}
@Override
public boolean isDebug() {
return debug || configDebug;
return isDebug(DebugFlag.GENERIC);
}
@Override
public boolean isDebug(DebugFlag flag) {
if (flag.isSetByGlobal() && (debug || configDebug)) {
return true;
}
final String flagConfigPath = flag.getConfigKey();
if (config.isBoolean(flagConfigPath)) {
return config.getBoolean(flagConfigPath, false);
}
return flag.getSystemPropertyBoolean();
}
@Override
public Long getDebugLong(DebugFlag flag) {
final String flagConfigPath = flag.getConfigKey();
if (config.hasProperty(flagConfigPath)) {
return config.getLong(flagConfigPath, 0);
}
return flag.getSystemPropertyLong();
}
@Override
@@ -1,8 +1,8 @@
package com.earth2me.essentials.userstorage;
import com.earth2me.essentials.ISettings;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.NumberUtil;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -36,13 +36,13 @@ public class ModernUserMap extends CacheLoader<UUID, User> implements IUserMap {
.softValues()
.build(this);
// -Dnet.essentialsx.usermap.print-stack=true
final String printStackProperty = System.getProperty("net.essentialsx.usermap.print-stack", "false");
// -Dnet.essentialsx.usermap.max-warns=20
final String maxWarnProperty = System.getProperty("net.essentialsx.usermap.max-warns", "100");
final Long maxWarnSetting = ess.getSettings().getDebugLong(ISettings.DebugFlag.USERMAP_MAX_WARNS);
this.debugMaxWarnsPerType = maxWarnSetting != null ? maxWarnSetting : -1;
// -Dnet.essentialsx.usermap.print-stack=true
this.debugPrintStackWithWarn = ess.getSettings().isDebug(ISettings.DebugFlag.USERMAP_PRINT_STACK);
this.debugMaxWarnsPerType = NumberUtil.isLong(maxWarnProperty) ? Long.parseLong(maxWarnProperty) : -1;
this.debugPrintStackWithWarn = Boolean.parseBoolean(printStackProperty);
this.debugNonPlayerWarnCounts = new ConcurrentHashMap<>();
}
+1 -1
View File
@@ -1 +1 @@
const val RUN_PAPER_MINECRAFT_VERSION = "1.19.2"
const val RUN_PAPER_MINECRAFT_VERSION = "1.19.3"