From b8434f891ed733eea4f8a6ef3507d423d33d17a1 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 29 Oct 2023 10:55:50 +0100 Subject: [PATCH] Reduce duplicated singleton objects (#2473) --- .../java/com/fastasyncworldedit/core/FaweCache.java | 11 ++++++----- .../core/configuration/Settings.java | 6 +++--- .../fastasyncworldedit/core/database/DBHandler.java | 2 +- .../com/fastasyncworldedit/core/util/WEManager.java | 2 +- .../sk89q/worldedit/command/HistorySubCommands.java | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java index d8e1474e6..0655e4214 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java @@ -60,16 +60,17 @@ import java.util.function.Supplier; import static com.google.common.base.Preconditions.checkNotNull; public enum FaweCache implements Trimable { - /** - * @deprecated Use {@link #INSTANCE} to get an instance. - */ - @Deprecated(forRemoval = true, since = "2.0.0") - IMP, /** * @since 2.0.0 */ INSTANCE; + /** + * @deprecated Use {@link #INSTANCE} to get an instance. + */ + @Deprecated(forRemoval = true, since = "2.0.0") + public static final FaweCache IMP = INSTANCE; + private static final Logger LOGGER = LogManagerCompat.getLogger(); public final int BLOCKS_PER_LAYER = 4096; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index d0aeb5058..672dcebe8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -19,14 +19,14 @@ import java.util.stream.Stream; public class Settings extends Config { + @Ignore + static Settings INSTANCE = new Settings(); /** * @deprecated Use {@link #settings()} instead to get an instance. */ @Ignore @Deprecated(forRemoval = true, since = "2.0.0") - public static final Settings IMP = new Settings(); - @Ignore - static Settings INSTANCE = new Settings(); + public static final Settings IMP = INSTANCE; @Ignore public boolean PROTOCOL_SUPPORT_FIX = false; @Comment("These first 6 aren't configurable") // This is a comment diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/DBHandler.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/DBHandler.java index fd1263b11..755e94b2f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/DBHandler.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/DBHandler.java @@ -13,7 +13,7 @@ public class DBHandler { * @deprecated Use {@link #dbHandler()} instead. */ @Deprecated(forRemoval = true, since = "2.0.0") - public static final DBHandler IMP = new DBHandler(); + public static final DBHandler IMP = dbHandler(); private static final Logger LOGGER = LogManagerCompat.getLogger(); private static DBHandler INSTANCE; private final Map databases = new ConcurrentHashMap<>(8, 0.9f, 1); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java index 17b7882f2..b31853dd0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java @@ -32,7 +32,7 @@ public class WEManager { * @deprecated Use {@link #weManager()} instead. */ @Deprecated(forRemoval = true, since = "2.0.0") - public static WEManager IMP = new WEManager(); + public static WEManager IMP = weManager(); private final ArrayDeque managers = new ArrayDeque<>(); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java index 452d5084c..6b30e9e7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java @@ -201,7 +201,7 @@ public class HistorySubCommands { .at(summary.maxX, world.getMaxY(), summary.maxZ) ); rollback.setTime(historyFile.lastModified()); - RollbackDatabase db = DBHandler.IMP + RollbackDatabase db = DBHandler.dbHandler() .getDatabase(world); db.logEdit(rollback); actor.print(TextComponent.of("Logging: " + historyFile));