mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 02:25:41 +01:00
Use a record NewAndRemovedWorlds instead of generic tuple for clarity
This commit is contained in:
parent
1eeb265f4e
commit
f5b5148f82
@ -119,8 +119,8 @@ public class WorldManager {
|
|||||||
*/
|
*/
|
||||||
private Try<Void> updateWorldsFromConfig() {
|
private Try<Void> updateWorldsFromConfig() {
|
||||||
return worldsConfigManager.load().mapTry(result -> {
|
return worldsConfigManager.load().mapTry(result -> {
|
||||||
loadNewWorldConfigs(result._1());
|
loadNewWorldConfigs(result.newWorlds());
|
||||||
removeWorldsNotInConfigs(result._2());
|
removeWorldsNotInConfigs(result.removedWorlds());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
}
|
@ -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.
|
* 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(() -> {
|
return Try.of(() -> {
|
||||||
loadWorldYmlFile();
|
loadWorldYmlFile();
|
||||||
return parseNewAndRemovedWorlds();
|
return parseNewAndRemovedWorlds();
|
||||||
@ -116,7 +116,7 @@ public final class WorldsConfigManager {
|
|||||||
*
|
*
|
||||||
* @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config.
|
* @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);
|
Set<String> allWorldsInConfig = worldsConfig.getKeys(false);
|
||||||
List<WorldConfig> newWorldsAdded = new ArrayList<>();
|
List<WorldConfig> newWorldsAdded = new ArrayList<>();
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ public final class WorldsConfigManager {
|
|||||||
worldConfigMap.remove(s);
|
worldConfigMap.remove(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Tuple2<>(newWorldsAdded, worldsRemoved);
|
return new NewAndRemovedWorlds(newWorldsAdded, worldsRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user