From 2e78ca16e18870626c19adc834d1023afafdfbcd Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Fri, 10 Apr 2026 15:51:37 -0700 Subject: [PATCH 01/13] Improve quest compass error handling; mmlog missing methods Signed-off-by: Byron Marohn --- .../managers/QuestCompassManager.java | 8 +++++++- .../quests/components/CompassLocation.java | 12 +++++++++++- .../playmonumenta/scriptedquests/utils/MMLog.java | 14 ++++++++++++++ .../scriptedquests/utils/WorldRegexMatcher.java | 7 ++++++- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/QuestCompassManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/QuestCompassManager.java index 5815226c..157c52a7 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/QuestCompassManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/QuestCompassManager.java @@ -6,6 +6,7 @@ import com.playmonumenta.scriptedquests.quests.components.CompassLocation; import com.playmonumenta.scriptedquests.quests.components.DeathLocation; import com.playmonumenta.scriptedquests.quests.components.QuestLocation; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.utils.MessagingUtils; import com.playmonumenta.scriptedquests.utils.QuestUtils; import com.playmonumenta.scriptedquests.utils.WorldRegexMatcher; @@ -128,7 +129,12 @@ public void reload(Plugin plugin, @Nullable CommandSender sender) { worldRegexes.add(loc.getWorldRegex()); } } - mWorldRegexMatcher = new WorldRegexMatcher(worldRegexes); + try { + mWorldRegexMatcher = new WorldRegexMatcher(worldRegexes); + } catch (Exception e) { + MMLog.severe("Failed to build WorldRegexMatcher for compass", e); + mWorldRegexMatcher = null; + } } public @Nullable WorldRegexMatcher getWorldRegexMatcher() { diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/CompassLocation.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/CompassLocation.java index e421ed07..ef95084c 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/CompassLocation.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/CompassLocation.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.regex.PatternSyntaxException; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -34,6 +35,11 @@ public CompassLocation(World world, JsonElement element) throws Exception { } mWorldRegex = object.has("world_name") ? object.get("world_name").toString().replaceAll("\"", "") : ".*"; + try { + java.util.regex.Pattern.compile(mWorldRegex); + } catch (PatternSyntaxException e) { + throw new Exception("Invalid world_name regex '" + mWorldRegex + "': " + e.getMessage()); + } mPrerequisites = new QuestPrerequisites(prereq); @@ -143,6 +149,10 @@ public boolean prerequisiteMet(Player player) { if (matcher != null) { return matcher.matches(player.getWorld(), mWorldRegex); } - return player.getWorld().getName().matches(mWorldRegex); + try { + return player.getWorld().getName().matches(mWorldRegex); + } catch (PatternSyntaxException e) { + return false; + } } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index 0a0c8839..8fa06408 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -91,6 +91,13 @@ public static void warning(String msg) { } } + public static void warning(String msg, Throwable throwable) { + Logger logger = CustomLogger.getInstance(); + if (logger != null) { + logger.log(Level.WARNING, msg, throwable); + } + } + public static void severe(Supplier msg) { Logger logger = CustomLogger.getInstance(); if (logger != null) { @@ -104,4 +111,11 @@ public static void severe(String msg) { logger.severe(msg); } } + + public static void severe(String msg, Throwable throwable) { + Logger logger = CustomLogger.getInstance(); + if (logger != null) { + logger.log(Level.SEVERE, msg, throwable); + } + } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java index 8c4f3c08..cc8560ba 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/WorldRegexMatcher.java @@ -50,7 +50,12 @@ public boolean matches(World world, String worldRegex) { Set matches = mWorldPatternMatches.get(world); if (matches == null) { MMLog.warning("Falling back to slow regex .matches() to test world: '" + world.getName() + "' against unregistered regex: '" + worldRegex + "'"); - return world.getName().matches(worldRegex); + try { + return world.getName().matches(worldRegex); + } catch (PatternSyntaxException e) { + MMLog.warning("Invalid world regex '" + worldRegex + "'", e); + return false; + } } return matches.contains(worldRegex); } From a955e105d83fdaf1d5cd697d4d3b720ede994636 Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Sat, 11 Apr 2026 21:45:02 -0700 Subject: [PATCH 02/13] Add new monumenta-common dependency and leverage common MMLog Signed-off-by: Byron Marohn --- build.gradle.kts | 2 +- gradle/libs.versions.toml | 2 + plugin/build.gradle.kts | 3 + .../scriptedquests/CustomLogger.java | 106 ------------- .../playmonumenta/scriptedquests/Plugin.java | 18 +-- .../commands/ChangeLogLevel.java | 31 ---- .../scriptedquests/utils/MMLog.java | 142 +++++++++--------- .../zones/ZoneTreeFactoryTest.java | 3 + 8 files changed, 89 insertions(+), 218 deletions(-) delete mode 100644 plugin/src/main/java/com/playmonumenta/scriptedquests/CustomLogger.java delete mode 100644 plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ChangeLogLevel.java diff --git a/build.gradle.kts b/build.gradle.kts index 01ecc560..dad8364b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,7 @@ monumenta { allprojects { tasks.withType { - options.compilerArgs.add("-Werror") + // options.compilerArgs.add("-Werror") } tasks.withType { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0fdca7d0..e8bc342b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,6 +12,7 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" +monumenta-common = "9cdcc5a-SNAPSHOT" redissync = "6.0.0" [libraries] @@ -29,6 +30,7 @@ jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.re junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" } mockito = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito-junit" } mockbukkit = { module = "com.github.seeseemelk:MockBukkit-v1.20", version.ref = "mockbukkit" } +monumenta-common = { module = "com.playmonumenta:monumenta-common", version.ref = "monumenta-common" } redissync = { module = "com.playmonumenta:redissync", version.ref = "redissync" } [bundles] diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 8e3cca2b..34a43f9e 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,12 +1,15 @@ import org.gradle.api.plugins.quality.Pmd repositories { + mavenLocal() maven("https://repo.mikeprimm.com") } dependencies { implementation(libs.bundles.google.api) + compileOnly(libs.monumenta.common) + testRuntimeOnly(libs.monumenta.common) compileOnly(libs.commandapi) compileOnly(libs.nbtapi) compileOnly(libs.brigadier) diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/CustomLogger.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/CustomLogger.java deleted file mode 100644 index 8aaf79df..00000000 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/CustomLogger.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.playmonumenta.scriptedquests; - -import java.util.function.Supplier; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.jetbrains.annotations.Nullable; - -public class CustomLogger extends Logger { - private static @Nullable CustomLogger INSTANCE = null; - - private Logger mLogger; - private Level mLevel; - - public CustomLogger(Logger logger, Level level) { - super(logger.getName(), logger.getResourceBundleName()); - INSTANCE = this; - mLogger = logger; - mLevel = level; - } - - public static @Nullable CustomLogger getInstance() { - return INSTANCE; - } - - @Override - public void setLevel(Level level) { - mLevel = level; - } - - @Override - public Level getLevel() { - return mLevel; - } - - @Override - public void finest(Supplier msg) { - if (mLevel.equals(Level.FINEST)) { - mLogger.info(msg); - } - } - - @Override - public void finest(String msg) { - if (mLevel.equals(Level.FINEST)) { - mLogger.info(msg); - } - } - - @Override - public void finer(Supplier msg) { - if (mLevel.equals(Level.FINER) || mLevel.equals(Level.FINEST)) { - mLogger.info(msg); - } - } - - @Override - public void finer(String msg) { - if (mLevel.equals(Level.FINER) || mLevel.equals(Level.FINEST)) { - mLogger.info(msg); - } - } - - @Override - public void fine(Supplier msg) { - if (mLevel.equals(Level.FINE) || mLevel.equals(Level.FINER) || mLevel.equals(Level.FINEST)) { - mLogger.info(msg); - } - } - - @Override - public void fine(String msg) { - if (mLevel.equals(Level.FINE) || mLevel.equals(Level.FINER) || mLevel.equals(Level.FINEST)) { - mLogger.info(msg); - } - } - - @Override - public void info(Supplier msg) { - mLogger.info(msg); - } - - @Override - public void info(String msg) { - mLogger.info(msg); - } - - @Override - public void warning(Supplier msg) { - mLogger.warning(msg); - } - - @Override - public void warning(String msg) { - mLogger.warning(msg); - } - - @Override - public void severe(Supplier msg) { - mLogger.severe(msg); - } - - @Override - public void severe(String msg) { - mLogger.severe(msg); - } -} diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java index 969ac6f4..8cb569e3 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java @@ -24,6 +24,7 @@ import com.playmonumenta.scriptedquests.managers.ZonePropertyManager; import com.playmonumenta.scriptedquests.protocollib.ProtocolLibIntegration; import com.playmonumenta.scriptedquests.timers.CommandTimerManager; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.utils.MetadataUtils; import com.playmonumenta.scriptedquests.utils.NmsUtils; import com.playmonumenta.scriptedquests.zones.ZoneManager; @@ -31,8 +32,6 @@ import java.io.File; import java.util.Objects; import java.util.Random; -import java.util.logging.Level; -import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.SoundCategory; import org.bukkit.command.CommandSender; @@ -76,14 +75,11 @@ public class Plugin extends JavaPlugin { public Random mRandom = new Random(); private @MonotonicNonNull ScheduleFunction mScheduledFunctionsManager; - private @MonotonicNonNull CustomLogger mLogger = null; private SoundCategory mDefaultMusicSoundCategory = SoundCategory.RECORDS; @Override public void onLoad() { - if (mLogger == null) { - mLogger = new CustomLogger(super.getLogger(), Level.INFO); - } + MMLog.init(this); NmsUtils.loadVersionAdapter(this.getServer().getClass(), getLogger()); @@ -100,7 +96,6 @@ public void onLoad() { mTranslationsManager = new TranslationsManager(this, translationsConfig); } - ChangeLogLevel.register(); FontUtilsDebug.register(); InteractNpc.register(this); Clickable.register(this); @@ -303,12 +298,11 @@ public static Plugin getInstance() { return INSTANCE; } + /** @deprecated Use {@link com.playmonumenta.scriptedquests.utils.MMLog} static methods instead. */ + @Deprecated @Override - public Logger getLogger() { - if (mLogger == null) { - mLogger = new CustomLogger(super.getLogger(), Level.INFO); - } - return mLogger; + public java.util.logging.Logger getLogger() { + return super.getLogger(); } public SoundCategory getDefaultMusicSoundCategory() { diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ChangeLogLevel.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ChangeLogLevel.java deleted file mode 100644 index 20e5c9a7..00000000 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ChangeLogLevel.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.playmonumenta.scriptedquests.commands; - -import com.playmonumenta.scriptedquests.utils.MMLog; -import dev.jorel.commandapi.CommandAPICommand; -import dev.jorel.commandapi.CommandPermission; -import java.util.logging.Level; - -public class ChangeLogLevel { - public static void register() { - new CommandAPICommand("scriptedquests") - .withSubcommand(new CommandAPICommand("changeloglevel") - .withPermission(CommandPermission.fromString("scriptedquests.changeloglevel")) - .withSubcommand(new CommandAPICommand("INFO") - .executes((sender, args) -> { - MMLog.setLevel(Level.INFO); - })) - .withSubcommand(new CommandAPICommand("FINE") - .executes((sender, args) -> { - MMLog.setLevel(Level.FINE); - })) - .withSubcommand(new CommandAPICommand("FINER") - .executes((sender, args) -> { - MMLog.setLevel(Level.FINER); - })) - .withSubcommand(new CommandAPICommand("FINEST") - .executes((sender, args) -> { - MMLog.setLevel(Level.FINEST); - })) - ).register(); - } -} diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index 8fa06408..88f84b9e 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -1,121 +1,127 @@ package com.playmonumenta.scriptedquests.utils; -import com.playmonumenta.scriptedquests.CustomLogger; import java.util.function.Supplier; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.apache.logging.log4j.Level; +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.Nullable; public class MMLog { - public static void setLevel(Level level) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.setLevel(level); + private static @Nullable com.playmonumenta.common.MMLog INSTANCE = null; + + public static void init(JavaPlugin plugin) { + if (INSTANCE == null) { + INSTANCE = new com.playmonumenta.common.MMLog(plugin, "scriptedquests"); } } - public static boolean isLevelEnabled(Level level) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - return level.intValue() >= logger.getLevel().intValue(); + public static void init(com.playmonumenta.common.MMLog log) { + INSTANCE = log; + } + + private static com.playmonumenta.common.MMLog getLogOrThrow() { + if (INSTANCE == null) { + throw new RuntimeException("ScriptedQuests logger invoked before being initialized!"); } - return true; + return INSTANCE; } + public static void setLevel(Level level) { + getLogOrThrow().setLevel(level); + } + + public static boolean isLevelEnabled(Level level) { + return getLogOrThrow().isLevelEnabled(level); + } + + /** @deprecated Use {@link #trace(Supplier)} instead. */ + @Deprecated public static void finest(Supplier msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.finest(msg); - } + getLogOrThrow().trace(msg); } + /** @deprecated Use {@link #trace(String)} instead. */ + @Deprecated public static void finest(String msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.finest(msg); - } + getLogOrThrow().trace(msg); } + /** @deprecated Use {@link #trace(Supplier)} instead. */ + @Deprecated public static void finer(Supplier msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.finer(msg); - } + getLogOrThrow().trace(msg); } + /** @deprecated Use {@link #trace(String)} instead. */ + @Deprecated public static void finer(String msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.finer(msg); - } + getLogOrThrow().trace(msg); } + /** @deprecated Use {@link #debug(Supplier)} instead. */ + @Deprecated public static void fine(Supplier msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.fine(msg); - } + getLogOrThrow().debug(msg); } + /** @deprecated Use {@link #debug(String)} instead. */ + @Deprecated public static void fine(String msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.fine(msg); - } + getLogOrThrow().debug(msg); + } + + public static void trace(Supplier msg) { + getLogOrThrow().trace(msg); + } + + public static void trace(String msg) { + getLogOrThrow().trace(msg); + } + + public static void trace(String msg, Throwable throwable) { + getLogOrThrow().trace(msg, throwable); + } + + public static void debug(Supplier msg) { + getLogOrThrow().debug(msg); + } + + public static void debug(String msg) { + getLogOrThrow().debug(msg); + } + + public static void debug(String msg, Throwable throwable) { + getLogOrThrow().debug(msg, throwable); } public static void info(String msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.info(msg); - } + getLogOrThrow().info(msg); } public static void info(Supplier msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.info(msg); - } + getLogOrThrow().info(msg); } public static void warning(Supplier msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.warning(msg); - } + getLogOrThrow().warning(msg); } public static void warning(String msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.warning(msg); - } + getLogOrThrow().warning(msg); } public static void warning(String msg, Throwable throwable) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.log(Level.WARNING, msg, throwable); - } + getLogOrThrow().warning(msg, throwable); } public static void severe(Supplier msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.severe(msg); - } + getLogOrThrow().severe(msg); } public static void severe(String msg) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.severe(msg); - } + getLogOrThrow().severe(msg); } public static void severe(String msg, Throwable throwable) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.log(Level.SEVERE, msg, throwable); - } + getLogOrThrow().severe(msg, throwable); } } diff --git a/plugin/src/test/java/com/playmonumenta/scriptedquests/zones/ZoneTreeFactoryTest.java b/plugin/src/test/java/com/playmonumenta/scriptedquests/zones/ZoneTreeFactoryTest.java index c80a3532..a02e573a 100644 --- a/plugin/src/test/java/com/playmonumenta/scriptedquests/zones/ZoneTreeFactoryTest.java +++ b/plugin/src/test/java/com/playmonumenta/scriptedquests/zones/ZoneTreeFactoryTest.java @@ -1,6 +1,7 @@ package com.playmonumenta.scriptedquests.zones; import com.playmonumenta.scriptedquests.Plugin; +import com.playmonumenta.scriptedquests.utils.MMLog; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -55,6 +56,8 @@ public static void setUp() throws Exception { mockedStaticZoneNamespace = Mockito.mockStatic(ZoneNamespace.class); + MMLog.init(Mockito.mock(com.playmonumenta.common.MMLog.class)); + Field instance = Plugin.class.getDeclaredField("INSTANCE"); instance.setAccessible(true); Plugin plugin = Mockito.mock(Plugin.class); From 08deeba7a1f303a650dac2b4da8123f802049ecb Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Sat, 11 Apr 2026 22:11:07 -0700 Subject: [PATCH 03/13] Refactor logging everywhere to use MMLog Signed-off-by: Byron Marohn --- build.gradle.kts | 2 +- .../api/ClientChatProtocol.java | 7 ++-- .../scriptedquests/commands/Leaderboard.java | 4 +-- .../commands/ScheduleFunction.java | 5 ++- .../scriptedquests/managers/GuiManager.java | 2 +- .../managers/NpcTradeManager.java | 2 +- .../scriptedquests/managers/RaceManager.java | 11 +++--- .../managers/TranslationsManager.java | 24 ++++++------- .../protocollib/ProtocolLibIntegration.java | 3 +- .../SelectiveNPCVisibilityHandler.java | 3 +- .../scriptedquests/quests/ZoneProperty.java | 3 +- .../components/actions/ActionCommand.java | 6 ++-- .../components/actions/ActionInteractNpc.java | 4 +-- .../actions/ActionRerunComponents.java | 3 +- .../scriptedquests/races/Race.java | 7 ++-- .../scriptedquests/races/RaceFactory.java | 4 +-- .../scriptedquests/timers/CommandTimer.java | 7 ++-- .../timers/CommandTimerInstance.java | 16 ++++----- .../timers/CommandTimerManager.java | 8 ++--- .../scriptedquests/utils/MMLog.java | 36 ------------------- .../scriptedquests/utils/NmsUtils.java | 7 ++-- .../scriptedquests/utils/QuestUtils.java | 5 ++- .../scriptedquests/zones/ZoneManager.java | 6 ++-- 23 files changed, 71 insertions(+), 104 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index dad8364b..01ecc560 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,7 @@ monumenta { allprojects { tasks.withType { - // options.compilerArgs.add("-Werror") + options.compilerArgs.add("-Werror") } tasks.withType { diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/api/ClientChatProtocol.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/api/ClientChatProtocol.java index dbcf224a..646eaf4b 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/api/ClientChatProtocol.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/api/ClientChatProtocol.java @@ -10,6 +10,7 @@ import com.playmonumenta.scriptedquests.Plugin; import com.playmonumenta.scriptedquests.quests.QuestContext; import com.playmonumenta.scriptedquests.quests.components.QuestComponent; +import com.playmonumenta.scriptedquests.utils.MMLog; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.HashSet; @@ -59,7 +60,7 @@ private static void sendJson(Player player, JsonObject object) { out.write(GSON.toJson(object)); player.sendPluginMessage(Plugin.getInstance(), Constants.API_CHANNEL_ID, stream.toByteArray()); } catch (Exception e) { - e.printStackTrace(); + MMLog.warning("Failed to send plugin message to player", e); } } @@ -105,7 +106,7 @@ public void onPluginMessageReceived(String s, Player player, byte[] bytes) { break; // Silently ignore other type requests } } catch (Exception e) { - e.printStackTrace(); + MMLog.warning("Failed to handle incoming plugin message from player", e); } } @@ -119,7 +120,7 @@ public static boolean shouldSend(Player p) { @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { mOverride = !mOverride; - Plugin.getInstance().getLogger().info("Should always send custom data to player: " + mOverride); + MMLog.info("Should always send custom data to player: " + mOverride); return true; } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/Leaderboard.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/Leaderboard.java index 3be483aa..501a4de4 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/Leaderboard.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/Leaderboard.java @@ -3,6 +3,7 @@ import com.playmonumenta.redissync.LeaderboardAPI; import com.playmonumenta.scriptedquests.utils.LeaderboardUtils; import com.playmonumenta.scriptedquests.utils.LeaderboardUtils.LeaderboardEntry; +import com.playmonumenta.scriptedquests.utils.MMLog; import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPICommand; import dev.jorel.commandapi.CommandPermission; @@ -175,8 +176,7 @@ public static void leaderboard(Plugin plugin, Player player, String objective, b Bukkit.getScheduler().runTask(plugin, () -> LeaderboardUtils.sendLeaderboard(player, displayName, entries, page, "/leaderboard " + player.getName() + " " + objective + (descending ? " true" : " false"))); } catch (Exception ex) { - plugin.getLogger().severe("Failed to generate leaderboard: " + ex.getMessage()); - ex.printStackTrace(); + MMLog.severe("Failed to generate leaderboard", ex); } }); } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ScheduleFunction.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ScheduleFunction.java index 697fd8d6..b1b890f5 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ScheduleFunction.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/commands/ScheduleFunction.java @@ -206,7 +206,7 @@ public void run() { } } } - mPlugin.getLogger().fine("Preparing to run " + entry); + MMLog.debug("Preparing to run " + entry); it.remove(); } @@ -229,8 +229,7 @@ public ScheduleFunction(Plugin plugin) { try { CommandAPI.unregister("schedule"); } catch (Exception e) { - // Nothing to do here - there is nothing to unregister in 1.13 - plugin.getLogger().info("Failed to unregister /schedule - this is only an error in 1.14+"); + MMLog.severe("Failed to unregister /schedule", e); } FunctionArgument functionArg = new FunctionArgument("function"); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/GuiManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/GuiManager.java index 584e88d1..5217ee6a 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/GuiManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/GuiManager.java @@ -198,7 +198,7 @@ protected void inventoryClose(InventoryCloseEvent event) { try { GuiPage updated = page.createUpdated(getInventory()); mGui.setPage(mPageName, updated); - QuestUtils.save(Plugin.getInstance(), event.getPlayer(), mGui.toJson(), mGui.getFile()); + QuestUtils.save(event.getPlayer(), mGui.toJson(), mGui.getFile()); event.getPlayer().sendMessage(Component.text("GUI updated.", NamedTextColor.GOLD)); } catch (Exception e) { event.getPlayer().sendMessage(Component.text("Failed to update GUI.", NamedTextColor.RED)); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/NpcTradeManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/NpcTradeManager.java index 79e464ab..1551e3d6 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/NpcTradeManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/NpcTradeManager.java @@ -604,7 +604,7 @@ protected void inventoryClick(InventoryClickEvent event) { @Override protected void inventoryClose(InventoryCloseEvent event) { try { - QuestUtils.save(Plugin.getInstance(), event.getPlayer(), mTrader.toJson(), mTrader.getFile()); + QuestUtils.save(event.getPlayer(), mTrader.toJson(), mTrader.getFile()); event.getPlayer().sendMessage(Component.text("Trade file updated.", NamedTextColor.GOLD)); } catch (Exception e) { event.getPlayer().sendMessage(Component.text("Failed to update trade file.", NamedTextColor.RED)); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/RaceManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/RaceManager.java index ee8006ce..bfca046d 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/RaceManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/RaceManager.java @@ -5,6 +5,7 @@ import com.playmonumenta.scriptedquests.Plugin; import com.playmonumenta.scriptedquests.races.Race; import com.playmonumenta.scriptedquests.races.RaceFactory; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.utils.QuestUtils; import java.util.ArrayList; import java.util.HashMap; @@ -92,12 +93,12 @@ public void removeIfNotActive(Entity entity) { try { ownerId = UUID.fromString(tag.substring(ARMOR_STAND_ID_PREFIX_TAG.length())); } catch (Exception e) { - mPlugin.getLogger().warning("Invalid Race ID tag on ring: " + tag); + MMLog.warning("Invalid Race ID tag on ring: " + tag); } } } if (ownerId != null && !isRacing(ownerId)) { - mPlugin.getLogger().fine("Removing stale race ring armor stand."); + MMLog.debug("Removing stale race ring armor stand."); entity.remove(); } } @@ -211,8 +212,8 @@ public void removeRace(Player player) { public void startRace(Player player, String raceLabel) { if (mActiveRaces.containsKey(player.getUniqueId())) { - mPlugin.getLogger().severe("Attempted to start second race '" + raceLabel + - "' for player '" + player.getName() + "'"); + MMLog.severe("Attempted to start second race '" + raceLabel + + "' for player '" + player.getName() + "'"); player.sendMessage(Component.text("You are already in a race!", NamedTextColor.RED)); return; } @@ -222,7 +223,7 @@ public void startRace(Player player, String raceLabel) { RaceFactory raceFactory = mRaceFactories.get(raceLabel); if (raceFactory == null) { - mPlugin.getLogger().severe("Attempted to start nonexistent race '" + raceLabel + "'"); + MMLog.severe("Attempted to start nonexistent race '" + raceLabel + "'"); return; } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/TranslationsManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/TranslationsManager.java index 860a55ed..03351261 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/TranslationsManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/managers/TranslationsManager.java @@ -14,6 +14,7 @@ import com.google.gson.JsonElement; import com.playmonumenta.scriptedquests.Plugin; import com.playmonumenta.scriptedquests.utils.FileUtils; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.utils.MessagingUtils; import com.playmonumenta.scriptedquests.utils.QuestUtils; import dev.jorel.commandapi.CommandAPICommand; @@ -202,13 +203,13 @@ public static void reload(@Nullable CommandSender sender) { if (INSTANCE.mWriting || INSTANCE.mReading) { /* Only allow one read/write task at a time. Better to lose translations than cause problems here */ - INSTANCE.mPlugin.getLogger().info("Read was cancelled by existing read/write task"); + MMLog.info("Read was cancelled by existing read/write task"); return; } if (INSTANCE.mWriteAndReloadRunnable != null && !INSTANCE.mWriteAndReloadRunnable.isCancelled()) { /* This will overwrite the data that would be written - so cancel the pending write task */ - INSTANCE.mPlugin.getLogger().info("Write was cancelled by new reload"); + MMLog.info("Write was cancelled by new reload"); INSTANCE.mWriteAndReloadRunnable.cancel(); INSTANCE.mWriteAndReloadRunnable = null; } @@ -298,7 +299,7 @@ private void addNewEntry(String message) { // update the loaded translation map mTranslationsMap.put(message, translations); - mPlugin.getLogger().info("Added new entry for translations: " + message); + MMLog.info("Added new entry for translations: " + message); writeTranslationFileAndReloadShards(); } @@ -323,7 +324,7 @@ public void run() { if (mReading) { /* Whatever was going to be written is being overwritten by read anyway, so cancel the write */ - mPlugin.getLogger().info("Write was cancelled by pending read"); + MMLog.info("Write was cancelled by pending read"); this.cancel(); mWriteAndReloadRunnable = null; return; @@ -334,7 +335,7 @@ public void run() { * Only allow one write task at a time. Better to lose translations than cause problems here. * This will try again next time it ticks until writing is complete */ - mPlugin.getLogger().info("Write was blocked by existing ongoing write, waiting a tick"); + MMLog.info("Write was blocked by existing ongoing write, waiting a tick"); return; } @@ -353,8 +354,7 @@ public void run() { try { FileUtils.writeFile(filename, content); } catch (IOException e) { - mPlugin.getLogger().severe("Caught error writing translations: " + e.getMessage()); - e.printStackTrace(); + MMLog.severe("Caught error writing translations", e); } // reload the translations on all shards @@ -448,7 +448,7 @@ private void syncTranslationSheet(CommandSender sender) { StandardCopyOption.REPLACE_EXISTING); } catch (Exception e) { MessagingUtils.sendMessageSync(sender, "Failed to backup translations.json database: " + e.getMessage()); - e.printStackTrace(); + MMLog.severe("Failed to backup translations.json database", e); return; } @@ -463,7 +463,7 @@ private void syncTranslationSheet(CommandSender sender) { gSheet = new TranslationGSheet(mGSheetConfig); } catch (Exception e) { MessagingUtils.sendMessageSync(sender, "Failed initialize Google Sheets: " + e.getMessage()); - e.printStackTrace(); + MMLog.severe("Failed to initialize Google Sheets", e); return; } @@ -474,7 +474,7 @@ private void syncTranslationSheet(CommandSender sender) { MessagingUtils.sendMessageSync(sender, "Received " + rows.size() + " rows from the GSheet"); } catch (IOException e) { MessagingUtils.sendMessageSync(sender, "Failed to read values from sheet. Abort. error: " + e.getMessage()); - e.printStackTrace(); + MMLog.severe("Failed to read values from Google Sheet", e); return; } @@ -498,7 +498,7 @@ private void syncTranslationSheet(CommandSender sender) { MessagingUtils.sendMessageSync(sender, "Done! written " + response.getUpdatedRows() + " rows"); } catch (IOException e) { MessagingUtils.sendMessageSync(sender, "Failed to write values into sheet. error: " + e.getMessage()); - e.printStackTrace(); + MMLog.severe("Failed to write values to Google Sheet", e); } }); }); @@ -589,7 +589,7 @@ private void readDataRow(List row, Map indexToLanguageM if (status.equals("DEL")) { // line is notified as to be deleted from the system. - mPlugin.getLogger().info("removing entry :" + message); + MMLog.info("removing entry :" + message); mTranslationsMap.remove(message); return; } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/ProtocolLibIntegration.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/ProtocolLibIntegration.java index 82803eb3..7c624775 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/ProtocolLibIntegration.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/ProtocolLibIntegration.java @@ -3,13 +3,14 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; import com.playmonumenta.scriptedquests.Plugin; +import com.playmonumenta.scriptedquests.utils.MMLog; public class ProtocolLibIntegration { private final SelectiveNPCVisibilityHandler mSelectiveNPCVisibilityHandler; public ProtocolLibIntegration(Plugin plugin) { - plugin.getLogger().info("Enabling ProtocolLib integration"); + MMLog.info("Enabling ProtocolLib integration"); ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/SelectiveNPCVisibilityHandler.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/SelectiveNPCVisibilityHandler.java index 1ddeff2c..77cceeca 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/SelectiveNPCVisibilityHandler.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/protocollib/SelectiveNPCVisibilityHandler.java @@ -12,6 +12,7 @@ import com.playmonumenta.scriptedquests.quests.QuestContext; import com.playmonumenta.scriptedquests.quests.QuestNpc; import com.playmonumenta.scriptedquests.races.RaceFactory; +import com.playmonumenta.scriptedquests.utils.MMLog; import java.lang.reflect.InvocationTargetException; import java.util.EnumSet; import java.util.HashMap; @@ -257,7 +258,7 @@ private void sendEntityDestroyPacket(Entity entity, Player player) { try { mProtocolManager.sendServerPacket(player, packet, false); } catch (InvocationTargetException e) { - e.printStackTrace(); + MMLog.warning("Failed to send packet to player", e); } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/ZoneProperty.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/ZoneProperty.java index cbc2da3d..6fe57615 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/ZoneProperty.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/ZoneProperty.java @@ -6,6 +6,7 @@ import com.playmonumenta.scriptedquests.Plugin; import com.playmonumenta.scriptedquests.quests.components.QuestComponent; import com.playmonumenta.scriptedquests.quests.components.QuestComponentList; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.zones.event.ZoneBlockBreakEvent; import com.playmonumenta.scriptedquests.zones.event.ZoneBlockInteractEvent; import com.playmonumenta.scriptedquests.zones.event.ZoneEntityDeathEvent; @@ -130,7 +131,7 @@ public ZoneProperty(JsonObject object) throws Exception { public void addFromOther(Plugin plugin, ZoneProperty other) { if (!mNamespaceName.equals(other.mNamespaceName) || !mName.equals(other.mName)) { - plugin.getLogger().severe("Attempted to add two ZoneProperty objects of different properties!"); + MMLog.severe("Attempted to add two ZoneProperty objects of different properties!"); return; } for (QuestComponent component : other.getComponents()) { diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionCommand.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionCommand.java index 5d854fdc..add3c248 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionCommand.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionCommand.java @@ -23,14 +23,14 @@ public ActionCommand(JsonElement element) throws Exception { mCommand = mCommand.substring(1); } - MMLog.finer("Parsing ActionCommand '" + mCommand + "'"); + MMLog.trace("Parsing ActionCommand '" + mCommand + "'"); String commandToTest = mCommand.replaceAll("@S", "dummy").replaceAll("@N", "00000000-0000-0000-0000-000000000000").replaceAll("@U", "00000000-0000-0000-0000-000000000000"); - MMLog.finer("Testing ActionCommand with substitutions '" + commandToTest + "'"); + MMLog.trace("Testing ActionCommand with substitutions '" + commandToTest + "'"); ParseResults pr = NmsUtils.getVersionAdapter().parseCommand(commandToTest); if (pr != null && pr.getReader().canRead()) { throw new Exception("Invalid command: '" + mCommand + "'"); } - MMLog.fine("Successfully parsed ActionCommand '" + mCommand + "'"); + MMLog.debug("Successfully parsed ActionCommand '" + mCommand + "'"); } @Override diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionInteractNpc.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionInteractNpc.java index ca23dc15..b5483eeb 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionInteractNpc.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionInteractNpc.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.playmonumenta.scriptedquests.quests.QuestContext; +import com.playmonumenta.scriptedquests.utils.MMLog; import java.util.Map.Entry; import java.util.Set; import org.bukkit.entity.EntityType; @@ -48,8 +49,7 @@ public ActionInteractNpc(JsonElement element) throws Exception { @Override public void doActions(QuestContext context) { if (!context.getPlugin().mNpcManager.interactEvent(context.clearPrerequisites().withNpc(null), mName, mType, true)) { - context.getPlugin().getLogger().severe("No interaction available for player '" + context.getPlayer().getName() + - "' and NPC '" + mName + "'"); + MMLog.severe("No interaction available for player '" + context.getPlayer().getName() + "' and NPC '" + mName + "'"); } } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionRerunComponents.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionRerunComponents.java index b166fbf8..31470081 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionRerunComponents.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/quests/components/actions/ActionRerunComponents.java @@ -1,6 +1,7 @@ package com.playmonumenta.scriptedquests.quests.components.actions; import com.playmonumenta.scriptedquests.quests.QuestContext; +import com.playmonumenta.scriptedquests.utils.MMLog; import java.util.ArrayList; import java.util.List; import org.bukkit.entity.EntityType; @@ -32,7 +33,7 @@ public void doActions(QuestContext context) { mLocked.remove(context.getPlayer()); } } else { - context.getPlugin().getLogger().severe("Stopped infinite loop for NPC '" + mNpcName + "'"); + MMLog.severe("Stopped infinite loop for NPC '" + mNpcName + "'"); } } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/races/Race.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/races/Race.java index 6708d4ac..0aa9a5fe 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/races/Race.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/races/Race.java @@ -8,6 +8,7 @@ import com.playmonumenta.scriptedquests.managers.RaceManager; import com.playmonumenta.scriptedquests.quests.QuestContext; import com.playmonumenta.scriptedquests.quests.components.QuestActions; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.utils.RaceUtils; import java.time.Duration; import java.util.ArrayDeque; @@ -631,8 +632,7 @@ public int getPlayerPosition(Player mPlayer, Objective lb) { position++; } } catch (Exception ex) { - mPlugin.getLogger().severe("Failed to get player position on leaderboard " + lb.getName() + ": " + ex.getMessage()); - ex.printStackTrace(); + MMLog.severe("Failed to get player position on leaderboard " + lb.getName(), ex); } } else { List sortedEntries = new ArrayList<>(lb.getScoreboard().getEntries()); @@ -670,8 +670,7 @@ private void updateWorldRecord(Objective objective, boolean isSpeedWR) { } } } catch (Exception ex) { - mPlugin.getLogger().severe("Failed to get world record time for leaderboard " + objective.getName() + ": " + ex.getMessage()); - ex.printStackTrace(); + MMLog.severe("Failed to get world record time for leaderboard " + objective.getName(), ex); } }); } else { diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/races/RaceFactory.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/races/RaceFactory.java index 91658f07..e37847b9 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/races/RaceFactory.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/races/RaceFactory.java @@ -9,6 +9,7 @@ import com.playmonumenta.scriptedquests.quests.components.QuestActions; import com.playmonumenta.scriptedquests.utils.LeaderboardUtils; import com.playmonumenta.scriptedquests.utils.LeaderboardUtils.LeaderboardEntry; +import com.playmonumenta.scriptedquests.utils.MMLog; import com.playmonumenta.scriptedquests.utils.RaceUtils; import java.util.ArrayList; import java.util.Collections; @@ -305,8 +306,7 @@ public void sendLeaderboard(Player player, int page) { Bukkit.getScheduler().runTask(mPlugin, () -> LeaderboardUtils.sendLeaderboard(player, Component.text(mName), entries, page, "/race leaderboard " + player.getName() + " " + mLabel)); } catch (Exception ex) { - mPlugin.getLogger().severe("Failed to generate leaderboard: " + ex.getMessage()); - ex.printStackTrace(); + MMLog.severe("Failed to generate leaderboard", ex); } }); } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimer.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimer.java index ef8f5904..72ae9876 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimer.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimer.java @@ -1,6 +1,7 @@ package com.playmonumenta.scriptedquests.timers; import com.playmonumenta.scriptedquests.Plugin; +import com.playmonumenta.scriptedquests.utils.MMLog; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; @@ -103,7 +104,7 @@ public void unloadAndAbort() { public void addEntity(final ArmorStand entity, final Set tags) { /* This should never happen */ if (mTimers.get(entity.getUniqueId()) != null) { - mPlugin.getLogger().warning("processEntity: Attempted to add timer entity that was already tracked!"); + MMLog.warning("processEntity: Attempted to add timer entity that was already tracked!"); return; } @@ -144,7 +145,7 @@ private boolean tryAddTimer(final ArmorStand entity, final Set tags, fin } else { entity.setCustomNameVisible(true); entity.customName(Component.text("Timer: INVALID BLOCK", NamedTextColor.RED).decorate(TextDecoration.BOLD)); - mPlugin.getLogger().warning("Timer is missing repeating command block at " + loc.toString()); + MMLog.warning("Timer is missing repeating command block at " + loc.toString()); return false; } } else { @@ -153,7 +154,7 @@ private boolean tryAddTimer(final ArmorStand entity, final Set tags, fin } else { entity.setCustomNameVisible(true); entity.customName(Component.text("Timer: INVALID BLOCK", NamedTextColor.RED).decorate(TextDecoration.BOLD)); - mPlugin.getLogger().warning("Timer is missing impulse command block at " + loc.toString()); + MMLog.warning("Timer is missing impulse command block at " + loc.toString()); return false; } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerInstance.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerInstance.java index 5d9386fe..57fcbcd3 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerInstance.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerInstance.java @@ -32,7 +32,7 @@ public class CommandTimerInstance { private boolean mRepeaterEnabled = true; public CommandTimerInstance(Location loc, TimerCoords coords, String periodStr, int playerRange, boolean playerOnline, boolean repeat) { - MMLog.finer("Adding new timer with coords=" + coords + " period=" + periodStr + " range=" + playerRange + " playerOnline=" + playerOnline + " repeat=" + repeat); + MMLog.trace("Adding new timer with coords=" + coords + " period=" + periodStr + " range=" + playerRange + " playerOnline=" + playerOnline + " repeat=" + repeat); mLoc = loc; mCoords = coords; mPeriodStr = periodStr; @@ -60,21 +60,21 @@ public boolean canRun() { public void tick(Plugin plugin) { if (canRun()) { - setAutoState(plugin, mLoc, false); - setAutoState(plugin, mLoc, true); + setAutoState(mLoc, false); + setAutoState(mLoc, true); mRepeaterEnabled = true; } else if (mRepeat && mRepeaterEnabled) { /* Turn repeaters back off again when player is out of range */ - setAutoState(plugin, mLoc, false); + setAutoState(mLoc, false); mRepeaterEnabled = false; } } public void unload(Plugin plugin) { - MMLog.finer("Unloading timer at " + mLoc); + MMLog.trace("Unloading timer at " + mLoc); if (mRepeat && mRepeaterEnabled) { /* Turn repeaters back off when unloading timer */ - setAutoState(plugin, mLoc, false); + setAutoState(mLoc, false); mRepeaterEnabled = false; } } @@ -119,13 +119,13 @@ public TimerCoords getCoords() { return mCoords; } - private static void setAutoState(Plugin plugin, Location loc, boolean auto) { + private static void setAutoState(Location loc, boolean auto) { Block block = loc.getBlock(); BlockState state = block.getState(); if (state instanceof CommandBlock commandBlock) { NmsUtils.getVersionAdapter().setAutoState(commandBlock, auto); } else { - plugin.getLogger().severe("Command block is missing for timer at " + loc.toString()); + MMLog.severe("Command block is missing for timer at " + loc.toString()); } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerManager.java index e0ff5e6f..cba2f615 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/timers/CommandTimerManager.java @@ -67,7 +67,7 @@ public void entityRemoveFromWorldEvent(EntityRemoveFromWorldEvent event) { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void worldUnloadEvent(WorldUnloadEvent event) { - MMLog.fine("Unloading all command timers in unloading world '" + event.getWorld().getName() + '"'); + MMLog.debug("Unloading all command timers in unloading world '" + event.getWorld().getName() + '"'); for (CommandTimer timer : mCommandTimers.values()) { timer.unloadAllInWorld(event.getWorld()); } @@ -86,7 +86,7 @@ public void unload(Entity entity) { CommandTimer timer = mCommandTimers.get(period); if (timer == null) { /* Out of range */ - mPlugin.getLogger().severe("Attempted to remove timer armor stand with non-tracked period " + period.toString()); + MMLog.severe("Attempted to remove timer armor stand with non-tracked period " + period.toString()); return; } timer.unload(entity); @@ -129,12 +129,12 @@ private void processEntity(Entity entity) { try { period = Integer.parseInt(tag.substring(7)); } catch (Exception e) { - mPlugin.getLogger().severe("Timer armor stand has invalid period '" + tag + "' at " + entity.getLocation().toString()); + MMLog.severe("Timer armor stand has invalid period '" + tag + "' at " + entity.getLocation().toString()); return null; } if (period == null || period <= 0 || period > 72000) { /* Out of range */ - mPlugin.getLogger().severe("Timer armor stand has invalid period '" + tag + "' at " + entity.getLocation().toString()); + MMLog.severe("Timer armor stand has invalid period '" + tag + "' at " + entity.getLocation().toString()); return null; } /* Good value - return it */ diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index 88f84b9e..48e3cc90 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -33,42 +33,6 @@ public static boolean isLevelEnabled(Level level) { return getLogOrThrow().isLevelEnabled(level); } - /** @deprecated Use {@link #trace(Supplier)} instead. */ - @Deprecated - public static void finest(Supplier msg) { - getLogOrThrow().trace(msg); - } - - /** @deprecated Use {@link #trace(String)} instead. */ - @Deprecated - public static void finest(String msg) { - getLogOrThrow().trace(msg); - } - - /** @deprecated Use {@link #trace(Supplier)} instead. */ - @Deprecated - public static void finer(Supplier msg) { - getLogOrThrow().trace(msg); - } - - /** @deprecated Use {@link #trace(String)} instead. */ - @Deprecated - public static void finer(String msg) { - getLogOrThrow().trace(msg); - } - - /** @deprecated Use {@link #debug(Supplier)} instead. */ - @Deprecated - public static void fine(Supplier msg) { - getLogOrThrow().debug(msg); - } - - /** @deprecated Use {@link #debug(String)} instead. */ - @Deprecated - public static void fine(String msg) { - getLogOrThrow().debug(msg); - } - public static void trace(Supplier msg) { getLogOrThrow().trace(msg); } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java index 51e31f81..0eb57380 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java @@ -2,6 +2,7 @@ import com.playmonumenta.scriptedquests.adapters.VersionAdapter; import com.playmonumenta.scriptedquests.adapters.VersionAdapter_unsupported; +import java.util.logging.Level; import java.util.logging.Logger; public class NmsUtils { @@ -27,8 +28,7 @@ public static void loadVersionAdapter(Class serverClass, Logger logger) { logger.severe("Somehow VersionAdapter is not assignable from " + clazz + ". NMS utilities will fail and throw NullPointerException's"); } } catch (Exception e) { - e.printStackTrace(); - logger.severe("Server version " + version + " is not supported!"); + logger.log(Level.SEVERE, "Server version " + version + " is not supported!", e); logger.severe("Everything that relies on version-specific 'NMS' logic will behave incorrectly"); try { Class clazz = Class.forName("com.playmonumenta.scriptedquests.adapters.VersionAdapter_unsupported"); @@ -38,8 +38,7 @@ public static void loadVersionAdapter(Class serverClass, Logger logger) { } logger.severe("Loaded 'unsupported' version adapter, which should at least reduce the number of null pointer exceptions"); } catch (Exception ex) { - ex.printStackTrace(); - logger.severe("Also failed to load generic unsupported adapter. There will be many null pointer exceptions."); + logger.log(Level.SEVERE, "Also failed to load generic unsupported adapter. There will be many null pointer exceptions.", ex); } } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java index 9881ed68..fa3b2de2 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java @@ -128,14 +128,13 @@ public static void loadScriptedQuests(Plugin plugin, String folderName, @Nullabl return action.load(object, file); } - public static void save(Plugin plugin, @Nullable CommandSender sender, JsonObject object, File file) { + public static void save(@Nullable CommandSender sender, JsonObject object, File file) { try { Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(object); FileUtils.writeFile(file.getPath(), json); } catch (Exception e) { - plugin.getLogger().severe("Caught exception: " + e); - e.printStackTrace(); + MMLog.severe("Failed to save quest file '" + file.getPath() + "'", e); if (sender != null) { sender.sendMessage(Component.text("Failed to save quest file '" + file.getPath() + "'", NamedTextColor.RED)); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/zones/ZoneManager.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/zones/ZoneManager.java index 80be11ca..b92ec8eb 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/zones/ZoneManager.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/zones/ZoneManager.java @@ -322,7 +322,7 @@ public void doReload(Plugin plugin) { } public void doReload(Plugin plugin, boolean firstRun) { - MMLog.fine("[Zone Reload] Begin"); + MMLog.debug("[Zone Reload] Begin"); mQueuedReloadRequesters.add(Bukkit.getConsoleSender()); mReloadRequesters = Audience.audience(mQueuedReloadRequesters); mQueuedReloadRequesters = new HashSet<>(); @@ -330,7 +330,7 @@ public void doReload(Plugin plugin, boolean firstRun) { long cpuNanos = System.nanoTime(); mReloadingState = new ZoneState(); ZoneNamespace.clearDynmapLayers(); - MMLog.fine("[Zone Reload] " + String.format("%13.9f", (System.nanoTime() - cpuNanos) / 1000000000.0) + "s Resetting old data"); + MMLog.debug("[Zone Reload] " + String.format("%13.9f", (System.nanoTime() - cpuNanos) / 1000000000.0) + "s Resetting old data"); cpuNanos = System.nanoTime(); plugin.mZonePropertyGroupManager.reload(plugin, mReloadRequesters); @@ -345,7 +345,7 @@ public void doReload(Plugin plugin, boolean firstRun) { mReloadingState.mNamespaces.putAll(mPluginNamespaces); mReloadingState.mNamespaces.putAll( new ZonesReferenceResolver(plugin, mReloadRequesters, mReloadingState.mNamespaces.keySet()).resolve()); - MMLog.fine("[Zone Reload] " + String.format("%13.9f", (System.nanoTime() - cpuNanos) / 1000000000.0) + "s Loading new data"); + MMLog.debug("[Zone Reload] " + String.format("%13.9f", (System.nanoTime() - cpuNanos) / 1000000000.0) + "s Loading new data"); final Set worldRegexes = new HashSet<>(); for (ZoneNamespace zoneNamespace : mReloadingState.mNamespaces.values()) { From 38720e22167e28fe827ddbb7c0e187ad4ad8c875 Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Sun, 12 Apr 2026 21:41:36 -0700 Subject: [PATCH 04/13] Refactor common plugin usage now that it also supports velocity Signed-off-by: Byron Marohn --- gradle/libs.versions.toml | 4 +++- plugin/build.gradle.kts | 5 +++++ .../main/java/com/playmonumenta/scriptedquests/Plugin.java | 2 +- .../java/com/playmonumenta/scriptedquests/utils/MMLog.java | 6 +++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e8bc342b..ea1d8637 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,8 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" -monumenta-common = "9cdcc5a-SNAPSHOT" +monumenta-common = "95e3b80-SNAPSHOT" +velocity = "3.3.0-SNAPSHOT" redissync = "6.0.0" [libraries] @@ -31,6 +32,7 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher mockito = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito-junit" } mockbukkit = { module = "com.github.seeseemelk:MockBukkit-v1.20", version.ref = "mockbukkit" } monumenta-common = { module = "com.playmonumenta:monumenta-common", version.ref = "monumenta-common" } +velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } redissync = { module = "com.playmonumenta:redissync", version.ref = "redissync" } [bundles] diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 34a43f9e..c8b21ce3 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -10,6 +10,11 @@ dependencies { compileOnly(libs.monumenta.common) testRuntimeOnly(libs.monumenta.common) + // monumenta-common's MMLog class references Velocity API types. Those types are resolved + // lazily at runtime (registerVelocityCommand() is never called on Paper), but the test + // class loader loads them eagerly. Add the Velocity API to the test classpath so that + // class loading succeeds, even though scripted-quests itself has no Velocity interaction. + testRuntimeOnly(libs.velocity) compileOnly(libs.commandapi) compileOnly(libs.nbtapi) compileOnly(libs.brigadier) diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java index 8cb569e3..d8b65570 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java @@ -79,7 +79,7 @@ public class Plugin extends JavaPlugin { @Override public void onLoad() { - MMLog.init(this); + MMLog.init(); NmsUtils.loadVersionAdapter(this.getServer().getClass(), getLogger()); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index 48e3cc90..e0056652 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -2,15 +2,15 @@ import java.util.function.Supplier; import org.apache.logging.log4j.Level; -import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.Nullable; public class MMLog { private static @Nullable com.playmonumenta.common.MMLog INSTANCE = null; - public static void init(JavaPlugin plugin) { + public static void init() { if (INSTANCE == null) { - INSTANCE = new com.playmonumenta.common.MMLog(plugin, "scriptedquests"); + INSTANCE = new com.playmonumenta.common.MMLog("ScriptedQuests"); + INSTANCE.registerPaperCommand("scriptedquests"); } } From b605fc38cc3a425b2ff35b3fba6351e83613902a Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Mon, 13 Apr 2026 10:03:44 -0700 Subject: [PATCH 05/13] Update common, minor tweak Signed-off-by: Byron Marohn --- gradle/libs.versions.toml | 2 +- .../main/java/com/playmonumenta/scriptedquests/utils/MMLog.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ea1d8637..32f10012 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,7 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" -monumenta-common = "95e3b80-SNAPSHOT" +monumenta-common = "f231e8a-SNAPSHOT" velocity = "3.3.0-SNAPSHOT" redissync = "6.0.0" diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index e0056652..f2a2ede9 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -10,7 +10,7 @@ public class MMLog { public static void init() { if (INSTANCE == null) { INSTANCE = new com.playmonumenta.common.MMLog("ScriptedQuests"); - INSTANCE.registerPaperCommand("scriptedquests"); + INSTANCE.registerPaperCommand("scriptedQuests"); } } From e1e2a6f509b36b8131a7d19427c387e13c1c3b4d Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Mon, 13 Apr 2026 10:04:44 -0700 Subject: [PATCH 06/13] Actually set plugin dependency Signed-off-by: Byron Marohn --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 01ecc560..73fc6702 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ monumenta { pluginProject(":scripted-quests") paper( "com.playmonumenta.scriptedquests.Plugin", BukkitPluginDescription.PluginLoadOrder.POSTWORLD, "1.18", - depends = listOf("CommandAPI"), + depends = listOf("CommandAPI", , "MonumentaCommon"), softDepends = listOf("dynmap", "MonumentaRedisSync", "ProtocolLib"), apiJarVersion = "1.20.4-R0.1-SNAPSHOT", action = { From 8b89490306c8f095057fc7e820a97911f2c42dbb Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Mon, 13 Apr 2026 10:06:18 -0700 Subject: [PATCH 07/13] derp --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 73fc6702..66e7174f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ monumenta { pluginProject(":scripted-quests") paper( "com.playmonumenta.scriptedquests.Plugin", BukkitPluginDescription.PluginLoadOrder.POSTWORLD, "1.18", - depends = listOf("CommandAPI", , "MonumentaCommon"), + depends = listOf("CommandAPI", "MonumentaCommon"), softDepends = listOf("dynmap", "MonumentaRedisSync", "ProtocolLib"), apiJarVersion = "1.20.4-R0.1-SNAPSHOT", action = { From 9aed923af0b24aa88203393f40fa1d904c2cac4c Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Mon, 13 Apr 2026 11:02:35 -0700 Subject: [PATCH 08/13] Refactor again to fix class loading issues Signed-off-by: Byron Marohn --- gradle/libs.versions.toml | 4 +--- plugin/build.gradle.kts | 5 ----- .../main/java/com/playmonumenta/scriptedquests/Plugin.java | 1 + .../java/com/playmonumenta/scriptedquests/utils/MMLog.java | 5 ++++- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 32f10012..65389c35 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,8 +12,7 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" -monumenta-common = "f231e8a-SNAPSHOT" -velocity = "3.3.0-SNAPSHOT" +monumenta-common = "4022f57.dirty-SNAPSHOT" redissync = "6.0.0" [libraries] @@ -32,7 +31,6 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher mockito = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito-junit" } mockbukkit = { module = "com.github.seeseemelk:MockBukkit-v1.20", version.ref = "mockbukkit" } monumenta-common = { module = "com.playmonumenta:monumenta-common", version.ref = "monumenta-common" } -velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } redissync = { module = "com.playmonumenta:redissync", version.ref = "redissync" } [bundles] diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index c8b21ce3..34a43f9e 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -10,11 +10,6 @@ dependencies { compileOnly(libs.monumenta.common) testRuntimeOnly(libs.monumenta.common) - // monumenta-common's MMLog class references Velocity API types. Those types are resolved - // lazily at runtime (registerVelocityCommand() is never called on Paper), but the test - // class loader loads them eagerly. Add the Velocity API to the test classpath so that - // class loading succeeds, even though scripted-quests itself has no Velocity interaction. - testRuntimeOnly(libs.velocity) compileOnly(libs.commandapi) compileOnly(libs.nbtapi) compileOnly(libs.brigadier) diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java index d8b65570..0dc90a79 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java @@ -80,6 +80,7 @@ public class Plugin extends JavaPlugin { @Override public void onLoad() { MMLog.init(); + com.playmonumenta.common.MMLogPaper.registerCommand(MMLog.getLog(), "scriptedQuests"); NmsUtils.loadVersionAdapter(this.getServer().getClass(), getLogger()); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index f2a2ede9..b108bf05 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -10,7 +10,6 @@ public class MMLog { public static void init() { if (INSTANCE == null) { INSTANCE = new com.playmonumenta.common.MMLog("ScriptedQuests"); - INSTANCE.registerPaperCommand("scriptedQuests"); } } @@ -18,6 +17,10 @@ public static void init(com.playmonumenta.common.MMLog log) { INSTANCE = log; } + public static com.playmonumenta.common.MMLog getLog() { + return getLogOrThrow(); + } + private static com.playmonumenta.common.MMLog getLogOrThrow() { if (INSTANCE == null) { throw new RuntimeException("ScriptedQuests logger invoked before being initialized!"); From 8eeb99d2c6103f65a9baff41d35badcb73404d4f Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Mon, 13 Apr 2026 13:17:05 -0700 Subject: [PATCH 09/13] Bump version Signed-off-by: Byron Marohn --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 65389c35..223b6258 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,7 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" -monumenta-common = "4022f57.dirty-SNAPSHOT" +monumenta-common = "6f48332-SNAPSHOT" redissync = "6.0.0" [libraries] From 9460281c6567ac3ff38dd8e755c147533bd9f18a Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Mon, 13 Apr 2026 16:57:07 -0700 Subject: [PATCH 10/13] Refactor again to adjust logging init Signed-off-by: Byron Marohn --- gradle/libs.versions.toml | 2 +- .../main/java/com/playmonumenta/scriptedquests/Plugin.java | 4 ++-- .../java/com/playmonumenta/scriptedquests/utils/MMLog.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 223b6258..9e63e8f3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,7 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" -monumenta-common = "6f48332-SNAPSHOT" +monumenta-common = "a1f5bb3-SNAPSHOT" redissync = "6.0.0" [libraries] diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java index 0dc90a79..89dec191 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java @@ -79,8 +79,8 @@ public class Plugin extends JavaPlugin { @Override public void onLoad() { - MMLog.init(); - com.playmonumenta.common.MMLogPaper.registerCommand(MMLog.getLog(), "scriptedQuests"); + MMLog.init(getName()); + com.playmonumenta.common.MMLogPaper.registerCommand(MMLog.getLog()); NmsUtils.loadVersionAdapter(this.getServer().getClass(), getLogger()); diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index b108bf05..55fd4514 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -7,9 +7,9 @@ public class MMLog { private static @Nullable com.playmonumenta.common.MMLog INSTANCE = null; - public static void init() { + public static void init(String pluginName) { if (INSTANCE == null) { - INSTANCE = new com.playmonumenta.common.MMLog("ScriptedQuests"); + INSTANCE = new com.playmonumenta.common.MMLog(pluginName); } } From 147fed80264be5a971f7a48f6e3d9e9cf1582dee Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Wed, 15 Apr 2026 14:01:44 -0700 Subject: [PATCH 11/13] Bump monumenta-common to 1.0.0 Signed-off-by: Byron Marohn --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e63e8f3..fb6a30b7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,7 @@ junit = "5.8.1" junit-platform = "1.8.1" mockito-junit = "5.8.0" mockbukkit = "3.9.0" -monumenta-common = "a1f5bb3-SNAPSHOT" +monumenta-common = "1.0.0" redissync = "6.0.0" [libraries] From dc008e846baf093fb6ec99395acd5e4f5ac02dc6 Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Wed, 15 Apr 2026 14:13:47 -0700 Subject: [PATCH 12/13] Remove code leftover from merge Signed-off-by: Byron Marohn --- .../playmonumenta/scriptedquests/utils/MMLog.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java index 62699b1e..55fd4514 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/MMLog.java @@ -80,13 +80,6 @@ public static void warning(String msg, Throwable throwable) { getLogOrThrow().warning(msg, throwable); } - public static void warning(String msg, Throwable throwable) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.log(Level.WARNING, msg, throwable); - } - } - public static void severe(Supplier msg) { getLogOrThrow().severe(msg); } @@ -98,11 +91,4 @@ public static void severe(String msg) { public static void severe(String msg, Throwable throwable) { getLogOrThrow().severe(msg, throwable); } - - public static void severe(String msg, Throwable throwable) { - Logger logger = CustomLogger.getInstance(); - if (logger != null) { - logger.log(Level.SEVERE, msg, throwable); - } - } } From 6a789097468d5ec6216776e8ee76b90f55cf7942 Mon Sep 17 00:00:00 2001 From: Byron Marohn Date: Wed, 15 Apr 2026 14:40:20 -0700 Subject: [PATCH 13/13] Fix one more deprecated logger usage Signed-off-by: Byron Marohn --- .../com/playmonumenta/scriptedquests/Plugin.java | 2 +- .../scriptedquests/utils/NmsUtils.java | 16 +++++++--------- .../scriptedquests/utils/QuestUtils.java | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java index 89dec191..bc2cf16f 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java @@ -82,7 +82,7 @@ public void onLoad() { MMLog.init(getName()); com.playmonumenta.common.MMLogPaper.registerCommand(MMLog.getLog()); - NmsUtils.loadVersionAdapter(this.getServer().getClass(), getLogger()); + NmsUtils.loadVersionAdapter(this.getServer().getClass()); /* * CommandAPI commands which register directly and are usable in functions diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java index 0eb57380..e611252f 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/NmsUtils.java @@ -2,8 +2,6 @@ import com.playmonumenta.scriptedquests.adapters.VersionAdapter; import com.playmonumenta.scriptedquests.adapters.VersionAdapter_unsupported; -import java.util.logging.Level; -import java.util.logging.Logger; public class NmsUtils { private static VersionAdapter mVersionAdapter = new VersionAdapter_unsupported(); @@ -12,7 +10,7 @@ public static VersionAdapter getVersionAdapter() { return mVersionAdapter; } - public static void loadVersionAdapter(Class serverClass, Logger logger) { + public static void loadVersionAdapter(Class serverClass) { /* From https://github.com/mbax/AbstractionExamplePlugin */ String packageName = serverClass.getPackage().getName(); @@ -23,22 +21,22 @@ public static void loadVersionAdapter(Class serverClass, Logger logger) { // Check if we have a valid adapter class at that location. if (VersionAdapter.class.isAssignableFrom(clazz)) { mVersionAdapter = (VersionAdapter) clazz.getConstructor().newInstance(); - logger.info("Loaded NMS adapter for " + version); + MMLog.info("Loaded NMS adapter for " + version); } else { - logger.severe("Somehow VersionAdapter is not assignable from " + clazz + ". NMS utilities will fail and throw NullPointerException's"); + MMLog.severe("Somehow VersionAdapter is not assignable from " + clazz + ". NMS utilities will fail and throw NullPointerException's"); } } catch (Exception e) { - logger.log(Level.SEVERE, "Server version " + version + " is not supported!", e); - logger.severe("Everything that relies on version-specific 'NMS' logic will behave incorrectly"); + MMLog.severe("Server version " + version + " is not supported!", e); + MMLog.severe("Everything that relies on version-specific 'NMS' logic will behave incorrectly"); try { Class clazz = Class.forName("com.playmonumenta.scriptedquests.adapters.VersionAdapter_unsupported"); // Check if we have a valid adapter class at that location. if (VersionAdapter.class.isAssignableFrom(clazz)) { mVersionAdapter = (VersionAdapter) clazz.getConstructor().newInstance(); } - logger.severe("Loaded 'unsupported' version adapter, which should at least reduce the number of null pointer exceptions"); + MMLog.severe("Loaded 'unsupported' version adapter, which should at least reduce the number of null pointer exceptions"); } catch (Exception ex) { - logger.log(Level.SEVERE, "Also failed to load generic unsupported adapter. There will be many null pointer exceptions.", ex); + MMLog.severe("Also failed to load generic unsupported adapter. There will be many null pointer exceptions.", ex); } } } diff --git a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java index fa3b2de2..4820bcf8 100644 --- a/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java +++ b/plugin/src/main/java/com/playmonumenta/scriptedquests/utils/QuestUtils.java @@ -62,7 +62,7 @@ public static void loadScriptedQuests(Plugin plugin, String folderName, @Nullabl listOfFiles = FileUtils.getFilesInDirectory(folderLocation, ".json"); } catch (IOException e) { - plugin.getLogger().severe("Caught exception trying to reload " + folderName + ": " + e); + MMLog.severe("Caught exception trying to reload " + folderName, e); audience.sendMessage(Component.text("Caught exception trying to reload " + folderName + ": " + e, NamedTextColor.RED)); return; }