From a7f39c5e0dd29852a8989942c30a01b258c7ce17 Mon Sep 17 00:00:00 2001 From: MD <1917406+mdcfe@users.noreply.github.com> Date: Sun, 12 Mar 2023 14:35:35 +0000 Subject: [PATCH 1/3] Bump Paper to 1.19.3 for run-paper --- build-logic/src/main/kotlin/constants.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-logic/src/main/kotlin/constants.kt b/build-logic/src/main/kotlin/constants.kt index 5aebfc557a3..5cc2ea1602e 100644 --- a/build-logic/src/main/kotlin/constants.kt +++ b/build-logic/src/main/kotlin/constants.kt @@ -1 +1 @@ -const val RUN_PAPER_MINECRAFT_VERSION = "1.19.2" +const val RUN_PAPER_MINECRAFT_VERSION = "1.19.3" From 1a09c49b293b03113470aca41c6b05c34516a376 Mon Sep 17 00:00:00 2001 From: MD <1917406+mdcfe@users.noreply.github.com> Date: Sun, 12 Mar 2023 15:08:08 +0000 Subject: [PATCH 2/3] Add flags to isDebug for more granular debug toggles --- .../com/earth2me/essentials/ISettings.java | 31 +++++++++++++++++++ .../com/earth2me/essentials/Settings.java | 10 +++++- .../essentials/userstorage/ModernUserMap.java | 6 ++-- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index 4da7f52549b..e444cc2ab61 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -18,6 +18,8 @@ import java.util.regex.Pattern; public interface ISettings extends IConf { + String DEBUG_FLAG_NAMESPACE = "net.essentialsx"; + File getConfigFile(); boolean areSignsDisabled(); @@ -141,6 +143,8 @@ public interface ISettings extends IConf { boolean isDebug(); + boolean isDebug(DebugFlag flag); + void setDebug(boolean debug); boolean isEcoDisabled(); @@ -416,4 +420,31 @@ enum TeleportWhenFreePolicy { 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; + } + } + } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index c0b1c618245..e34602ee299 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -860,7 +860,15 @@ private boolean _isDebug() { @Override 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 diff --git a/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java b/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java index eaab42c0f87..f4db066b841 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java +++ b/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java @@ -1,5 +1,6 @@ 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; @@ -36,13 +37,12 @@ public ModernUserMap(final IEssentials ess) { .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"); 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<>(); } From 9e5bdeb7d5fdecfd33f9294e451ffc5642c72357 Mon Sep 17 00:00:00 2001 From: MD <1917406+mdcfe@users.noreply.github.com> Date: Sun, 12 Mar 2023 15:33:00 +0000 Subject: [PATCH 3/3] Allow setting flags via config; add flags with long values --- .../com/earth2me/essentials/ISettings.java | 48 ++++++++++++++----- .../com/earth2me/essentials/Settings.java | 27 +++++++++-- .../essentials/userstorage/ModernUserMap.java | 6 +-- 3 files changed, 63 insertions(+), 18 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index e444cc2ab61..926a23ac452 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -3,6 +3,7 @@ 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; @@ -145,6 +146,8 @@ public interface ISettings extends IConf { boolean isDebug(DebugFlag flag); + Long getDebugLong(DebugFlag flag); + void setDebug(boolean debug); boolean isEcoDisabled(); @@ -420,30 +423,51 @@ enum TeleportWhenFreePolicy { 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 propertyKey; - private final boolean isSetByConfig; + 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; + } - DebugFlag(final String propertyKey, final boolean isSetByConfig) { - this.propertyKey = propertyKey; - this.isSetByConfig = isSetByConfig; + public String getConfigKey() { + return "debug." + (flagKey.replace("debug.", "")); } - public String getSystemProperty() { - return DEBUG_FLAG_NAMESPACE + "." + propertyKey; + public String getSystemPropertyValue() { + return System.getProperty(getSystemPropertyKey(), "false"); } - public boolean getSystemPropertyValue() { - final String value = System.getProperty(getSystemProperty(), "false"); - return Boolean.parseBoolean(value); + public boolean getSystemPropertyBoolean() { + return Boolean.parseBoolean(getSystemPropertyValue()); } - public boolean isSetByConfig() { - return isSetByConfig; + public Long getSystemPropertyLong() { + final String value = getSystemPropertyValue(); + if (NumberUtil.isLong(value)) { + return Long.parseLong(value); + } + return null; } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index e34602ee299..3d02712d893 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -855,7 +855,15 @@ public boolean warnOnBuildDisallow() { } 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 @@ -865,10 +873,23 @@ public boolean isDebug() { @Override public boolean isDebug(DebugFlag flag) { - if (flag.isSetByConfig() && (debug || configDebug)) { + if (flag.isSetByGlobal() && (debug || configDebug)) { return true; } - return flag.getSystemPropertyValue(); + 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 diff --git a/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java b/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java index f4db066b841..62330044859 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java +++ b/Essentials/src/main/java/com/earth2me/essentials/userstorage/ModernUserMap.java @@ -3,7 +3,6 @@ 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; @@ -38,11 +37,12 @@ public ModernUserMap(final IEssentials ess) { .build(this); // -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; - this.debugMaxWarnsPerType = NumberUtil.isLong(maxWarnProperty) ? Long.parseLong(maxWarnProperty) : -1; // -Dnet.essentialsx.usermap.print-stack=true this.debugPrintStackWithWarn = ess.getSettings().isDebug(ISettings.DebugFlag.USERMAP_PRINT_STACK); + this.debugNonPlayerWarnCounts = new ConcurrentHashMap<>(); }