mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-02 22:47:41 +01:00
Add flags to isDebug for more granular debug toggles
This commit is contained in:
parent
a7f39c5e0d
commit
1a09c49b29
@ -18,6 +18,8 @@ import java.util.function.Predicate;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public interface ISettings extends IConf {
|
public interface ISettings extends IConf {
|
||||||
|
String DEBUG_FLAG_NAMESPACE = "net.essentialsx";
|
||||||
|
|
||||||
File getConfigFile();
|
File getConfigFile();
|
||||||
|
|
||||||
boolean areSignsDisabled();
|
boolean areSignsDisabled();
|
||||||
@ -141,6 +143,8 @@ public interface ISettings extends IConf {
|
|||||||
|
|
||||||
boolean isDebug();
|
boolean isDebug();
|
||||||
|
|
||||||
|
boolean isDebug(DebugFlag flag);
|
||||||
|
|
||||||
void setDebug(boolean debug);
|
void setDebug(boolean debug);
|
||||||
|
|
||||||
boolean isEcoDisabled();
|
boolean isEcoDisabled();
|
||||||
@ -416,4 +420,31 @@ public interface ISettings extends IConf {
|
|||||||
OFF
|
OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum DebugFlag {
|
||||||
|
GENERIC("debug.generic", true),
|
||||||
|
USERMAP_PRINT_STACK("usermap.print-stack", false),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String propertyKey;
|
||||||
|
private final boolean isSetByConfig;
|
||||||
|
|
||||||
|
DebugFlag(final String propertyKey, final boolean isSetByConfig) {
|
||||||
|
this.propertyKey = propertyKey;
|
||||||
|
this.isSetByConfig = isSetByConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSystemProperty() {
|
||||||
|
return DEBUG_FLAG_NAMESPACE + "." + propertyKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSystemPropertyValue() {
|
||||||
|
final String value = System.getProperty(getSystemProperty(), "false");
|
||||||
|
return Boolean.parseBoolean(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSetByConfig() {
|
||||||
|
return isSetByConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -860,7 +860,15 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebug() {
|
public boolean isDebug() {
|
||||||
return debug || configDebug;
|
return isDebug(DebugFlag.GENERIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebug(DebugFlag flag) {
|
||||||
|
if (flag.isSetByConfig() && (debug || configDebug)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return flag.getSystemPropertyValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.userstorage;
|
package com.earth2me.essentials.userstorage;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.ISettings;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
import com.earth2me.essentials.OfflinePlayer;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
@ -36,13 +37,12 @@ public class ModernUserMap extends CacheLoader<UUID, User> implements IUserMap {
|
|||||||
.softValues()
|
.softValues()
|
||||||
.build(this);
|
.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
|
// -Dnet.essentialsx.usermap.max-warns=20
|
||||||
final String maxWarnProperty = System.getProperty("net.essentialsx.usermap.max-warns", "100");
|
final String maxWarnProperty = System.getProperty("net.essentialsx.usermap.max-warns", "100");
|
||||||
|
|
||||||
this.debugMaxWarnsPerType = NumberUtil.isLong(maxWarnProperty) ? Long.parseLong(maxWarnProperty) : -1;
|
this.debugMaxWarnsPerType = NumberUtil.isLong(maxWarnProperty) ? Long.parseLong(maxWarnProperty) : -1;
|
||||||
this.debugPrintStackWithWarn = Boolean.parseBoolean(printStackProperty);
|
// -Dnet.essentialsx.usermap.print-stack=true
|
||||||
|
this.debugPrintStackWithWarn = ess.getSettings().isDebug(ISettings.DebugFlag.USERMAP_PRINT_STACK);
|
||||||
this.debugNonPlayerWarnCounts = new ConcurrentHashMap<>();
|
this.debugNonPlayerWarnCounts = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user