diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/MVSettings.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/ConfigHandle.java similarity index 94% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/MVSettings.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/ConfigHandle.java index 936e292e..75151ac9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/MVSettings.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/ConfigHandle.java @@ -1,12 +1,12 @@ -package com.onarandombox.MultiverseCore.utils.settings; +package com.onarandombox.MultiverseCore.configuration; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.logging.Logger; -import com.onarandombox.MultiverseCore.utils.settings.migration.ConfigMigrator; -import com.onarandombox.MultiverseCore.utils.settings.node.NodeGroup; +import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator; +import com.onarandombox.MultiverseCore.configuration.node.NodeGroup; import io.github.townyadvanced.commentedconfiguration.CommentedConfiguration; import io.github.townyadvanced.commentedconfiguration.setting.CommentedNode; import io.github.townyadvanced.commentedconfiguration.setting.TypedValueNode; @@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable; /** * A class that makes use of CommentedConfiguration to provide a simple way to load and save with node objects. */ -public class MVSettings { +public class ConfigHandle { public static Builder builder(String configPath) { return new Builder(configPath); @@ -44,7 +44,7 @@ public class MVSettings { * @param nodes All the node path and values for the configuration. * @param migrator The migrator to use for migrating the configuration. */ - protected MVSettings(@NotNull Path configPath, @Nullable Logger logger, @NotNull NodeGroup nodes, ConfigMigrator migrator) { + protected ConfigHandle(@NotNull Path configPath, @Nullable Logger logger, @NotNull NodeGroup nodes, ConfigMigrator migrator) { this.configPath = configPath; this.nodes = nodes; this.logger = logger; @@ -308,8 +308,8 @@ public class MVSettings { * * @return The built settings. */ - public MVSettings build() { - return new MVSettings(configPath, logger, nodes, migrator); + public ConfigHandle build() { + return new ConfigHandle(configPath, logger, nodes, migrator); } } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/DefaultMVConfig.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/DefaultMVConfig.java index 5376cf4c..0fda3753 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/DefaultMVConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/DefaultMVConfig.java @@ -7,11 +7,10 @@ import java.nio.file.Path; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVConfig; -import com.onarandombox.MultiverseCore.utils.settings.MVSettings; -import com.onarandombox.MultiverseCore.utils.settings.migration.ConfigMigrator; -import com.onarandombox.MultiverseCore.utils.settings.migration.InvertBoolMigratorAction; -import com.onarandombox.MultiverseCore.utils.settings.migration.MoveMigratorAction; -import com.onarandombox.MultiverseCore.utils.settings.migration.VersionMigrator; +import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator; +import com.onarandombox.MultiverseCore.configuration.migration.InvertBoolMigratorAction; +import com.onarandombox.MultiverseCore.configuration.migration.MoveMigratorAction; +import com.onarandombox.MultiverseCore.configuration.migration.VersionMigrator; public class DefaultMVConfig implements MVConfig { public static final String CONFIG_FILENAME = "config.yml"; @@ -31,14 +30,14 @@ public class DefaultMVConfig implements MVConfig { } private final Path configPath; - private final MVSettings settings; + private final ConfigHandle configHandle; public DefaultMVConfig(MultiverseCore core) { configPath = Path.of(core.getDataFolder().getPath(), CONFIG_FILENAME); migrateFromOldConfigFile(); - settings = MVSettings.builder(configPath) + configHandle = ConfigHandle.builder(configPath) .logger(Logging.getLogger()) .nodes(MVConfigNodes.getNodes()) .migrator(ConfigMigrator.builder(MVConfigNodes.VERSION) @@ -83,161 +82,161 @@ public class DefaultMVConfig implements MVConfig { @Override public boolean load() { - return settings.load(); + return configHandle.load(); } @Override public void save() { - settings.save(); + configHandle.save(); } @Override public Object getProperty(String name) { - return settings.get(name); + return configHandle.get(name); } @Override public boolean setProperty(String name, Object value) { - return settings.set(name, value); + return configHandle.set(name, value); } @Override public void setEnforceAccess(boolean enforceAccess) { - settings.set(MVConfigNodes.ENFORCE_ACCESS, enforceAccess); + configHandle.set(MVConfigNodes.ENFORCE_ACCESS, enforceAccess); } @Override public boolean getEnforceAccess() { - return settings.get(MVConfigNodes.ENFORCE_ACCESS); + return configHandle.get(MVConfigNodes.ENFORCE_ACCESS); } @Override public void setEnforceGameMode(boolean enforceGameMode) { - settings.set(MVConfigNodes.ENFORCE_GAMEMODE, enforceGameMode); + configHandle.set(MVConfigNodes.ENFORCE_GAMEMODE, enforceGameMode); } @Override public boolean getEnforceGameMode() { - return settings.get(MVConfigNodes.ENFORCE_GAMEMODE); + return configHandle.get(MVConfigNodes.ENFORCE_GAMEMODE); } @Override public void setAutoPurgeEntities(boolean autopurge) { - settings.set(MVConfigNodes.AUTO_PURGE_ENTITIES, autopurge); + configHandle.set(MVConfigNodes.AUTO_PURGE_ENTITIES, autopurge); } @Override public boolean isAutoPurgeEntities() { - return settings.get(MVConfigNodes.AUTO_PURGE_ENTITIES); + return configHandle.get(MVConfigNodes.AUTO_PURGE_ENTITIES); } @Override public void setTeleportIntercept(boolean teleportIntercept) { - settings.set(MVConfigNodes.TELEPORT_INTERCEPT, teleportIntercept); + configHandle.set(MVConfigNodes.TELEPORT_INTERCEPT, teleportIntercept); } @Override public boolean getTeleportIntercept() { - return settings.get(MVConfigNodes.TELEPORT_INTERCEPT); + return configHandle.get(MVConfigNodes.TELEPORT_INTERCEPT); } @Override public void setFirstSpawnOverride(boolean firstSpawnOverride) { - settings.set(MVConfigNodes.FIRST_SPAWN_OVERRIDE, firstSpawnOverride); + configHandle.set(MVConfigNodes.FIRST_SPAWN_OVERRIDE, firstSpawnOverride); } @Override public boolean getFirstSpawnOverride() { - return settings.get(MVConfigNodes.FIRST_SPAWN_OVERRIDE); + return configHandle.get(MVConfigNodes.FIRST_SPAWN_OVERRIDE); } @Override public void setFirstSpawnLocation(String firstSpawnWorld) { - settings.set(MVConfigNodes.FIRST_SPAWN_LOCATION, firstSpawnWorld); + configHandle.set(MVConfigNodes.FIRST_SPAWN_LOCATION, firstSpawnWorld); } @Override public String getFirstSpawnLocation() { - return settings.get(MVConfigNodes.FIRST_SPAWN_LOCATION); + return configHandle.get(MVConfigNodes.FIRST_SPAWN_LOCATION); } @Override public void setUseCustomPortalSearch(boolean useDefaultPortalSearch) { - settings.set(MVConfigNodes.USE_CUSTOM_PORTAL_SEARCH, useDefaultPortalSearch); + configHandle.set(MVConfigNodes.USE_CUSTOM_PORTAL_SEARCH, useDefaultPortalSearch); } @Override public boolean isUsingCustomPortalSearch() { - return settings.get(MVConfigNodes.USE_CUSTOM_PORTAL_SEARCH); + return configHandle.get(MVConfigNodes.USE_CUSTOM_PORTAL_SEARCH); } @Override public void setCustomPortalSearchRadius(int searchRadius) { - settings.set(MVConfigNodes.CUSTOM_PORTAL_SEARCH_RADIUS, searchRadius); + configHandle.set(MVConfigNodes.CUSTOM_PORTAL_SEARCH_RADIUS, searchRadius); } @Override public int getCustomPortalSearchRadius() { - return settings.get(MVConfigNodes.CUSTOM_PORTAL_SEARCH_RADIUS); + return configHandle.get(MVConfigNodes.CUSTOM_PORTAL_SEARCH_RADIUS); } @Override public void setEnablePrefixChat(boolean prefixChat) { - settings.set(MVConfigNodes.ENABLE_CHAT_PREFIX, prefixChat); + configHandle.set(MVConfigNodes.ENABLE_CHAT_PREFIX, prefixChat); } @Override public boolean isEnablePrefixChat() { - return settings.get(MVConfigNodes.ENABLE_CHAT_PREFIX); + return configHandle.get(MVConfigNodes.ENABLE_CHAT_PREFIX); } @Override public void setPrefixChatFormat(String prefixChatFormat) { - settings.set(MVConfigNodes.CHAT_PREFIX_FORMAT, prefixChatFormat); + configHandle.set(MVConfigNodes.CHAT_PREFIX_FORMAT, prefixChatFormat); } @Override public String getPrefixChatFormat() { - return settings.get(MVConfigNodes.CHAT_PREFIX_FORMAT); + return configHandle.get(MVConfigNodes.CHAT_PREFIX_FORMAT); } @Override public void setRegisterPapiHook(boolean registerPapiHook) { - settings.set(MVConfigNodes.REGISTER_PAPI_HOOK, registerPapiHook); + configHandle.set(MVConfigNodes.REGISTER_PAPI_HOOK, registerPapiHook); } @Override public boolean isRegisterPapiHook() { - return settings.get(MVConfigNodes.REGISTER_PAPI_HOOK); + return configHandle.get(MVConfigNodes.REGISTER_PAPI_HOOK); } @Override public void setGlobalDebug(int globalDebug) { - settings.set(MVConfigNodes.GLOBAL_DEBUG, globalDebug); + configHandle.set(MVConfigNodes.GLOBAL_DEBUG, globalDebug); } @Override public int getGlobalDebug() { - return settings.get(MVConfigNodes.GLOBAL_DEBUG); + return configHandle.get(MVConfigNodes.GLOBAL_DEBUG); } @Override public void setSilentStart(boolean silentStart) { - settings.set(MVConfigNodes.SILENT_START, silentStart); + configHandle.set(MVConfigNodes.SILENT_START, silentStart); } @Override public boolean getSilentStart() { - return settings.get(MVConfigNodes.SILENT_START); + return configHandle.get(MVConfigNodes.SILENT_START); } @Override public void setShowDonateMessage(boolean showDonateMessage) { - settings.set(MVConfigNodes.SHOW_DONATION_MESSAGE, showDonateMessage); + configHandle.set(MVConfigNodes.SHOW_DONATION_MESSAGE, showDonateMessage); } @Override public boolean isShowingDonateMessage() { - return settings.get(MVConfigNodes.SHOW_DONATION_MESSAGE); + return configHandle.get(MVConfigNodes.SHOW_DONATION_MESSAGE); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/MVConfigNodes.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/MVConfigNodes.java index e92956d6..b5149fdf 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/MVConfigNodes.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/MVConfigNodes.java @@ -1,8 +1,8 @@ package com.onarandombox.MultiverseCore.configuration; -import com.onarandombox.MultiverseCore.utils.settings.node.MVCommentedNode; -import com.onarandombox.MultiverseCore.utils.settings.node.MVValueNode; -import com.onarandombox.MultiverseCore.utils.settings.node.NodeGroup; +import com.onarandombox.MultiverseCore.configuration.node.MVCommentedNode; +import com.onarandombox.MultiverseCore.configuration.node.MVValueNode; +import com.onarandombox.MultiverseCore.configuration.node.NodeGroup; import io.github.townyadvanced.commentedconfiguration.setting.CommentedNode; public class MVConfigNodes { diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/ConfigMigrator.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/ConfigMigrator.java similarity index 94% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/ConfigMigrator.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/migration/ConfigMigrator.java index cbe88aa5..7e842c12 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/ConfigMigrator.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/ConfigMigrator.java @@ -1,10 +1,10 @@ -package com.onarandombox.MultiverseCore.utils.settings.migration; +package com.onarandombox.MultiverseCore.configuration.migration; import java.util.ArrayList; import java.util.List; import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.MultiverseCore.utils.settings.MVSettings; +import com.onarandombox.MultiverseCore.configuration.ConfigHandle; import io.github.townyadvanced.commentedconfiguration.setting.TypedValueNode; /** @@ -36,7 +36,7 @@ public class ConfigMigrator { * * @param settings The target settings instance to migrate. */ - public void migrate(MVSettings settings) { + public void migrate(ConfigHandle settings) { double versionNumber = settings.get(versionNode); for (VersionMigrator versionMigrator : versionMigrators) { if (versionNumber < versionMigrator.getVersion()) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/InvertBoolMigratorAction.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/InvertBoolMigratorAction.java similarity index 79% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/InvertBoolMigratorAction.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/migration/InvertBoolMigratorAction.java index 6b301b37..c9022688 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/InvertBoolMigratorAction.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/InvertBoolMigratorAction.java @@ -1,6 +1,6 @@ -package com.onarandombox.MultiverseCore.utils.settings.migration; +package com.onarandombox.MultiverseCore.configuration.migration; -import com.onarandombox.MultiverseCore.utils.settings.MVSettings; +import com.onarandombox.MultiverseCore.configuration.ConfigHandle; /** * Single migrator action that inverts a boolean value for a given path. @@ -27,7 +27,7 @@ public class InvertBoolMigratorAction implements MigratorAction { * {@inheritDoc} */ @Override - public void migrate(MVSettings settings) { + public void migrate(ConfigHandle settings) { settings.getConfig().set(path, !settings.getConfig().getBoolean(path)); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/MigratorAction.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/MigratorAction.java similarity index 59% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/MigratorAction.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/migration/MigratorAction.java index d1e180f7..1f3fdbe8 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/MigratorAction.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/MigratorAction.java @@ -1,6 +1,6 @@ -package com.onarandombox.MultiverseCore.utils.settings.migration; +package com.onarandombox.MultiverseCore.configuration.migration; -import com.onarandombox.MultiverseCore.utils.settings.MVSettings; +import com.onarandombox.MultiverseCore.configuration.ConfigHandle; /** * A migrator action is a single action that is performed when migrating a config. @@ -12,5 +12,5 @@ public interface MigratorAction { * * @param settings The target settings instance to migrate. */ - void migrate(MVSettings settings); + void migrate(ConfigHandle settings); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/MoveMigratorAction.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/MoveMigratorAction.java similarity index 86% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/MoveMigratorAction.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/migration/MoveMigratorAction.java index dffdaa6a..662d5685 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/MoveMigratorAction.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/MoveMigratorAction.java @@ -1,9 +1,9 @@ -package com.onarandombox.MultiverseCore.utils.settings.migration; +package com.onarandombox.MultiverseCore.configuration.migration; import java.util.Optional; import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.MultiverseCore.utils.settings.MVSettings; +import com.onarandombox.MultiverseCore.configuration.ConfigHandle; /** * Single migrator action that moves a value from one path to another. @@ -33,7 +33,7 @@ public class MoveMigratorAction implements MigratorAction { * {@inheritDoc} */ @Override - public void migrate(MVSettings settings) { + public void migrate(ConfigHandle settings) { Optional.ofNullable(settings.getConfig().get(fromPath)) .ifPresent(value -> { settings.getConfig().set(toPath, value); diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/VersionMigrator.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/VersionMigrator.java similarity index 92% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/VersionMigrator.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/migration/VersionMigrator.java index 4b3de046..e0aacbfd 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/migration/VersionMigrator.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/migration/VersionMigrator.java @@ -1,9 +1,9 @@ -package com.onarandombox.MultiverseCore.utils.settings.migration; +package com.onarandombox.MultiverseCore.configuration.migration; import java.util.ArrayList; import java.util.List; -import com.onarandombox.MultiverseCore.utils.settings.MVSettings; +import com.onarandombox.MultiverseCore.configuration.ConfigHandle; /** * A version migrator is a collection of migrator actions that are performed when migrating a config to a specific version. @@ -33,7 +33,7 @@ public class VersionMigrator { * * @param settings The target settings instance to migrate. */ - public void migrate(MVSettings settings) { + public void migrate(ConfigHandle settings) { actions.forEach(action -> action.migrate(settings)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/MVCommentedNode.java similarity index 97% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/node/MVCommentedNode.java index 0a6b0582..eaf2637c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/MVCommentedNode.java @@ -1,4 +1,4 @@ -package com.onarandombox.MultiverseCore.utils.settings.node; +package com.onarandombox.MultiverseCore.configuration.node; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/MVValueNode.java similarity index 97% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/node/MVValueNode.java index 3783d496..adf9e94d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/MVValueNode.java @@ -1,4 +1,4 @@ -package com.onarandombox.MultiverseCore.utils.settings.node; +package com.onarandombox.MultiverseCore.configuration.node; import java.util.Optional; diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/NamedValueNode.java similarity index 88% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/node/NamedValueNode.java index 0c8891b7..69f80b1d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/NamedValueNode.java @@ -1,4 +1,4 @@ -package com.onarandombox.MultiverseCore.utils.settings.node; +package com.onarandombox.MultiverseCore.configuration.node; import java.util.Optional; diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NodeGroup.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/NodeGroup.java similarity index 98% rename from src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NodeGroup.java rename to src/main/java/com/onarandombox/MultiverseCore/configuration/node/NodeGroup.java index 1f33cfe0..919c4889 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NodeGroup.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/node/NodeGroup.java @@ -1,4 +1,4 @@ -package com.onarandombox.MultiverseCore.utils.settings.node; +package com.onarandombox.MultiverseCore.configuration.node; import java.util.ArrayList; import java.util.Collection;