From 05095a3fa20653840e58baf854c96fee0b4a26d8 Mon Sep 17 00:00:00 2001 From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> Date: Sat, 9 Nov 2024 01:56:22 +0800 Subject: [PATCH] perf(bukkit): lazy cache for WordReplace --- .../main/java/io/wdsj/asw/bukkit/AdvancedSensitiveWords.java | 3 ++- .../io/wdsj/asw/bukkit/command/ConstructCommandExecutor.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/java/io/wdsj/asw/bukkit/AdvancedSensitiveWords.java b/bukkit/src/main/java/io/wdsj/asw/bukkit/AdvancedSensitiveWords.java index 0b38838..e6a8612 100644 --- a/bukkit/src/main/java/io/wdsj/asw/bukkit/AdvancedSensitiveWords.java +++ b/bukkit/src/main/java/io/wdsj/asw/bukkit/AdvancedSensitiveWords.java @@ -135,6 +135,7 @@ public void onEnable() { permCache = CachingPermTool.enable(this); BookCache.initialize(); LoggingUtils.start(); + WordReplace.clearCache(); doInitTasks(); if (settingsManager.getProperty(PluginSettings.PURGE_LOG_FILE)) purgeLog(); if (!isEventMode) { @@ -257,7 +258,6 @@ public void onEnable() { public void doInitTasks() { isAuthMeAvailable = Bukkit.getPluginManager().getPlugin("AuthMe") != null; isCslAvailable = Bukkit.getPluginManager().getPlugin("CatSeedLogin") != null; - WordReplace.clearCache(); IWordAllow wA = WordAllows.chains(WordAllows.defaults(), new WordAllow(), new ExternalWordAllow()); AtomicReference wD = new AtomicReference<>(); isInitialized = false; @@ -320,6 +320,7 @@ public void onDisable() { voiceChatHookService.unregister(); } BookCache.invalidateAll(); + WordReplace.clearCache(); ViolationCounter.resetAllViolations(); SchedulingUtils.cancelTaskSafely(violationResetTask); if (permCache != null) permCache.disable(); diff --git a/bukkit/src/main/java/io/wdsj/asw/bukkit/command/ConstructCommandExecutor.java b/bukkit/src/main/java/io/wdsj/asw/bukkit/command/ConstructCommandExecutor.java index fd82172..c9b4b98 100644 --- a/bukkit/src/main/java/io/wdsj/asw/bukkit/command/ConstructCommandExecutor.java +++ b/bukkit/src/main/java/io/wdsj/asw/bukkit/command/ConstructCommandExecutor.java @@ -46,6 +46,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } messagesManager.reload(); sensitiveWordBs.destroy(); + WordReplace.clearCache(); getInstance().doInitTasks(); if (settingsManager.getProperty(PluginSettings.BOOK_CACHE_CLEAR_ON_RELOAD) && settingsManager.getProperty(PluginSettings.BOOK_CACHE)) BookCache.invalidateAll();