Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public Try<Void> initAllWorlds() {
*/
private Try<Void> updateWorldsFromConfig() {
return worldsConfigManager.load().mapTry(result -> {
loadNewWorldConfigs(result._1());
removeWorldsNotInConfigs(result._2());
loadNewWorldConfigs(result.newWorlds());
removeWorldsNotInConfigs(result.removedWorlds());
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.mvplugins.multiverse.core.world.config;

import java.util.List;

/**
* A record containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
*
* @param newWorlds List of the new WorldConfigs added
* @param removedWorlds List of the worlds removed from the config
*/
public record NewAndRemovedWorlds(List<WorldConfig> newWorlds, List<String> removedWorlds) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public final class WorldsConfigManager {
/**
* Loads the worlds.yml file and creates a WorldConfig for each world in the file if it doesn't already exist.
*
* @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
* @return A {@link NewAndRemovedWorlds} record.
*/
public Try<Tuple2<List<WorldConfig>, List<String>>> load() {
public Try<NewAndRemovedWorlds> load() {
return Try.of(() -> {
loadWorldYmlFile();
return parseNewAndRemovedWorlds();
Expand Down Expand Up @@ -116,7 +116,7 @@ private void migrateRemoveOldConfigSerializable() {
*
* @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
*/
private Tuple2<List<WorldConfig>, List<String>> parseNewAndRemovedWorlds() {
private NewAndRemovedWorlds parseNewAndRemovedWorlds() {
Set<String> allWorldsInConfig = worldsConfig.getKeys(false);
List<WorldConfig> newWorldsAdded = new ArrayList<>();

Expand All @@ -141,7 +141,7 @@ private Tuple2<List<WorldConfig>, List<String>> parseNewAndRemovedWorlds() {
worldConfigMap.remove(s);
}

return new Tuple2<>(newWorldsAdded, worldsRemoved);
return new NewAndRemovedWorlds(newWorldsAdded, worldsRemoved);
}

/**
Expand Down
Loading