From af1efa0f2404bcab732b5c1209f473bff09c159b Mon Sep 17 00:00:00 2001 From: TheFaser Date: Thu, 9 Nov 2023 21:55:45 +0500 Subject: [PATCH] Modules: remove statics for maps that do not need them --- src/main/java/net/flectone/chat/FlectoneChat.java | 1 - .../java/net/flectone/chat/manager/FModuleManager.java | 6 +----- .../chat/module/autoMessage/AutoMessageModule.java | 4 ++-- .../chat/module/commands/CommandFlectonechat.java | 1 - .../chat/module/player/afkTimeout/AfkTimeoutModule.java | 2 +- .../module/playerMessage/formatting/FormattingModule.java | 2 +- .../module/playerMessage/patterns/PatternsModule.java | 2 +- .../net/flectone/chat/module/server/tab/TabModule.java | 8 ++++---- .../serverMessage/advancement/AdvancementModule.java | 2 +- 9 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/flectone/chat/FlectoneChat.java b/src/main/java/net/flectone/chat/FlectoneChat.java index 1434a372..f52a741a 100644 --- a/src/main/java/net/flectone/chat/FlectoneChat.java +++ b/src/main/java/net/flectone/chat/FlectoneChat.java @@ -96,7 +96,6 @@ public void onDisable() { FPlayerManager.terminateAll(); FActionManager.clearAll(); - FModuleManager.clear(); database.getExecutor().close(); database.disconnect(); } diff --git a/src/main/java/net/flectone/chat/manager/FModuleManager.java b/src/main/java/net/flectone/chat/manager/FModuleManager.java index 10f9a20d..aeed818f 100644 --- a/src/main/java/net/flectone/chat/manager/FModuleManager.java +++ b/src/main/java/net/flectone/chat/manager/FModuleManager.java @@ -22,7 +22,7 @@ @Getter public class FModuleManager { - private static final HashMap, FModule> F_MODULE_MAP = new HashMap<>(); + private final HashMap, FModule> F_MODULE_MAP = new HashMap<>(); public Collection getModules() { return F_MODULE_MAP.values(); @@ -56,8 +56,4 @@ public void init() { public FModule get(Class clazz) { return F_MODULE_MAP.get(clazz); } - - public static void clear() { - F_MODULE_MAP.clear(); - } } diff --git a/src/main/java/net/flectone/chat/module/autoMessage/AutoMessageModule.java b/src/main/java/net/flectone/chat/module/autoMessage/AutoMessageModule.java index 5ec3c8d5..bbc08721 100644 --- a/src/main/java/net/flectone/chat/module/autoMessage/AutoMessageModule.java +++ b/src/main/java/net/flectone/chat/module/autoMessage/AutoMessageModule.java @@ -23,8 +23,8 @@ public class AutoMessageModule extends FModule { - private static final HashMap MESSAGE_INDEX_MAP = new HashMap<>(); - private static final HashMap> MESSAGE_MAP = new HashMap<>(); + private final HashMap MESSAGE_INDEX_MAP = new HashMap<>(); + private final HashMap> MESSAGE_MAP = new HashMap<>(); public AutoMessageModule(String name) { super(name); diff --git a/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java b/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java index c58e1803..62d1c71a 100644 --- a/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java +++ b/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java @@ -93,7 +93,6 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command // disable all IntegrationsModule.unregister(); FActionManager.clearAll(); - FModuleManager.clear(); FPlayerManager.terminateAll(); diff --git a/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java b/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java index 27859d10..2a916f5e 100644 --- a/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java +++ b/src/main/java/net/flectone/chat/module/player/afkTimeout/AfkTimeoutModule.java @@ -20,7 +20,7 @@ public class AfkTimeoutModule extends FModule { - private static final HashMap> LAST_BLOCK_MAP = new HashMap<>(); + private final HashMap> LAST_BLOCK_MAP = new HashMap<>(); public AfkTimeoutModule(FModule module, String name) { super(module, name); diff --git a/src/main/java/net/flectone/chat/module/playerMessage/formatting/FormattingModule.java b/src/main/java/net/flectone/chat/module/playerMessage/formatting/FormattingModule.java index 00a138e8..68763ce3 100644 --- a/src/main/java/net/flectone/chat/module/playerMessage/formatting/FormattingModule.java +++ b/src/main/java/net/flectone/chat/module/playerMessage/formatting/FormattingModule.java @@ -29,7 +29,7 @@ public class FormattingModule extends FModule { private final static List patterns = List.of("||", "**", "__", "##", "??", "~~"); - private final static HashMap> FORMATTING_MAP = new HashMap<>(); + private final HashMap> FORMATTING_MAP = new HashMap<>(); public FormattingModule(FModule module, String name) { super(module, name); diff --git a/src/main/java/net/flectone/chat/module/playerMessage/patterns/PatternsModule.java b/src/main/java/net/flectone/chat/module/playerMessage/patterns/PatternsModule.java index 1dfbf0cc..2420aec3 100644 --- a/src/main/java/net/flectone/chat/module/playerMessage/patterns/PatternsModule.java +++ b/src/main/java/net/flectone/chat/module/playerMessage/patterns/PatternsModule.java @@ -14,7 +14,7 @@ public class PatternsModule extends FModule { - private static HashMap> PATTERN_MAP = new HashMap<>(); + private HashMap> PATTERN_MAP = new HashMap<>(); public PatternsModule(FModule module, String name) { super(module, name); diff --git a/src/main/java/net/flectone/chat/module/server/tab/TabModule.java b/src/main/java/net/flectone/chat/module/server/tab/TabModule.java index 017d6749..1d4b54e2 100644 --- a/src/main/java/net/flectone/chat/module/server/tab/TabModule.java +++ b/src/main/java/net/flectone/chat/module/server/tab/TabModule.java @@ -18,10 +18,10 @@ public class TabModule extends FModule { - private static final HashMap HEADER_INDEX_MAP = new HashMap<>(); - private static final HashMap FOOTER_INDEX_MAP = new HashMap<>(); - private static final HashMap> TAB_HEADER_MAP = new HashMap<>(); - private static final HashMap> TAB_FOOTER_MAP = new HashMap<>(); + private final HashMap HEADER_INDEX_MAP = new HashMap<>(); + private final HashMap FOOTER_INDEX_MAP = new HashMap<>(); + private final HashMap> TAB_HEADER_MAP = new HashMap<>(); + private final HashMap> TAB_FOOTER_MAP = new HashMap<>(); public TabModule(FModule module, String name) { super(module, name); diff --git a/src/main/java/net/flectone/chat/module/serverMessage/advancement/AdvancementModule.java b/src/main/java/net/flectone/chat/module/serverMessage/advancement/AdvancementModule.java index 8f7939a7..f33968c5 100644 --- a/src/main/java/net/flectone/chat/module/serverMessage/advancement/AdvancementModule.java +++ b/src/main/java/net/flectone/chat/module/serverMessage/advancement/AdvancementModule.java @@ -25,7 +25,7 @@ public class AdvancementModule extends FModule { - private static final HashMap LAST_WORLD_ANNOUNCE_ADVANCEMENT_MAP = new HashMap<>(); + private final HashMap LAST_WORLD_ANNOUNCE_ADVANCEMENT_MAP = new HashMap<>(); public AdvancementModule(FModule module, String name) { super(module, name);