Skip to content

Commit b434903

Browse files
authored
Merge pull request #3131 from Multiverse/ben/mv5/NewAndRemovedWorlds
Use a record NewAndRemovedWorlds instead of generic tuple for clarity
2 parents e2050c8 + f5b5148 commit b434903

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public Try<Void> initAllWorlds() {
119119
*/
120120
private Try<Void> updateWorldsFromConfig() {
121121
return worldsConfigManager.load().mapTry(result -> {
122-
loadNewWorldConfigs(result._1());
123-
removeWorldsNotInConfigs(result._2());
122+
loadNewWorldConfigs(result.newWorlds());
123+
removeWorldsNotInConfigs(result.removedWorlds());
124124
return null;
125125
});
126126
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.mvplugins.multiverse.core.world.config;
2+
3+
import java.util.List;
4+
5+
/**
6+
* A record containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
7+
*
8+
* @param newWorlds List of the new WorldConfigs added
9+
* @param removedWorlds List of the worlds removed from the config
10+
*/
11+
public record NewAndRemovedWorlds(List<WorldConfig> newWorlds, List<String> removedWorlds) {
12+
}

src/main/java/org/mvplugins/multiverse/core/world/config/WorldsConfigManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public final class WorldsConfigManager {
4747
/**
4848
* Loads the worlds.yml file and creates a WorldConfig for each world in the file if it doesn't already exist.
4949
*
50-
* @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
50+
* @return A {@link NewAndRemovedWorlds} record.
5151
*/
52-
public Try<Tuple2<List<WorldConfig>, List<String>>> load() {
52+
public Try<NewAndRemovedWorlds> load() {
5353
return Try.of(() -> {
5454
loadWorldYmlFile();
5555
return parseNewAndRemovedWorlds();
@@ -116,7 +116,7 @@ private void migrateRemoveOldConfigSerializable() {
116116
*
117117
* @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
118118
*/
119-
private Tuple2<List<WorldConfig>, List<String>> parseNewAndRemovedWorlds() {
119+
private NewAndRemovedWorlds parseNewAndRemovedWorlds() {
120120
Set<String> allWorldsInConfig = worldsConfig.getKeys(false);
121121
List<WorldConfig> newWorldsAdded = new ArrayList<>();
122122

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

144-
return new Tuple2<>(newWorldsAdded, worldsRemoved);
144+
return new NewAndRemovedWorlds(newWorldsAdded, worldsRemoved);
145145
}
146146

147147
/**

0 commit comments

Comments
 (0)