Skip to content

Commit

Permalink
perf(bukkit): lazy cache for WordReplace
Browse files Browse the repository at this point in the history
  • Loading branch information
HaHaWTH committed Nov 8, 2024
1 parent f1b5011 commit 05095a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<IWordDeny> wD = new AtomicReference<>();
isInitialized = false;
Expand Down Expand Up @@ -320,6 +320,7 @@ public void onDisable() {
voiceChatHookService.unregister();
}
BookCache.invalidateAll();
WordReplace.clearCache();
ViolationCounter.resetAllViolations();
SchedulingUtils.cancelTaskSafely(violationResetTask);
if (permCache != null) permCache.disable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 05095a3

Please sign in to comment.