From 1ca6b207556dbc17c0891b8eef50aa977cab2a9b Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 08:52:35 -0400 Subject: [PATCH 1/9] Apply basic checkstyle fixes to WorldManager. --- .../MultiverseCore/worldnew/WorldManager.java | 206 +++++++++--------- 1 file changed, 109 insertions(+), 97 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java index 65916190..45ace4e6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java @@ -130,14 +130,13 @@ public class WorldManager { * Load worlds that are already loaded by bukkit before Multiverse-Core is loaded. */ private void loadDefaultWorlds() { - Bukkit.getWorlds().forEach((world) -> { + Bukkit.getWorlds().forEach(world -> { if (isOfflineWorld(world.getName())) { return; } importWorld(ImportWorldOptions.worldName(world.getName()) .environment(world.getEnvironment()) - .generator(generatorProvider.getDefaultGeneratorForWorld(world.getName())) - ); + .generator(generatorProvider.getDefaultGeneratorForWorld(world.getName()))); }); } @@ -149,7 +148,7 @@ public class WorldManager { if (isMVWorld(world) || !world.getAutoLoad()) { return; } - loadWorld(world).onFailure((failure) -> Logging.severe("Failed to load world %s: %s", world.getName(), failure)); + loadWorld(world).onFailure(failure -> Logging.severe("Failed to load world %s: %s", world.getName(), failure)); }); } @@ -161,17 +160,21 @@ public class WorldManager { public Result createWorld(CreateWorldOptions options) { // Params validations if (!worldNameChecker.isValidWorldName(options.worldName())) { - return Result.failure(CreateWorldResult.Failure.INVALID_WORLDNAME, replace("{world}").with(options.worldName())); + return Result.failure(CreateWorldResult.Failure.INVALID_WORLDNAME, + replace("{world}").with(options.worldName())); } if (getMVWorld(options.worldName()).isDefined()) { - return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(options.worldName())); + return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_LOADED, + replace("{world}").with(options.worldName())); } if (getOfflineWorld(options.worldName()).isDefined()) { - return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(options.worldName())); + return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_OFFLINE, + replace("{world}").with(options.worldName())); } File worldFolder = new File(Bukkit.getWorldContainer(), options.worldName()); if (worldFolder.exists()) { - return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_FOLDER, replace("{world}").with(options.worldName())); + return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_FOLDER, + replace("{world}").with(options.worldName())); } String parsedGenerator = parseGenerator(options.worldName(), options.generator()); @@ -180,17 +183,16 @@ public class WorldManager { .generateStructures(options.generateStructures()) .generator(parsedGenerator) .seed(options.seed()) - .type(options.worldType()) - ).fold( - (exception) -> Result.failure(CreateWorldResult.Failure.BUKKIT_CREATION_FAILED, - replace("{world}").with(options.worldName()), - replace("{error}").with(exception.getMessage()) - ), - (world) -> { - newMVWorld(world, parsedGenerator); - return Result.success(CreateWorldResult.Success.CREATED, replace("{world}").with(world.getName())); - } - ); + .type(options.worldType())) + .fold( + exception -> Result.failure(CreateWorldResult.Failure.BUKKIT_CREATION_FAILED, + replace("{world}").with(options.worldName()), + replace("{error}").with(exception.getMessage())), + world -> { + newMVWorld(world, parsedGenerator); + return Result.success(CreateWorldResult.Success.CREATED, + replace("{world}").with(world.getName())); + }); } /** @@ -202,32 +204,35 @@ public class WorldManager { public Result importWorld(ImportWorldOptions options) { // Params validations if (!worldNameChecker.isValidWorldName(options.worldName())) { - return Result.failure(ImportWorldResult.Failure.INVALID_WORLDNAME, replace("{world}").with(options.worldName())); + return Result.failure(ImportWorldResult.Failure.INVALID_WORLDNAME, + replace("{world}").with(options.worldName())); } if (!worldNameChecker.isValidWorldFolder(options.worldName())) { - return Result.failure(ImportWorldResult.Failure.WORLD_FOLDER_INVALID, replace("{world}").with(options.worldName())); + return Result.failure(ImportWorldResult.Failure.WORLD_FOLDER_INVALID, + replace("{world}").with(options.worldName())); } if (isMVWorld(options.worldName())) { - return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(options.worldName())); + return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_LOADED, + replace("{world}").with(options.worldName())); } if (isOfflineWorld(options.worldName())) { - return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(options.worldName())); + return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_OFFLINE, + replace("{world}").with(options.worldName())); } String parsedGenerator = parseGenerator(options.worldName(), options.generator()); return createBukkitWorld(WorldCreator.name(options.worldName()) .environment(options.environment()) - .generator(parsedGenerator) - ).fold( - (exception) -> Result.failure(ImportWorldResult.Failure.BUKKIT_CREATION_FAILED, - replace("{world}").with(options.worldName()), - replace("{error}").with(exception.getMessage()) - ), - (world) -> { - newMVWorld(world, parsedGenerator); - return Result.success(ImportWorldResult.Success.IMPORTED, replace("{world}").with(options.worldName())); - } - ); + .generator(parsedGenerator)) + .fold( + exception -> Result.failure(ImportWorldResult.Failure.BUKKIT_CREATION_FAILED, + replace("{world}").with(options.worldName()), + replace("{error}").with(exception.getMessage())), + world -> { + newMVWorld(world, parsedGenerator); + return Result.success(ImportWorldResult.Success.IMPORTED, + replace("{world}").with(options.worldName())); + }); } private @Nullable String parseGenerator(@NotNull String worldName, @Nullable String generator) { @@ -258,8 +263,10 @@ public class WorldManager { return getOfflineWorld(worldName) .map(this::loadWorld) .getOrElse(() -> worldNameChecker.isValidWorldFolder(worldName) - ? Result.failure(LoadWorldResult.Failure.WORLD_EXIST_FOLDER, replace("{world}").with(worldName)) - : Result.failure(LoadWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName))); + ? Result.failure(LoadWorldResult.Failure.WORLD_EXIST_FOLDER, + replace("{world}").with(worldName)) + : Result.failure(LoadWorldResult.Failure.WORLD_NON_EXISTENT, + replace("{world}").with(worldName))); } /** @@ -273,30 +280,31 @@ public class WorldManager { if (loadTracker.contains(offlineWorld.getName())) { // This is to prevent recursive calls by WorldLoadEvent Logging.fine("World already loading: " + offlineWorld.getName()); - return Result.failure(LoadWorldResult.Failure.WORLD_ALREADY_LOADING, replace("{world}").with(offlineWorld.getName())); + return Result.failure(LoadWorldResult.Failure.WORLD_ALREADY_LOADING, + replace("{world}").with(offlineWorld.getName())); } if (isMVWorld(offlineWorld)) { Logging.severe("World already loaded: " + offlineWorld.getName()); - return Result.failure(LoadWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(offlineWorld.getName())); + return Result.failure(LoadWorldResult.Failure.WORLD_EXIST_LOADED, + replace("{world}").with(offlineWorld.getName())); } return createBukkitWorld(WorldCreator.name(offlineWorld.getName()) .environment(offlineWorld.getEnvironment()) .generator(Strings.isNullOrEmpty(offlineWorld.getGenerator()) ? null : offlineWorld.getGenerator()) - .seed(offlineWorld.getSeed()) - ).fold( - (exception) -> Result.failure(LoadWorldResult.Failure.BUKKIT_CREATION_FAILED, - replace("{world}").with(offlineWorld.getName()), - replace("{error}").with(exception.getMessage()) - ), - (world) -> { - WorldConfig worldConfig = worldsConfigManager.getWorldConfig(offlineWorld.getName()); - MVWorld mvWorld = new MVWorld(world, worldConfig, blockSafety, safeTTeleporter, locationManipulation); - worldsMap.put(mvWorld.getName(), mvWorld); - saveWorldsConfig(); - return Result.success(LoadWorldResult.Success.LOADED, replace("{world}").with(mvWorld.getName())); - } - ); + .seed(offlineWorld.getSeed())).fold( + exception -> Result.failure(LoadWorldResult.Failure.BUKKIT_CREATION_FAILED, + replace("{world}").with(offlineWorld.getName()), + replace("{error}").with(exception.getMessage())), + world -> { + WorldConfig worldConfig = worldsConfigManager.getWorldConfig(offlineWorld.getName()); + MVWorld mvWorld = new MVWorld(world, worldConfig, blockSafety, + safeTTeleporter, locationManipulation); + worldsMap.put(mvWorld.getName(), mvWorld); + saveWorldsConfig(); + return Result.success(LoadWorldResult.Success.LOADED, + replace("{world}").with(mvWorld.getName())); + }); } /** @@ -319,8 +327,10 @@ public class WorldManager { return getMVWorld(worldName) .map(this::unloadWorld) .getOrElse(() -> isOfflineOnlyWorld(worldName) - ? Result.failure(UnloadWorldResult.Failure.WORLD_OFFLINE, replace("{world}").with(worldName)) - : Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName))); + ? Result.failure(UnloadWorldResult.Failure.WORLD_OFFLINE, + replace("{world}").with(worldName)) + : Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, + replace("{world}").with(worldName))); } /** @@ -333,28 +343,28 @@ public class WorldManager { if (unloadTracker.contains(world.getName())) { // This is to prevent recursive calls by WorldUnloadEvent Logging.fine("World already unloading: " + world.getName()); - return Result.failure(UnloadWorldResult.Failure.WORLD_ALREADY_UNLOADING, replace("{world}").with(world.getName())); + return Result.failure(UnloadWorldResult.Failure.WORLD_ALREADY_UNLOADING, + replace("{world}").with(world.getName())); } // TODO: removePlayersFromWorld? return unloadBukkitWorld(world.getBukkitWorld().getOrNull()).fold( - (exception) -> Result.failure(UnloadWorldResult.Failure.BUKKIT_UNLOAD_FAILED, + exception -> Result.failure(UnloadWorldResult.Failure.BUKKIT_UNLOAD_FAILED, replace("{world}").with(world.getName()), - replace("{error}").with(exception.getMessage()) - ), - (success) -> Option.of(worldsMap.remove(world.getName())).fold( + replace("{error}").with(exception.getMessage())), + success -> Option.of(worldsMap.remove(world.getName())).fold( () -> { Logging.severe("Failed to remove world from map: " + world.getName()); - return Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(world.getName())); + return Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, + replace("{world}").with(world.getName())); }, - (mvWorld) -> { + mvWorld -> { Logging.fine("Removed MVWorld from map: " + world.getName()); mvWorld.getWorldConfig().deferenceMVWorld(); - return Result.success(UnloadWorldResult.Success.UNLOADED, replace("{world}").with(world.getName())); - } - ) - ); + return Result.success(UnloadWorldResult.Success.UNLOADED, + replace("{world}").with(world.getName())); + })); } /** @@ -380,13 +390,12 @@ public class WorldManager { public Result removeWorld(@NotNull OfflineWorld world) { return getMVWorld(world).fold( () -> removeWorldFromConfig(world), - this::removeWorld - ); + this::removeWorld); } /** - * Removes an existing multiverse world. It will be deleted from the worlds config and will no longer be an offline world. - * World files will not be deleted. + * Removes an existing multiverse world. It will be deleted from the worlds config and will no longer be an offline + * world. World files will not be deleted. * * @param world The multiverse world to remove. * @return The result of the remove. @@ -405,7 +414,8 @@ public class WorldManager { * @param world The multiverse world to remove. * @return The result of the remove. */ - private Result removeWorldFromConfig(@NotNull OfflineWorld world) { + private Result + removeWorldFromConfig(@NotNull OfflineWorld world) { // Remove world from config offlineWorldsMap.remove(world.getName()); worldsConfigManager.deleteWorldConfig(world.getName()); @@ -424,7 +434,8 @@ public class WorldManager { public Result deleteWorld(@NotNull String worldName) { return getOfflineWorld(worldName) .map(this::deleteWorld) - .getOrElse(() -> Result.failure(DeleteWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName))); + .getOrElse(() -> Result.failure(DeleteWorldResult.Failure.WORLD_NON_EXISTENT, + replace("{world}").with(worldName))); } /** @@ -439,12 +450,12 @@ public class WorldManager { () -> { var result = loadWorld(world); if (result.isFailure()) { - return Result.failure(DeleteWorldResult.Failure.LOAD_FAILED, replace("{world}").with(world.getName())); + return Result.failure(DeleteWorldResult.Failure.LOAD_FAILED, + replace("{world}").with(world.getName())); } return deleteWorld(world); }, - this::deleteWorld - ); + this::deleteWorld); } /** @@ -457,7 +468,8 @@ public class WorldManager { File worldFolder = world.getBukkitWorld().map(World::getWorldFolder).getOrNull(); if (worldFolder == null || !worldNameChecker.isValidWorldFolder(worldFolder)) { Logging.severe("Failed to get world folder for world: " + world.getName()); - return Result.failure(DeleteWorldResult.Failure.WORLD_FOLDER_NOT_FOUND, replace("{world}").with(world.getName())); + return Result.failure(DeleteWorldResult.Failure.WORLD_FOLDER_NOT_FOUND, + replace("{world}").with(world.getName())); } var result = removeWorld(world); @@ -468,12 +480,11 @@ public class WorldManager { // Erase world files from disk // TODO: Possible config options to keep certain files return filesManipulator.deleteFolder(worldFolder).fold( - (exception) -> Result.failure(DeleteWorldResult.Failure.FAILED_TO_DELETE_FOLDER, + exception -> Result.failure(DeleteWorldResult.Failure.FAILED_TO_DELETE_FOLDER, replace("{world}").with(world.getName()), - replace("{error}").with(exception.getMessage()) - ), - (success) -> Result.success(DeleteWorldResult.Success.DELETED, replace("{world}").with(world.getName())) - ); + replace("{error}").with(exception.getMessage())), + success -> Result.success(DeleteWorldResult.Success.DELETED, + replace("{world}").with(world.getName()))); } /** @@ -487,24 +498,24 @@ public class WorldManager { .onSuccessThen(s -> importWorld( ImportWorldOptions.worldName(options.newWorldName()) .environment(options.world().getEnvironment()) - .generator(options.world().getGenerator()) - ).fold( - failure -> Result.failure(CloneWorldResult.Failure.IMPORT_FAILED, failure.getReasonMessage()), - success -> Result.success() - )) + .generator(options.world().getGenerator())) + .fold( + failure -> Result.failure(CloneWorldResult.Failure.IMPORT_FAILED, failure.getReasonMessage()), + success -> Result.success())) .onSuccessThen(s -> getMVWorld(options.newWorldName()).fold( - () -> Result.failure(CloneWorldResult.Failure.MV_WORLD_FAILED, replace("{world}").with(options.newWorldName())), + () -> Result.failure(CloneWorldResult.Failure.MV_WORLD_FAILED, + replace("{world}").with(options.newWorldName())), mvWorld -> { cloneWorldTransferData(options, mvWorld); saveWorldsConfig(); return Result.success(CloneWorldResult.Success.CLONED, replace("{world}").with(options.world().getName()), replace("{newworld}").with(mvWorld.getName())); - } - )); + })); } - private Result cloneWorldValidateWorld(@NotNull CloneWorldOptions options) { + private Result + cloneWorldValidateWorld(@NotNull CloneWorldOptions options) { String newWorldName = options.newWorldName(); if (!worldNameChecker.isValidWorldName(newWorldName)) { Logging.severe("Invalid world name: " + newWorldName); @@ -524,14 +535,15 @@ public class WorldManager { return Result.success(); } - private Result cloneWorldCopyFolder(@NotNull CloneWorldOptions options) { + private Result + cloneWorldCopyFolder(@NotNull CloneWorldOptions options) { File worldFolder = options.world().getBukkitWorld().map(World::getWorldFolder).getOrNull(); // TODO: Check null? File newWorldFolder = new File(Bukkit.getWorldContainer(), options.newWorldName()); return filesManipulator.copyFolder(worldFolder, newWorldFolder, CLONE_IGNORE_FILES).fold( - (exception) -> Result.failure(CloneWorldResult.Failure.COPY_FAILED, + exception -> Result.failure(CloneWorldResult.Failure.COPY_FAILED, replace("{world}").with(options.world().getName()), replace("{error}").with(exception.getMessage())), - (success) -> Result.success()); + success -> Result.success()); } private void cloneWorldTransferData(@NotNull CloneWorldOptions options, @NotNull MVWorld newWorld) { @@ -570,11 +582,11 @@ public class WorldManager { } CreateWorldOptions createWorldOptions = CreateWorldOptions.worldName(world.getName()) - .environment(world.getEnvironment()) - .generateStructures(world.canGenerateStructures().getOrElse(true)) - .generator(world.getGenerator()) - .seed(options.seed()) - .worldType(world.getWorldType().getOrElse(WorldType.NORMAL)); + .environment(world.getEnvironment()) + .generateStructures(world.canGenerateStructures().getOrElse(true)) + .generator(world.getGenerator()) + .seed(options.seed()) + .worldType(world.getWorldType().getOrElse(WorldType.NORMAL)); var deleteResult = deleteWorld(world); if (deleteResult.isFailure()) { From 7726cf3485b7f157dd99dc460f85f835fcd2ca27 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 08:58:43 -0400 Subject: [PATCH 2/9] Apply basic checkstyle fixes to MVWorld. --- .../MultiverseCore/worldnew/MVWorld.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java index d9038c43..13800697 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java @@ -31,8 +31,7 @@ public class MVWorld extends OfflineWorld { @NotNull WorldConfig worldConfig, @NotNull BlockSafety blockSafety, @NotNull SafeTTeleporter safeTTeleporter, - @NotNull LocationManipulation locationManipulation - ) { + @NotNull LocationManipulation locationManipulation) { super(world.getName(), worldConfig); this.worldUid = world.getUID(); this.blockSafety = blockSafety; @@ -118,11 +117,11 @@ public class MVWorld extends OfflineWorld { @Override public String toString() { - return "MVWorld{" + - "name='" + worldName + "', " + - "env='" + getEnvironment() + "', " + - "type='" + getWorldType().getOrNull() + "', " + - "gen='" + getGenerator() + "'" + - '}'; + return "MVWorld{" + + "name='" + worldName + "', " + + "env='" + getEnvironment() + "', " + + "type='" + getWorldType().getOrNull() + "', " + + "gen='" + getGenerator() + "'" + + '}'; } } From caba4100a376e5f715d9d3b541ce3e490cefbe5b Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 08:59:36 -0400 Subject: [PATCH 3/9] Apply basic checkstyle fixes to OfflineWorld. --- .../MultiverseCore/worldnew/OfflineWorld.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java index 095aaa3d..d4d8ebc9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java @@ -300,10 +300,10 @@ public class OfflineWorld { @Override public String toString() { - return "OfflineWorld{" + - "name='" + worldName + "', " + - "env='" + getEnvironment() + "', " + - "gen='" + getGenerator() + "'" + - '}'; + return "OfflineWorld{" + + "name='" + worldName + "', " + + "env='" + getEnvironment() + "', " + + "gen='" + getGenerator() + "'" + + '}'; } } From 11edd8e63102594983a99645b688fd514552fe95 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 09:02:17 -0400 Subject: [PATCH 4/9] Apply basic checkstyle fixes to WorldPurger. --- .../MultiverseCore/worldnew/WorldPurger.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java index 2d2f70fa..0fe90deb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java @@ -60,7 +60,7 @@ public class WorldPurger { } public void purgeWorld(MVWorld mvworld, List thingsToKill, - boolean negateAnimals, boolean negateMonsters, CommandSender sender) { + boolean negateAnimals, boolean negateMonsters, CommandSender sender) { if (mvworld == null) { return; } @@ -77,8 +77,7 @@ public class WorldPurger { List livingEntities = new ArrayList(worldEntities.size()); List projectiles = new ArrayList(worldEntities.size()); for (final Entity e : worldEntities) { - if (e instanceof Projectile) { - final Projectile p = (Projectile) e; + if (e instanceof Projectile p) { if (p.getShooter() != null) { projectiles.add((Projectile) e); } @@ -107,7 +106,7 @@ public class WorldPurger { } private boolean killDecision(Entity e, List thingsToKill, boolean negateAnimals, - boolean negateMonsters, boolean specifiedAnimals, boolean specifiedMonsters) { + boolean negateMonsters, boolean specifiedAnimals, boolean specifiedMonsters) { boolean negate = false; boolean specified = false; if (e instanceof Golem || e instanceof Squid || e instanceof Animals @@ -149,7 +148,8 @@ public class WorldPurger { return false; } - public boolean shouldWeKillThisCreature(Entity e, List thingsToKill, boolean negateAnimals, boolean negateMonsters) { + public boolean shouldWeKillThisCreature(Entity e, List thingsToKill, + boolean negateAnimals, boolean negateMonsters) { boolean specifiedAll = thingsToKill.contains("ALL"); boolean specifiedAnimals = thingsToKill.contains("ANIMALS") || specifiedAll; boolean specifiedMonsters = thingsToKill.contains("MONSTERS") || specifiedAll; From 58d37e93eeaf9eddfbcb5fc7e64fe30dd61afa16 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 09:03:10 -0400 Subject: [PATCH 5/9] Apply basic checkstyle fixes to NullLocation. --- .../MultiverseCore/worldnew/config/NullLocation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java index 1e812834..80df59c9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java @@ -20,7 +20,7 @@ public final class NullLocation extends SpawnLocation { @Override public Location clone() { throw new UnsupportedOperationException(); - }; + } @Override public Map serialize() { @@ -44,10 +44,10 @@ public final class NullLocation extends SpawnLocation { @Override public int hashCode() { return -1; - }; + } @Override public String toString() { return "Location{null}"; - }; + } } From 93d23115ff2a58726cb57c8aba44d554550a3061 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 09:04:23 -0400 Subject: [PATCH 6/9] Apply basic checkstyle fixes to WorldConfig. --- .../MultiverseCore/worldnew/config/WorldConfig.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java index 478457f9..e86e0be6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java @@ -2,7 +2,6 @@ package com.onarandombox.MultiverseCore.worldnew.config; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.configuration.handle.ConfigurationSectionHandle; -import com.onarandombox.MultiverseCore.configuration.node.NodeGroup; import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType; import com.onarandombox.MultiverseCore.worldnew.MVWorld; import io.vavr.control.Try; @@ -18,7 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; -public class WorldConfig { +public final class WorldConfig { private final String worldName; private final WorldConfigNodes configNodes; From 7582a84cc63967eb507f4aebcf98def6ae9cb7be Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 09:07:21 -0400 Subject: [PATCH 7/9] Apply basic checkstyle fixes to WorldConfigNodes. --- .../worldnew/config/WorldConfigNodes.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java index 033ec325..66ef14db 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java @@ -49,7 +49,7 @@ public class WorldConfigNodes { .defaultValue(true) .name("allow-weather") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> { if (!world.isClearWeather() && !newValue) { world.setThundering(false); @@ -78,7 +78,7 @@ public class WorldConfigNodes { .defaultValue(Difficulty.NORMAL) .name("difficulty") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setDifficulty(newValue)); }) .build()); @@ -93,7 +93,8 @@ public class WorldConfigNodes { .name("entryfee-currency") .build()); - public final ConfigNode ENVIRONMENT = node(ConfigNode.builder("environment", World.Environment.class) + public final ConfigNode ENVIRONMENT = node(ConfigNode + .builder("environment", World.Environment.class) .defaultValue(World.Environment.NORMAL) .name("environment") .build()); @@ -118,11 +119,12 @@ public class WorldConfigNodes { .name("hunger") .build()); - public final ConfigNode KEEP_SPAWN_IN_MEMORY = node(ConfigNode.builder("keep-spawn-in-memory", Boolean.class) + public final ConfigNode KEEP_SPAWN_IN_MEMORY = node(ConfigNode + .builder("keep-spawn-in-memory", Boolean.class) .defaultValue(true) .name("keep-spawn-in-memory") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setKeepSpawnInMemory(newValue)); }) .build()); @@ -132,7 +134,8 @@ public class WorldConfigNodes { .name("player-limit") .build()); - public final ConfigNode PORTAL_FORM = node(ConfigNode.builder("portal-form", AllowedPortalType.class) + public final ConfigNode PORTAL_FORM = node(ConfigNode + .builder("portal-form", AllowedPortalType.class) .defaultValue(AllowedPortalType.ALL) .name("portal-form") .build()); @@ -141,7 +144,7 @@ public class WorldConfigNodes { .defaultValue(true) .name("pvp") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setPVP(newValue)); }) .build()); @@ -165,7 +168,7 @@ public class WorldConfigNodes { .defaultValue(new NullLocation()) .name("spawn-location") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> { world.setSpawnLocation(newValue.getBlockX(), newValue.getBlockY(), newValue.getBlockZ()); newValue.setWorld(world); @@ -177,44 +180,49 @@ public class WorldConfigNodes { .defaultValue(true) .name("spawning-animals") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setSpawnFlags(world.getAllowMonsters(), newValue)); }) .build()); - public final ConfigNode SPAWNING_ANIMALS_TICKS = node(ConfigNode.builder("spawning.animals.tick-rate", Integer.class) + public final ConfigNode SPAWNING_ANIMALS_TICKS = node(ConfigNode + .builder("spawning.animals.tick-rate", Integer.class) .defaultValue(-1) .name("spawning-animals-ticks") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setTicksPerAnimalSpawns(newValue)); }) .build()); - public final ConfigNode SPAWNING_ANIMALS_EXCEPTIONS = node(ConfigNode.builder("spawning.animals.exceptions", List.class) + public final ConfigNode SPAWNING_ANIMALS_EXCEPTIONS = node(ConfigNode + .builder("spawning.animals.exceptions", List.class) .defaultValue(new ArrayList<>()) .name("spawning-animals-exceptions") .build()); - public final ConfigNode SPAWNING_MONSTERS = node(ConfigNode.builder("spawning.monsters.spawn", Boolean.class) + public final ConfigNode SPAWNING_MONSTERS = node(ConfigNode + .builder("spawning.monsters.spawn", Boolean.class) .defaultValue(true) .name("spawning-monsters") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setSpawnFlags(newValue, world.getAllowAnimals())); }) .build()); - public final ConfigNode SPAWNING_MONSTERS_TICKS = node(ConfigNode.builder("spawning.monsters.tick-rate", Integer.class) + public final ConfigNode SPAWNING_MONSTERS_TICKS = node(ConfigNode + .builder("spawning.monsters.tick-rate", Integer.class) .defaultValue(-1) .name("spawning-monsters-ticks") .onSetValue((oldValue, newValue) -> { - if (world == null) { return; } + if (world == null) return; world.getBukkitWorld().peek(world -> world.setTicksPerMonsterSpawns(newValue)); }) .build()); - public final ConfigNode SPAWNING_MONSTERS_EXCEPTIONS = node(ConfigNode.builder("spawning.monsters.exceptions", List.class) + public final ConfigNode SPAWNING_MONSTERS_EXCEPTIONS = node(ConfigNode + .builder("spawning.monsters.exceptions", List.class) .defaultValue(new ArrayList<>()) .name("spawning-monsters-exceptions") .build()); From 324328f25408dcd6f3d1470c4d13b335ad75b348 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 09:07:46 -0400 Subject: [PATCH 8/9] Apply basic checkstyle fixes to WorldConfigManager. --- .../MultiverseCore/worldnew/config/WorldsConfigManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java index bc0d642e..0dd1cbb5 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java @@ -15,7 +15,7 @@ import java.util.Map; import java.util.Set; @Service -public class WorldsConfigManager { +public final class WorldsConfigManager { private static final String CONFIG_FILENAME = "worlds2.yml"; private final Map worldConfigMap; From 035005bac32b640c902e1863218854a4404ccdf5 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 8 Sep 2023 09:08:30 -0400 Subject: [PATCH 9/9] Apply basic checkstyle fixes to DataStore. --- .../onarandombox/MultiverseCore/worldnew/helpers/DataStore.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java index 1a152822..bddf4ac3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java @@ -2,7 +2,6 @@ package com.onarandombox.MultiverseCore.worldnew.helpers; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.worldnew.MVWorld; -import com.onarandombox.MultiverseCore.worldnew.OfflineWorld; import org.bukkit.GameRule; import org.bukkit.World; import org.jvnet.hk2.annotations.Service;