@@ -121,7 +121,11 @@ private void migrateRemoveOldConfigSerializable() {
121121 * @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
122122 */
123123 private NewAndRemovedWorlds parseNewAndRemovedWorlds () {
124- Set <String > allWorldsInConfig = worldsConfig .getKeys (false );
124+ List <String > allWorldsInConfig = worldsConfig .getKeys (false )
125+ .stream ()
126+ .map (this ::decodeWorldName )
127+ .toList ();
128+
125129 List <WorldConfig > newWorldsAdded = new ArrayList <>();
126130
127131 for (String worldName : allWorldsInConfig ) {
@@ -174,7 +178,7 @@ public Try<Void> save() {
174178 worldConfig .save ().onFailure (e -> {
175179 throw new RuntimeException ("Failed to save world config: " + worldName , e );
176180 });
177- worldsConfig .set (worldName , worldConfig .getConfigurationSection ());
181+ worldsConfig .set (encodeWorldName ( worldName ) , worldConfig .getConfigurationSection ());
178182 });
179183 worldsConfig .save (worldConfigFile );
180184 }).onFailure (e -> {
@@ -214,7 +218,7 @@ public Try<Void> save() {
214218 */
215219 public void deleteWorldConfig (@ NotNull String worldName ) {
216220 worldConfigMap .remove (worldName );
217- worldsConfig .set (worldName , null );
221+ worldsConfig .set (encodeWorldName ( worldName ) , null );
218222 }
219223
220224 /**
@@ -225,11 +229,23 @@ public void deleteWorldConfig(@NotNull String worldName) {
225229 * @return The {@link ConfigurationSection} for the given world.
226230 */
227231 private ConfigurationSection getWorldConfigSection (String worldName ) {
232+ worldName = encodeWorldName (worldName );
228233 return worldsConfig .isConfigurationSection (worldName )
229234 ? worldsConfig .getConfigurationSection (worldName )
230235 : worldsConfig .createSection (worldName );
231236 }
232237
238+ /**
239+ * Dot is a special character in YAML that causes sub-path issues.
240+ */
241+ private String encodeWorldName (String worldName ) {
242+ return worldName .replace ("." , "[dot]" );
243+ }
244+
245+ private String decodeWorldName (String worldName ) {
246+ return worldName .replace ("[dot]" , "." );
247+ }
248+
233249 private static final class ConfigMigratedException extends RuntimeException {
234250 private ConfigMigratedException () {
235251 super ("Config migrated" );
0 commit comments