From f0d2499dd2685712a2dafff4c4fbc58fdea522c6 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 8 Sep 2023 23:19:43 +0800 Subject: [PATCH] Refactor multiverse world class and getters naming --- .../MultiverseCore/commands/CloneCommand.java | 4 +- .../commands/CoordinatesCommand.java | 4 +- .../MultiverseCore/commands/DumpsCommand.java | 2 +- .../commands/GameruleCommand.java | 6 +- .../MultiverseCore/commands/ListCommand.java | 12 +- .../MultiverseCore/commands/RegenCommand.java | 5 +- .../commands/UnloadCommand.java | 4 +- .../commandtools/MVCommandCompletions.java | 16 +-- .../commandtools/MVCommandConditions.java | 10 +- .../commandtools/MVCommandContexts.java | 34 ++--- .../destination/core/CannonDestination.java | 4 +- .../destination/core/ExactDestination.java | 4 +- .../destination/core/WorldDestination.java | 4 +- .../core/WorldDestinationInstance.java | 6 +- .../MultiverseCore/economy/MVEconomist.java | 4 +- .../listeners/MVChatListener.java | 2 +- .../listeners/MVEntityListener.java | 6 +- .../listeners/MVPlayerListener.java | 26 ++-- .../listeners/MVPortalListener.java | 6 +- .../listeners/MVWeatherListener.java | 5 +- .../listeners/MVWorldListener.java | 2 +- .../permissions/CorePermissionsChecker.java | 12 +- .../MultiverseCorePlaceholders.java | 10 +- .../utils/metrics/MetricsConfigurator.java | 12 +- ...VWorld.java => LoadedMultiverseWorld.java} | 4 +- ...OfflineWorld.java => MultiverseWorld.java} | 6 +- .../MultiverseCore/worldnew/WorldManager.java | 126 +++++++++--------- .../MultiverseCore/worldnew/WorldPurger.java | 14 +- .../worldnew/config/WorldConfig.java | 4 +- .../worldnew/config/WorldConfigNodes.java | 4 +- .../entrycheck/WorldEntryChecker.java | 16 +-- .../worldnew/helpers/DataStore.java | 20 +-- .../worldnew/options/CloneWorldOptions.java | 10 +- .../worldnew/options/RegenWorldOptions.java | 10 +- .../multiverse/core/world/WorldManagerTest.kt | 10 +- 35 files changed, 210 insertions(+), 214 deletions(-) rename src/main/java/com/onarandombox/MultiverseCore/worldnew/{MVWorld.java => LoadedMultiverseWorld.java} (98%) rename src/main/java/com/onarandombox/MultiverseCore/worldnew/{OfflineWorld.java => MultiverseWorld.java} (98%) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java index f41923a2..d50ed9cb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java @@ -15,7 +15,7 @@ import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup; import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags; import com.onarandombox.MultiverseCore.utils.MVCorei18n; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import com.onarandombox.MultiverseCore.worldnew.options.CloneWorldOptions; import jakarta.inject.Inject; @@ -55,7 +55,7 @@ public class CloneCommand extends MultiverseCommand { @Syntax("") @Description("{@@mv-core.clone.world.description}") - MVWorld world, + LoadedMultiverseWorld world, @Syntax("") @Description("{@@mv-core.clone.newWorld.description}") diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordinatesCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordinatesCommand.java index 323ea393..4531ea3a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordinatesCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordinatesCommand.java @@ -10,7 +10,7 @@ import com.onarandombox.MultiverseCore.api.LocationManipulation; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand; import com.onarandombox.MultiverseCore.utils.MVCorei18n; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import jakarta.inject.Inject; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public class CoordinatesCommand extends MultiverseCommand { Player player, @Flags("resolve=issuerOnly") - MVWorld world + LoadedMultiverseWorld world ) { issuer.sendInfo(MVCorei18n.COORDINATES_INFO_TITLE); issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLD, "{world}", world.getName()); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DumpsCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DumpsCommand.java index a6836efe..8a1c9ab0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DumpsCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DumpsCommand.java @@ -184,7 +184,7 @@ public class DumpsCommand extends MultiverseCommand { return "# Multiverse-Core Version info" + "\n\n" + " - Multiverse-Core Version: " + this.plugin.getDescription().getVersion() + '\n' + " - Bukkit Version: " + this.plugin.getServer().getVersion() + '\n' - + " - Loaded Worlds: " + worldManager.getMVWorlds() + '\n' + + " - Loaded Worlds: " + worldManager.getLoadedWorlds() + '\n' + " - Multiverse Plugins Loaded: " + this.plugin.getPluginCount() + '\n'; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java index e0b43c13..3408f506 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java @@ -12,7 +12,7 @@ import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand; import com.onarandombox.MultiverseCore.commandtools.context.GameRuleValue; import com.onarandombox.MultiverseCore.utils.MVCorei18n; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import jakarta.inject.Inject; import org.bukkit.GameRule; import org.bukkit.World; @@ -46,11 +46,11 @@ public class GameruleCommand extends MultiverseCommand { @Flags("resolve=issuerAware") @Syntax("[World or *]") @Description("{@@mv-core.gamerule.world.description}") - MVWorld[] worlds + LoadedMultiverseWorld[] worlds ) { Object value = gameRuleValue.getValue(); boolean success = true; - for(MVWorld world : worlds) { + for(LoadedMultiverseWorld world : worlds) { // Set gamerules and add false to list if it fails World bukkitWorld = world.getBukkitWorld().getOrNull(); if (bukkitWorld == null || !bukkitWorld.setGameRule(gamerule, value)) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java index 09e0a053..dcdcaef7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java @@ -1,6 +1,5 @@ package com.onarandombox.MultiverseCore.commands; -import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.InvalidCommandArgument; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; @@ -22,12 +21,11 @@ import com.onarandombox.MultiverseCore.display.handlers.PagedSendHandler; import com.onarandombox.MultiverseCore.display.parsers.ListContentProvider; import com.onarandombox.MultiverseCore.worldnew.entrycheck.WorldEntryChecker; import com.onarandombox.MultiverseCore.worldnew.entrycheck.WorldEntryCheckerProvider; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.bukkit.ChatColor; import org.bukkit.World; -import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; @@ -100,14 +98,14 @@ public class ListCommand extends MultiverseCommand { List worldList = new ArrayList<>(); WorldEntryChecker worldEntryChecker = worldEntryCheckerProvider.forSender(issuer.getIssuer()); - worldManager.getMVWorlds().stream() + worldManager.getLoadedWorlds().stream() .filter(world -> worldEntryChecker.canAccessWorld(world).isSuccess()) .filter(world -> canSeeWorld(issuer, world)) .map(world -> hiddenText(world) + world.getAlias() + " - " + parseColouredEnvironment(world.getEnvironment())) .sorted() .forEach(worldList::add); - worldManager.getOfflineOnlyWorlds().stream() + worldManager.getUnloadedWorlds().stream() .filter(world -> worldEntryChecker.canAccessWorld(world).isSuccess()) .map(world -> ChatColor.GRAY + world.getAlias() + " - UNLOADED") .sorted() @@ -116,12 +114,12 @@ public class ListCommand extends MultiverseCommand { return worldList; } - private boolean canSeeWorld(MVCommandIssuer issuer, MVWorld world) { + private boolean canSeeWorld(MVCommandIssuer issuer, LoadedMultiverseWorld world) { return !world.isHidden() || issuer.hasPermission("multiverse.core.modify"); // TODO: Refactor stray permission check } - private String hiddenText(MVWorld world) { + private String hiddenText(LoadedMultiverseWorld world) { return (world.isHidden()) ? String.format("%s[H] ", ChatColor.GRAY) : ""; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java index daaa566e..5c8cb2d5 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java @@ -1,6 +1,5 @@ package com.onarandombox.MultiverseCore.commands; -import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.MessageType; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; @@ -19,7 +18,7 @@ import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag; import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags; import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand; import com.onarandombox.MultiverseCore.utils.MVCorei18n; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import com.onarandombox.MultiverseCore.worldnew.options.RegenWorldOptions; import jakarta.inject.Inject; @@ -67,7 +66,7 @@ public class RegenCommand extends MultiverseCommand { @Syntax("") @Description("{@@mv-core.regen.world.description}") - MVWorld world, + LoadedMultiverseWorld world, @Optional @Syntax("--seed [seed] --reset-gamerules") diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java index 90bbdd30..81b1aeda 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java @@ -11,7 +11,7 @@ import com.onarandombox.MultiverseCore.commandtools.MVCommandIssuer; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand; import com.onarandombox.MultiverseCore.utils.MVCorei18n; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.jetbrains.annotations.NotNull; @@ -38,7 +38,7 @@ public class UnloadCommand extends MultiverseCommand { @Syntax("") @Description("{@@mv-core.unload.world.description}") - MVWorld world + LoadedMultiverseWorld world ) { issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING, "{world}", world.getAlias()); worldManager.unloadWorld(world) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java index 9c0dfa1b..ac21dc11 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java @@ -11,8 +11,8 @@ import com.google.common.collect.Sets; import com.onarandombox.MultiverseCore.config.MVCoreConfig; import com.onarandombox.MultiverseCore.destination.DestinationsProvider; import com.onarandombox.MultiverseCore.destination.ParsedDestination; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; -import com.onarandombox.MultiverseCore.worldnew.OfflineWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; +import com.onarandombox.MultiverseCore.worldnew.MultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.bukkit.GameRule; @@ -56,7 +56,7 @@ public class MVCommandCompletions extends PaperCommandCompletions { setDefaultCompletion("destinations", ParsedDestination.class); setDefaultCompletion("flags", String[].class); setDefaultCompletion("gamerules", GameRule.class); - setDefaultCompletion("mvworlds", MVWorld.class); + setDefaultCompletion("mvworlds", LoadedMultiverseWorld.class); } private Collection suggestCommands(BukkitCommandCompletionContext context) { @@ -127,17 +127,17 @@ public class MVCommandCompletions extends PaperCommandCompletions { String scope = context.getConfig("scope", "loaded"); switch (scope) { case "both" -> { - return worldManager.getOfflineWorlds().stream().map(OfflineWorld::getName).toList(); + return worldManager.getWorlds().stream().map(MultiverseWorld::getName).toList(); } case "loaded" -> { - return worldManager.getMVWorlds() + return worldManager.getLoadedWorlds() .stream() - .map(MVWorld::getName) + .map(LoadedMultiverseWorld::getName) .toList(); } case "unloaded" -> { - return worldManager.getOfflineOnlyWorlds().stream() - .map(OfflineWorld::getName) + return worldManager.getUnloadedWorlds().stream() + .map(MultiverseWorld::getName) .toList(); } case "potential" -> { diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java index 11900d5c..6eba7dc0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java @@ -40,14 +40,14 @@ public class MVCommandConditions { switch (scope) { // Worlds that are loaded case "loaded": - if (!this.worldManager.isMVWorld(worldName)) { + if (!this.worldManager.isLoadedWorld(worldName)) { throw new ConditionFailedException("World with name '" + worldName + "' does not exist or is not loaded!"); } break; // Worlds that are unloaded case "unloaded": - if (!this.worldManager.isOfflineOnlyWorld(worldName)) { - if (this.worldManager.isMVWorld(worldName)) { + if (!this.worldManager.isUnloadedWorld(worldName)) { + if (this.worldManager.isLoadedWorld(worldName)) { throw new ConditionFailedException("World with name '" + worldName + "' is loaded already!"); } throw new ConditionFailedException("World with name '" + worldName + "' does not exist!"); @@ -55,13 +55,13 @@ public class MVCommandConditions { break; // World that are loaded or unloaded case "both": - if (!this.worldManager.isOfflineWorld(worldName)) { + if (!this.worldManager.isWorld(worldName)) { throw new ConditionFailedException("World with name '" + worldName + "' does not exist!"); } break; // World that are does not exist case "new": - if (this.worldManager.isOfflineWorld(worldName)) { + if (this.worldManager.isWorld(worldName)) { throw new ConditionFailedException("World with name '" + worldName + "' already exists!"); } switch (WorldNameChecker.checkName(worldName)) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandContexts.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandContexts.java index 4d21d497..531b29f3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandContexts.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandContexts.java @@ -20,7 +20,7 @@ import com.onarandombox.MultiverseCore.display.filters.ContentFilter; import com.onarandombox.MultiverseCore.display.filters.DefaultContentFilter; import com.onarandombox.MultiverseCore.display.filters.RegexContentFilter; import com.onarandombox.MultiverseCore.utils.PlayerFinder; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import io.vavr.control.Option; import jakarta.inject.Inject; @@ -56,8 +56,8 @@ public class MVCommandContexts extends PaperCommandContexts { registerContext(GameRule.class, this::parseGameRule); registerContext(GameRuleValue.class, this::parseGameRuleValue); registerContext(MVConfigValue.class, this::parseMVConfigValue); - registerIssuerAwareContext(MVWorld.class, this::parseMVWorld); - registerIssuerAwareContext(MVWorld[].class, this::parseMVWorldArray); + registerIssuerAwareContext(LoadedMultiverseWorld.class, this::parseMVWorld); + registerIssuerAwareContext(LoadedMultiverseWorld[].class, this::parseMVWorldArray); registerIssuerAwareContext(Player.class, this::parsePlayer); registerIssuerAwareContext(Player[].class, this::parsePlayerArray); } @@ -161,13 +161,13 @@ public class MVCommandContexts extends PaperCommandContexts { return new MVConfigValue(resolvedValue); } - private MVWorld parseMVWorld(BukkitCommandExecutionContext context) { + private LoadedMultiverseWorld parseMVWorld(BukkitCommandExecutionContext context) { String resolve = context.getFlagValue("resolve", ""); // Get world based on sender only if (resolve.equals("issuerOnly")) { if (context.getIssuer().isPlayer()) { - return worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld()).getOrNull(); + return worldManager.getLoadedWorld(context.getIssuer().getPlayer().getWorld()).getOrNull(); } if (context.isOptional()) { return null; @@ -176,7 +176,7 @@ public class MVCommandContexts extends PaperCommandContexts { } String worldName = context.getFirstArg(); - MVWorld world = worldManager.getMVWorld(worldName).getOrNull(); + LoadedMultiverseWorld world = worldManager.getLoadedWorld(worldName).getOrNull(); // Get world based on input, fallback to sender if input is not a world if (resolve.equals("issuerAware")) { @@ -185,7 +185,7 @@ public class MVCommandContexts extends PaperCommandContexts { return world; } if (context.getIssuer().isPlayer()) { - return worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld()).getOrNull(); + return worldManager.getLoadedWorld(context.getIssuer().getPlayer().getWorld()).getOrNull(); } if (context.isOptional()) { return null; @@ -204,18 +204,18 @@ public class MVCommandContexts extends PaperCommandContexts { throw new InvalidCommandArgument("World " + worldName + " is not a loaded multiverse world."); } - private MVWorld[] parseMVWorldArray(BukkitCommandExecutionContext context) { + private LoadedMultiverseWorld[] parseMVWorldArray(BukkitCommandExecutionContext context) { String resolve = context.getFlagValue("resolve", ""); - MVWorld playerWorld = null; + LoadedMultiverseWorld playerWorld = null; if (context.getIssuer().isPlayer()) { - playerWorld = worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld()).getOrNull(); + playerWorld = worldManager.getLoadedWorld(context.getIssuer().getPlayer().getWorld()).getOrNull(); } // Get world based on sender only if (resolve.equals("issuerOnly")) { if (playerWorld != null) { - return new MVWorld[]{playerWorld}; + return new LoadedMultiverseWorld[]{playerWorld}; } if (context.isOptional()) { return null; @@ -225,13 +225,13 @@ public class MVCommandContexts extends PaperCommandContexts { String worldStrings = context.getFirstArg(); String[] worldNames = worldStrings == null ? new String[0] : worldStrings.split(","); - Set worlds = new HashSet<>(worldNames.length); + Set worlds = new HashSet<>(worldNames.length); for (String worldName : worldNames) { if ("*".equals(worldName)) { - worlds.addAll(worldManager.getMVWorlds()); + worlds.addAll(worldManager.getLoadedWorlds()); break; } - MVWorld world = worldManager.getMVWorld(worldName).getOrNull(); + LoadedMultiverseWorld world = worldManager.getLoadedWorld(worldName).getOrNull(); if (world == null) { throw new InvalidCommandArgument("World " + worldName + " is not a loaded multiverse world."); } @@ -242,10 +242,10 @@ public class MVCommandContexts extends PaperCommandContexts { if (resolve.equals("issuerAware")) { if (!worlds.isEmpty()) { context.popFirstArg(); - return worlds.toArray(new MVWorld[0]); + return worlds.toArray(new LoadedMultiverseWorld[0]); } if (playerWorld != null) { - return new MVWorld[]{playerWorld}; + return new LoadedMultiverseWorld[]{playerWorld}; } if (context.isOptional()) { return null; @@ -256,7 +256,7 @@ public class MVCommandContexts extends PaperCommandContexts { // Get world based on input only if (!worlds.isEmpty()) { context.popFirstArg(); - return worlds.toArray(new MVWorld[0]); + return worlds.toArray(new LoadedMultiverseWorld[0]); } if (context.isOptional()) { return null; diff --git a/src/main/java/com/onarandombox/MultiverseCore/destination/core/CannonDestination.java b/src/main/java/com/onarandombox/MultiverseCore/destination/core/CannonDestination.java index 23dbf81e..f62cd9f3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/destination/core/CannonDestination.java +++ b/src/main/java/com/onarandombox/MultiverseCore/destination/core/CannonDestination.java @@ -6,7 +6,7 @@ import java.util.Collections; import co.aikar.commands.BukkitCommandIssuer; import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.Teleporter; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.bukkit.Location; @@ -54,7 +54,7 @@ public class CannonDestination implements Destination return null; } - World world = this.worldManager.getMVWorld(worldName).map(MVWorld::getBukkitWorld).getOrNull().getOrNull(); + World world = this.worldManager.getLoadedWorld(worldName).map(LoadedMultiverseWorld::getBukkitWorld).getOrNull().getOrNull(); if (world == null) { return null; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/destination/core/ExactDestination.java b/src/main/java/com/onarandombox/MultiverseCore/destination/core/ExactDestination.java index ca504c78..f24d92ca 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/destination/core/ExactDestination.java +++ b/src/main/java/com/onarandombox/MultiverseCore/destination/core/ExactDestination.java @@ -6,7 +6,7 @@ import java.util.Collections; import co.aikar.commands.BukkitCommandIssuer; import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.Teleporter; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.bukkit.Location; @@ -50,7 +50,7 @@ public class ExactDestination implements Destination { return null; } - World world = this.worldManager.getMVWorld(worldName).map(MVWorld::getBukkitWorld).getOrNull().getOrNull(); + World world = this.worldManager.getLoadedWorld(worldName).map(LoadedMultiverseWorld::getBukkitWorld).getOrNull().getOrNull(); if (world == null) { return null; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestination.java b/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestination.java index f0c63da4..153af088 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestination.java +++ b/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestination.java @@ -7,7 +7,7 @@ import co.aikar.commands.BukkitCommandIssuer; import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.LocationManipulation; import com.onarandombox.MultiverseCore.api.Teleporter; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ public class WorldDestination implements Destination { } String worldName = items[0]; - MVWorld world = this.worldManager.getMVWorld(worldName).getOrNull(); + LoadedMultiverseWorld world = this.worldManager.getLoadedWorld(worldName).getOrNull(); if (world == null) { return null; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestinationInstance.java b/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestinationInstance.java index b1ac6353..e4d47c5b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestinationInstance.java +++ b/src/main/java/com/onarandombox/MultiverseCore/destination/core/WorldDestinationInstance.java @@ -1,7 +1,7 @@ package com.onarandombox.MultiverseCore.destination.core; import com.onarandombox.MultiverseCore.api.DestinationInstance; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.util.Vector; @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class WorldDestinationInstance implements DestinationInstance { - private final MVWorld world; + private final LoadedMultiverseWorld world; private final String direction; private final float yaw; @@ -18,7 +18,7 @@ public class WorldDestinationInstance implements DestinationInstance { * * @param world The world to teleport to. */ - public WorldDestinationInstance(@NotNull MVWorld world, @Nullable String direction, float yaw) { + public WorldDestinationInstance(@NotNull LoadedMultiverseWorld world, @Nullable String direction, float yaw) { this.world = world; this.direction = direction; this.yaw = yaw; diff --git a/src/main/java/com/onarandombox/MultiverseCore/economy/MVEconomist.java b/src/main/java/com/onarandombox/MultiverseCore/economy/MVEconomist.java index e1c9dea7..832cb031 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/economy/MVEconomist.java +++ b/src/main/java/com/onarandombox/MultiverseCore/economy/MVEconomist.java @@ -1,6 +1,6 @@ package com.onarandombox.MultiverseCore.economy; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import jakarta.inject.Inject; import org.bukkit.Material; import org.bukkit.World; @@ -98,7 +98,7 @@ public class MVEconomist { * @param player the player to deposit currency into. * @param world the world to take entry fee from. */ - public void payEntryFee(Player player, MVWorld world) { + public void payEntryFee(Player player, LoadedMultiverseWorld world) { payEntryFee(player, world.getPrice(), world.getCurrency()); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java index 56f85d04..6c750d80 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java @@ -51,7 +51,7 @@ public class MVChatListener implements InjectableListener { playerListener.getPlayerWorld().put(event.getPlayer().getName(), world); } - String prefix = this.worldManager.getMVWorld(world) + String prefix = this.worldManager.getLoadedWorld(world) .map((mvworld) -> mvworld.isHidden() ? "" : mvworld.getAlias()) .getOrElse(""); String chat = event.getFormat(); diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVEntityListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVEntityListener.java index f5b3cf0a..b014d8f8 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVEntityListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVEntityListener.java @@ -52,7 +52,7 @@ public class MVEntityListener implements InjectableListener { if (!(event.getEntity() instanceof Player player)) { return; } - worldManager.getMVWorld(player.getWorld()) + worldManager.getLoadedWorld(player.getWorld()) .peek((world) -> { if (!world.getHunger() && event.getFoodLevel() < player.getFoodLevel()) { event.setCancelled(true); @@ -69,7 +69,7 @@ public class MVEntityListener implements InjectableListener { if (event.isCancelled() || event.getRegainReason() != RegainReason.REGEN) { return; } - worldManager.getMVWorld(event.getEntity().getWorld()) + worldManager.getLoadedWorld(event.getEntity().getWorld()) .peek((world) -> { if (!world.getAutoHeal()) { event.setCancelled(true); @@ -95,7 +95,7 @@ public class MVEntityListener implements InjectableListener { return; } - worldManager.getMVWorld(event.getEntity().getWorld()) + worldManager.getLoadedWorld(event.getEntity().getWorld()) .peek((world) -> { if (this.worldPurger.shouldWeKillThisCreature(world, event.getEntity())) { Logging.finer("Cancelling Creature Spawn Event for: " + event.getEntity()); diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index 25182bb0..e5ccfcfa 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -20,7 +20,7 @@ import com.onarandombox.MultiverseCore.inject.InjectableListener; import com.onarandombox.MultiverseCore.permissions.CorePermissionsChecker; import com.onarandombox.MultiverseCore.teleportation.TeleportQueue; import com.onarandombox.MultiverseCore.utils.result.ResultChain; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import com.onarandombox.MultiverseCore.worldnew.entrycheck.EntryFeeResult; import com.onarandombox.MultiverseCore.worldnew.entrycheck.WorldEntryCheckerProvider; @@ -116,7 +116,7 @@ public class MVPlayerListener implements InjectableListener { @EventHandler(priority = EventPriority.LOW) public void playerRespawn(PlayerRespawnEvent event) { World world = event.getPlayer().getWorld(); - MVWorld mvWorld = getWorldManager().getMVWorld(world.getName()).getOrNull(); + LoadedMultiverseWorld mvWorld = getWorldManager().getLoadedWorld(world.getName()).getOrNull(); // If it's not a World MV manages we stop. if (mvWorld == null) { return; @@ -128,9 +128,9 @@ public class MVPlayerListener implements InjectableListener { } // Get the instance of the World the player should respawn at. - MVWorld respawnWorld = null; - if (getWorldManager().isMVWorld(mvWorld.getRespawnWorld())) { - respawnWorld = getWorldManager().getMVWorld(mvWorld.getRespawnWorld()).getOrNull(); + LoadedMultiverseWorld respawnWorld = null; + if (getWorldManager().isLoadedWorld(mvWorld.getRespawnWorld())) { + respawnWorld = getWorldManager().getLoadedWorld(mvWorld.getRespawnWorld()).getOrNull(); } // If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it. @@ -147,7 +147,7 @@ public class MVPlayerListener implements InjectableListener { } private Location getMostAccurateRespawnLocation(World w) { - MVWorld mvw = getWorldManager().getMVWorld(w.getName()).getOrNull(); + LoadedMultiverseWorld mvw = getWorldManager().getLoadedWorld(w.getName()).getOrNull(); if (mvw != null) { return mvw.getSpawnLocation(); } @@ -161,7 +161,7 @@ public class MVPlayerListener implements InjectableListener { @EventHandler public void playerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - MVWorld world = getWorldManager().getMVWorld(player.getWorld()).getOrNull(); + LoadedMultiverseWorld world = getWorldManager().getLoadedWorld(player.getWorld()).getOrNull(); if (world == null) { Logging.finer("Player joined in a world that is not managed by Multiverse."); return; @@ -226,8 +226,8 @@ public class MVPlayerListener implements InjectableListener { } Logging.finer("Inferred sender '" + teleporter + "' from name '" + teleporterName + "', fetched from name '" + teleportee.getName() + "'"); - MVWorld fromWorld = getWorldManager().getMVWorld(event.getFrom().getWorld().getName()).getOrNull(); - MVWorld toWorld = getWorldManager().getMVWorld(event.getTo().getWorld().getName()).getOrNull(); + LoadedMultiverseWorld fromWorld = getWorldManager().getLoadedWorld(event.getFrom().getWorld().getName()).getOrNull(); + LoadedMultiverseWorld toWorld = getWorldManager().getLoadedWorld(event.getTo().getWorld().getName()).getOrNull(); if (toWorld == null) { Logging.fine("Player '" + teleportee.getName() + "' is teleporting to world '" + event.getTo().getWorld().getName() + "' which is not managed by Multiverse-Core. No further " @@ -304,8 +304,8 @@ public class MVPlayerListener implements InjectableListener { event.setSearchRadius(config.getCustomPortalSearchRadius()); } - MVWorld fromWorld = getWorldManager().getMVWorld(event.getFrom().getWorld().getName()).getOrNull(); - MVWorld toWorld = getWorldManager().getMVWorld(event.getTo().getWorld().getName()).getOrNull(); + LoadedMultiverseWorld fromWorld = getWorldManager().getLoadedWorld(event.getFrom().getWorld().getName()).getOrNull(); + LoadedMultiverseWorld toWorld = getWorldManager().getLoadedWorld(event.getTo().getWorld().getName()).getOrNull(); if (event.getFrom().getWorld().equals(event.getTo().getWorld())) { // The player is Portaling to the same world. Logging.finer("Player '" + event.getPlayer().getName() + "' is portaling to the same world."); @@ -335,7 +335,7 @@ public class MVPlayerListener implements InjectableListener { // FOLLOWING 2 Methods and Private class handle Per Player GameModes. private void handleGameModeAndFlight(Player player, World world) { - MVWorld mvWorld = getWorldManager().getMVWorld(world.getName()).getOrNull(); + LoadedMultiverseWorld mvWorld = getWorldManager().getLoadedWorld(world.getName()).getOrNull(); if (mvWorld != null) { this.handleGameModeAndFlight(player, mvWorld); } else { @@ -349,7 +349,7 @@ public class MVPlayerListener implements InjectableListener { * @param player The {@link Player}. * @param world The world the player is in. */ - public void handleGameModeAndFlight(final Player player, final MVWorld world) { + public void handleGameModeAndFlight(final Player player, final LoadedMultiverseWorld world) { // We perform this task one tick later to MAKE SURE that the player actually reaches the // destination world, otherwise we'd be changing the player mode if they havent moved anywhere. this.server.getScheduler().scheduleSyncDelayedTask(this.plugin, diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPortalListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPortalListener.java index d832fa14..1e4650e3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPortalListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPortalListener.java @@ -10,7 +10,7 @@ package com.onarandombox.MultiverseCore.listeners; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.config.MVCoreConfig; import com.onarandombox.MultiverseCore.inject.InjectableListener; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; import org.bukkit.Material; @@ -47,7 +47,7 @@ public class MVPortalListener implements InjectableListener { public void portalForm(PortalCreateEvent event) { Logging.fine("Attempting to create portal at '%s' with reason: %s", event.getWorld().getName(), event.getReason()); - MVWorld world = this.worldManager.getMVWorld(event.getWorld()).getOrNull(); + LoadedMultiverseWorld world = this.worldManager.getLoadedWorld(event.getWorld()).getOrNull(); if (world == null) { Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PortalCreateEvent.", event.getWorld().getName()); return; @@ -103,7 +103,7 @@ public class MVPortalListener implements InjectableListener { return; } - MVWorld world = this.worldManager.getMVWorld(event.getPlayer().getWorld()).getOrNull(); + LoadedMultiverseWorld world = this.worldManager.getLoadedWorld(event.getPlayer().getWorld()).getOrNull(); if (world == null) { Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PlayerInteractEvent.", event.getPlayer().getWorld().getName()); diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWeatherListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWeatherListener.java index 68b8a516..c4310304 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWeatherListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWeatherListener.java @@ -11,7 +11,6 @@ import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.inject.InjectableListener; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.inject.Inject; -import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.weather.ThunderChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent; @@ -39,7 +38,7 @@ public class MVWeatherListener implements InjectableListener { if (event.isCancelled() || !event.toWeatherState()) { return; } - worldManager.getMVWorld(event.getWorld()) + worldManager.getLoadedWorld(event.getWorld()) .peek((world) -> { if (!world.getAllowWeather()) { Logging.fine("Cancelling weather for %s as getAllowWeather is false", world.getName()); @@ -57,7 +56,7 @@ public class MVWeatherListener implements InjectableListener { if (event.isCancelled() || !event.toThunderState()) { return; } - worldManager.getMVWorld(event.getWorld()) + worldManager.getLoadedWorld(event.getWorld()) .peek((world) -> { if (!world.getAllowWeather()) { Logging.fine("Cancelling thunder for %s as getAllowWeather is false", world.getName()); diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWorldListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWorldListener.java index d66d8d71..316ef455 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWorldListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVWorldListener.java @@ -54,7 +54,7 @@ public class MVWorldListener implements InjectableListener { */ @EventHandler(priority = EventPriority.MONITOR) public void loadWorld(WorldLoadEvent event) { - worldManager.getOfflineOnlyWorld(event.getWorld().getName()) + worldManager.getUnloadedWorld(event.getWorld().getName()) .peek(offlineWorld -> { Logging.fine("Loading world: " + offlineWorld.getName()); worldManager.loadWorld(offlineWorld).onFailure(failure -> { diff --git a/src/main/java/com/onarandombox/MultiverseCore/permissions/CorePermissionsChecker.java b/src/main/java/com/onarandombox/MultiverseCore/permissions/CorePermissionsChecker.java index d40d12f8..de26450c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/permissions/CorePermissionsChecker.java +++ b/src/main/java/com/onarandombox/MultiverseCore/permissions/CorePermissionsChecker.java @@ -1,15 +1,15 @@ package com.onarandombox.MultiverseCore.permissions; import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; -import com.onarandombox.MultiverseCore.worldnew.OfflineWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; +import com.onarandombox.MultiverseCore.worldnew.MultiverseWorld; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; @Service public class CorePermissionsChecker { - public boolean hasWorldAccessPermission(@NotNull CommandSender sender, @NotNull OfflineWorld world) { + public boolean hasWorldAccessPermission(@NotNull CommandSender sender, @NotNull MultiverseWorld world) { return hasPermission(sender, concatPermission(CorePermissions.WORLD_ACCESS, world.getName())); } @@ -18,15 +18,15 @@ public class CorePermissionsChecker { return hasPermission(sender, concatPermission(CorePermissions.WORLD_ACCESS, world.getName())); } - public boolean hasWorldExemptPermission(@NotNull CommandSender sender, @NotNull MVWorld world) { + public boolean hasWorldExemptPermission(@NotNull CommandSender sender, @NotNull LoadedMultiverseWorld world) { return hasPermission(sender, concatPermission(CorePermissions.WORLD_EXEMPT, world.getName())); } - public boolean hasPlayerLimitBypassPermission(@NotNull CommandSender sender, @NotNull MVWorld world) { + public boolean hasPlayerLimitBypassPermission(@NotNull CommandSender sender, @NotNull LoadedMultiverseWorld world) { return hasPermission(sender, concatPermission(CorePermissions.PLAYERLIMIT_BYPASS, world.getName())); } - public boolean hasGameModeBypassPermission(@NotNull CommandSender sender, @NotNull MVWorld world) { + public boolean hasGameModeBypassPermission(@NotNull CommandSender sender, @NotNull LoadedMultiverseWorld world) { return hasPermission(sender, concatPermission(CorePermissions.GAMEMODE_BYPASS, world.getName())); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java b/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java index 4564f932..8730c710 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java +++ b/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java @@ -2,7 +2,7 @@ package com.onarandombox.MultiverseCore.placeholders; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.economy.MVEconomist; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import io.vavr.control.Option; import jakarta.annotation.PostConstruct; @@ -74,23 +74,23 @@ public class MultiverseCorePlaceholders extends PlaceholderExpansion { } final var placeholder = paramsArray[0]; - Option targetWorld; + Option targetWorld; // If no world is defined, use the player's world if (paramsArray.length == 1) { if (!offlinePlayer.isOnline()) { return null; } - targetWorld = worldManager.getMVWorld(((Player)offlinePlayer).getWorld()); + targetWorld = worldManager.getLoadedWorld(((Player)offlinePlayer).getWorld()); } else { - targetWorld = worldManager.getMVWorld(paramsArray[1]); + targetWorld = worldManager.getLoadedWorld(paramsArray[1]); } // Fail if world is null return targetWorld.map(world -> getWorldPlaceHolderValue(placeholder, world)).getOrNull(); } - private @Nullable String getWorldPlaceHolderValue(@NotNull String placeholder, @NotNull MVWorld world) { + private @Nullable String getWorldPlaceHolderValue(@NotNull String placeholder, @NotNull LoadedMultiverseWorld world) { // Switch to find what specific placeholder we want switch (placeholder.toLowerCase()) { case "alias" -> { diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java b/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java index 82d9df46..a8117ad6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java @@ -2,7 +2,7 @@ package com.onarandombox.MultiverseCore.utils.metrics; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import com.onarandombox.MultiverseCore.worldnew.WorldManager; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; @@ -45,20 +45,20 @@ public class MetricsConfigurator { private void addCustomGeneratorsMetric() { addAdvancedPieMetric("custom_generators", map -> { - for (MVWorld w : worldManager.getMVWorlds()) { + for (LoadedMultiverseWorld w : worldManager.getLoadedWorlds()) { MetricsHelper.incrementCount(map, getGeneratorName(w)); } }); } - private String getGeneratorName(MVWorld world) { + private String getGeneratorName(LoadedMultiverseWorld world) { String gen = world.getGenerator(); return (gen != null && !gen.equalsIgnoreCase("null")) ? gen.split(":")[0] : NO_GENERATOR_NAME; } private void addEnvironmentsMetric() { addAdvancedPieMetric("environments", map -> { - for (MVWorld w : worldManager.getMVWorlds()) { + for (LoadedMultiverseWorld w : worldManager.getLoadedWorlds()) { MetricsHelper.incrementCount(map, titleCaseEnv(w.getEnvironment())); } }); @@ -71,8 +71,8 @@ public class MetricsConfigurator { private void addWorldCountMetric() { addMultiLineMetric("world_count", map -> { - map.put("Loaded worlds", worldManager.getMVWorlds().size()); - map.put("Total number of worlds", worldManager.getOfflineWorlds().size()); + map.put("Loaded worlds", worldManager.getLoadedWorlds().size()); + map.put("Total number of worlds", worldManager.getWorlds().size()); }); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java similarity index 98% rename from src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java rename to src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java index 13800697..fa76de7c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull; import java.util.UUID; -public class MVWorld extends OfflineWorld { +public class LoadedMultiverseWorld extends MultiverseWorld { private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16; private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16; @@ -26,7 +26,7 @@ public class MVWorld extends OfflineWorld { private final SafeTTeleporter safeTTeleporter; private final LocationManipulation locationManipulation; - MVWorld( + LoadedMultiverseWorld( @NotNull World world, @NotNull WorldConfig worldConfig, @NotNull BlockSafety blockSafety, diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java similarity index 98% rename from src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java rename to src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java index d4d8ebc9..dfdb7c02 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java @@ -15,12 +15,12 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; -public class OfflineWorld { +public class MultiverseWorld { protected final String worldName; protected WorldConfig worldConfig; - OfflineWorld(String worldName, WorldConfig worldConfig) { + MultiverseWorld(String worldName, WorldConfig worldConfig) { this.worldName = worldName; this.worldConfig = worldConfig; } @@ -201,7 +201,7 @@ public class OfflineWorld { return worldConfig.setRespawnWorld(respawnWorld.getName()); } - public Try setRespawnWorld(OfflineWorld respawnWorld) { + public Try setRespawnWorld(MultiverseWorld respawnWorld) { return worldConfig.setRespawnWorld(respawnWorld.getName()); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java index b04b228c..8e1f0dcb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java @@ -55,8 +55,8 @@ import static com.onarandombox.MultiverseCore.worldnew.helpers.DataStore.WorldCo public class WorldManager { private static final List CLONE_IGNORE_FILES = Arrays.asList("uid.dat", "session.lock"); - private final Map offlineWorldsMap; - private final Map worldsMap; + private final Map offlineWorldsMap; + private final Map worldsMap; private final List unloadTracker; private final List loadTracker; private final WorldsConfigManager worldsConfigManager; @@ -114,12 +114,12 @@ public class WorldManager { return false; } worldsConfigManager.getAllWorldConfigs().forEach(worldConfig -> { - getMVWorld(worldConfig.getWorldName()) - .peek(mvWorld -> mvWorld.setWorldConfig(worldConfig)); - getOfflineWorld(worldConfig.getWorldName()) - .peek(offlineWorld -> offlineWorld.setWorldConfig(worldConfig)) + getLoadedWorld(worldConfig.getWorldName()) + .peek(loadedWorld -> loadedWorld.setWorldConfig(worldConfig)); + getWorld(worldConfig.getWorldName()) + .peek(unloadedWorld -> unloadedWorld.setWorldConfig(worldConfig)) .onEmpty(() -> { - OfflineWorld offlineWorld = new OfflineWorld(worldConfig.getWorldName(), worldConfig); + MultiverseWorld offlineWorld = new MultiverseWorld(worldConfig.getWorldName(), worldConfig); offlineWorldsMap.put(offlineWorld.getName(), offlineWorld); }); }); @@ -130,13 +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 -> { - if (isOfflineWorld(world.getName())) { + Bukkit.getWorlds().forEach(bukkitWorld -> { + if (isWorld(bukkitWorld.getName())) { return; } - importWorld(ImportWorldOptions.worldName(world.getName()) - .environment(world.getEnvironment()) - .generator(generatorProvider.getDefaultGeneratorForWorld(world.getName()))); + importWorld(ImportWorldOptions.worldName(bukkitWorld.getName()) + .environment(bukkitWorld.getEnvironment()) + .generator(generatorProvider.getDefaultGeneratorForWorld(bukkitWorld.getName()))); }); } @@ -144,8 +144,8 @@ public class WorldManager { * Loads all worlds that are set to autoload. */ private void autoLoadOfflineWorlds() { - getOfflineWorlds().forEach(world -> { - if (isMVWorld(world) || !world.getAutoLoad()) { + getWorlds().forEach(world -> { + if (isLoadedWorld(world) || !world.getAutoLoad()) { return; } loadWorld(world).onFailure(failure -> Logging.severe("Failed to load world %s: %s", world.getName(), failure)); @@ -163,11 +163,11 @@ public class WorldManager { return Result.failure(CreateWorldResult.Failure.INVALID_WORLDNAME, replace("{world}").with(options.worldName())); } - if (getMVWorld(options.worldName()).isDefined()) { + if (getLoadedWorld(options.worldName()).isDefined()) { return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(options.worldName())); } - if (getOfflineWorld(options.worldName()).isDefined()) { + if (getWorld(options.worldName()).isDefined()) { return Result.failure(CreateWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(options.worldName())); } @@ -211,11 +211,11 @@ public class WorldManager { return Result.failure(ImportWorldResult.Failure.WORLD_FOLDER_INVALID, replace("{world}").with(options.worldName())); } - if (isMVWorld(options.worldName())) { + if (isLoadedWorld(options.worldName())) { return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(options.worldName())); } - if (isOfflineWorld(options.worldName())) { + if (isWorld(options.worldName())) { return Result.failure(ImportWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(options.worldName())); } @@ -246,10 +246,10 @@ public class WorldManager { worldConfig.setAdjustSpawn(adjustSpawn); worldConfig.setGenerator(generator == null ? "" : generator); - OfflineWorld offlineWorld = new OfflineWorld(world.getName(), worldConfig); + MultiverseWorld offlineWorld = new MultiverseWorld(world.getName(), worldConfig); offlineWorldsMap.put(offlineWorld.getName(), offlineWorld); - MVWorld mvWorld = new MVWorld(world, worldConfig, blockSafety, safeTTeleporter, locationManipulation); + LoadedMultiverseWorld mvWorld = new LoadedMultiverseWorld(world, worldConfig, blockSafety, safeTTeleporter, locationManipulation); worldsMap.put(mvWorld.getName(), mvWorld); saveWorldsConfig(); } @@ -261,7 +261,7 @@ public class WorldManager { * @return The result of the load. */ public Result loadWorld(@NotNull String worldName) { - return getOfflineWorld(worldName) + return getWorld(worldName) .map(this::loadWorld) .getOrElse(() -> worldNameChecker.isValidWorldFolder(worldName) ? Result.failure(LoadWorldResult.Failure.WORLD_EXIST_FOLDER, @@ -276,7 +276,7 @@ public class WorldManager { * @param offlineWorld The offline world to load. * @return The result of the load. */ - public Result loadWorld(@NotNull OfflineWorld offlineWorld) { + public Result loadWorld(@NotNull MultiverseWorld offlineWorld) { // Params validations if (loadTracker.contains(offlineWorld.getName())) { // This is to prevent recursive calls by WorldLoadEvent @@ -284,7 +284,7 @@ public class WorldManager { return Result.failure(LoadWorldResult.Failure.WORLD_ALREADY_LOADING, replace("{world}").with(offlineWorld.getName())); } - if (isMVWorld(offlineWorld)) { + if (isLoadedWorld(offlineWorld)) { Logging.severe("World already loaded: " + offlineWorld.getName()); return Result.failure(LoadWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(offlineWorld.getName())); @@ -299,7 +299,7 @@ public class WorldManager { replace("{error}").with(exception.getMessage())), world -> { WorldConfig worldConfig = worldsConfigManager.getWorldConfig(offlineWorld.getName()); - MVWorld mvWorld = new MVWorld(world, worldConfig, blockSafety, + LoadedMultiverseWorld mvWorld = new LoadedMultiverseWorld(world, worldConfig, blockSafety, safeTTeleporter, locationManipulation); worldsMap.put(mvWorld.getName(), mvWorld); saveWorldsConfig(); @@ -325,9 +325,9 @@ public class WorldManager { * @return The result of the unload action. */ public Result unloadWorld(@NotNull String worldName) { - return getMVWorld(worldName) + return getLoadedWorld(worldName) .map(this::unloadWorld) - .getOrElse(() -> isOfflineOnlyWorld(worldName) + .getOrElse(() -> isUnloadedWorld(worldName) ? Result.failure(UnloadWorldResult.Failure.WORLD_OFFLINE, replace("{world}").with(worldName)) : Result.failure(UnloadWorldResult.Failure.WORLD_NON_EXISTENT, @@ -340,7 +340,7 @@ public class WorldManager { * @param world The multiverse world to unload. * @return The result of the unload action. */ - public Result unloadWorld(@NotNull MVWorld world) { + public Result unloadWorld(@NotNull LoadedMultiverseWorld world) { if (unloadTracker.contains(world.getName())) { // This is to prevent recursive calls by WorldUnloadEvent Logging.fine("World already unloading: " + world.getName()); @@ -376,7 +376,7 @@ public class WorldManager { * @return The result of the remove. */ public Result removeWorld(@NotNull String worldName) { - return getOfflineWorld(worldName) + return getWorld(worldName) .map(this::removeWorld) .getOrElse(() -> Result.failure(RemoveWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName))); } @@ -388,8 +388,8 @@ public class WorldManager { * @param world The multiverse world to remove. * @return The result of the remove. */ - public Result removeWorld(@NotNull OfflineWorld world) { - return getMVWorld(world).fold( + public Result removeWorld(@NotNull MultiverseWorld world) { + return getLoadedWorld(world).fold( () -> removeWorldFromConfig(world), this::removeWorld); } @@ -401,7 +401,7 @@ public class WorldManager { * @param world The multiverse world to remove. * @return The result of the remove. */ - public Result removeWorld(@NotNull MVWorld world) { + public Result removeWorld(@NotNull LoadedMultiverseWorld world) { var result = unloadWorld(world); if (result.isFailure()) { return Result.failure(RemoveWorldResult.Failure.UNLOAD_FAILED, result.getReasonMessage()); @@ -416,7 +416,7 @@ public class WorldManager { * @return The result of the remove. */ private Result - removeWorldFromConfig(@NotNull OfflineWorld world) { + removeWorldFromConfig(@NotNull MultiverseWorld world) { // Remove world from config offlineWorldsMap.remove(world.getName()); worldsConfigManager.deleteWorldConfig(world.getName()); @@ -433,7 +433,7 @@ public class WorldManager { * @return The result of the delete action. */ public Result deleteWorld(@NotNull String worldName) { - return getOfflineWorld(worldName) + return getWorld(worldName) .map(this::deleteWorld) .getOrElse(() -> Result.failure(DeleteWorldResult.Failure.WORLD_NON_EXISTENT, replace("{world}").with(worldName))); @@ -446,8 +446,8 @@ public class WorldManager { * @param world The offline world to delete. * @return The result of the delete action. */ - public Result deleteWorld(@NotNull OfflineWorld world) { - return getMVWorld(world).fold( + public Result deleteWorld(@NotNull MultiverseWorld world) { + return getLoadedWorld(world).fold( () -> { var result = loadWorld(world); if (result.isFailure()) { @@ -465,7 +465,7 @@ public class WorldManager { * @param world The multiverse world to delete. * @return The result of the delete action. */ - public Result deleteWorld(@NotNull MVWorld world) { + public Result deleteWorld(@NotNull LoadedMultiverseWorld world) { 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()); @@ -503,7 +503,7 @@ public class WorldManager { .fold( failure -> Result.failure(CloneWorldResult.Failure.IMPORT_FAILED, failure.getReasonMessage()), success -> Result.success())) - .onSuccessThen(s -> getMVWorld(options.newWorldName()).fold( + .onSuccessThen(s -> getLoadedWorld(options.newWorldName()).fold( () -> Result.failure(CloneWorldResult.Failure.MV_WORLD_FAILED, replace("{world}").with(options.newWorldName())), mvWorld -> { @@ -525,11 +525,11 @@ public class WorldManager { if (worldNameChecker.isValidWorldFolder(newWorldName)) { return Result.failure(CloneWorldResult.Failure.WORLD_EXIST_FOLDER, replace("{world}").with(newWorldName)); } - if (isMVWorld(newWorldName)) { + if (isLoadedWorld(newWorldName)) { Logging.severe("World already loaded: " + newWorldName); return Result.failure(CloneWorldResult.Failure.WORLD_EXIST_LOADED, replace("{world}").with(newWorldName)); } - if (isOfflineWorld(newWorldName)) { + if (isWorld(newWorldName)) { Logging.severe("World already exist offline: " + newWorldName); return Result.failure(CloneWorldResult.Failure.WORLD_EXIST_OFFLINE, replace("{world}").with(newWorldName)); } @@ -547,9 +547,9 @@ public class WorldManager { success -> Result.success()); } - private void cloneWorldTransferData(@NotNull CloneWorldOptions options, @NotNull MVWorld newWorld) { - MVWorld world = options.world(); - DataTransfer dataTransfer = new DataTransfer<>(); + private void cloneWorldTransferData(@NotNull CloneWorldOptions options, @NotNull LoadedMultiverseWorld newWorld) { + LoadedMultiverseWorld world = options.world(); + DataTransfer dataTransfer = new DataTransfer<>(); if (options.keepWorldConfig()) { dataTransfer.addDataStore(new WorldConfigStore(), world); } @@ -569,9 +569,9 @@ public class WorldManager { */ public Result regenWorld(@NotNull RegenWorldOptions options) { // TODO: Teleport players out of world, and back in after regen - MVWorld world = options.world(); + LoadedMultiverseWorld world = options.world(); - DataTransfer dataTransfer = new DataTransfer<>(); + DataTransfer dataTransfer = new DataTransfer<>(); if (options.keepWorldConfig()) { dataTransfer.addDataStore(new WorldConfigStore(), world); } @@ -599,7 +599,7 @@ public class WorldManager { return Result.failure(RegenWorldResult.Failure.CREATE_FAILED, createResult.getReasonMessage()); } - getMVWorld(createWorldOptions.worldName()).peek(newWorld -> { + getLoadedWorld(createWorldOptions.worldName()).peek(newWorld -> { dataTransfer.pasteAllTo(newWorld); saveWorldsConfig(); }); @@ -667,7 +667,7 @@ public class WorldManager { return Collections.emptyList(); } return Arrays.stream(files) - .filter(file -> !isOfflineWorld(file.getName())) + .filter(file -> !isWorld(file.getName())) .filter(worldNameChecker::isValidWorldFolder) .map(File::getName) .toList(); @@ -679,8 +679,8 @@ public class WorldManager { * @param worldName The name of the world to get. * @return The offline world if it exists. */ - public Option getOfflineOnlyWorld(@Nullable String worldName) { - return isMVWorld(worldName) ? Option.none() : Option.of(offlineWorldsMap.get(worldName)); + public Option getUnloadedWorld(@Nullable String worldName) { + return isLoadedWorld(worldName) ? Option.none() : Option.of(offlineWorldsMap.get(worldName)); } /** @@ -688,7 +688,7 @@ public class WorldManager { * * @return A list of all offline worlds that are not loaded. */ - public Collection getOfflineOnlyWorlds() { + public Collection getUnloadedWorlds() { return offlineWorldsMap.values().stream().filter(world -> !world.isLoaded()).toList(); } @@ -698,8 +698,8 @@ public class WorldManager { * @param worldName The name of the world to check. * @return True if the world is an offline world that is not loaded. */ - public boolean isOfflineOnlyWorld(@Nullable String worldName) { - return !isMVWorld(worldName) && isOfflineWorld(worldName); + public boolean isUnloadedWorld(@Nullable String worldName) { + return !isLoadedWorld(worldName) && isWorld(worldName); } /** @@ -708,7 +708,7 @@ public class WorldManager { * @param worldName The name of the world to get. * @return The offline world if it exists. */ - public Option getOfflineWorld(@Nullable String worldName) { + public Option getWorld(@Nullable String worldName) { return Option.of(offlineWorldsMap.get(worldName)); } @@ -717,7 +717,7 @@ public class WorldManager { * * @return A list of all offline worlds that may or may not be loaded. */ - public Collection getOfflineWorlds() { + public Collection getWorlds() { return offlineWorldsMap.values(); } @@ -727,7 +727,7 @@ public class WorldManager { * @param worldName The name of the world to check. * @return True if the world is an offline world that may or may not be loaded. */ - public boolean isOfflineWorld(@Nullable String worldName) { + public boolean isWorld(@Nullable String worldName) { return offlineWorldsMap.containsKey(worldName); } @@ -737,7 +737,7 @@ public class WorldManager { * @param world The bukkit world that should be loaded. * @return The multiverse world if it exists. */ - public Option getMVWorld(@Nullable World world) { + public Option getLoadedWorld(@Nullable World world) { return world == null ? Option.none() : Option.of(worldsMap.get(world.getName())); } @@ -747,7 +747,7 @@ public class WorldManager { * @param world The offline world that should be loaded. * @return The multiverse world if it exists. */ - public Option getMVWorld(@Nullable OfflineWorld world) { + public Option getLoadedWorld(@Nullable MultiverseWorld world) { return world == null ? Option.none() : Option.of(worldsMap.get(world.getName())); } @@ -757,7 +757,7 @@ public class WorldManager { * @param worldName The name of the world to get. * @return The multiverse world if it exists. */ - public Option getMVWorld(@Nullable String worldName) { + public Option getLoadedWorld(@Nullable String worldName) { return Option.of(worldsMap.get(worldName)); } @@ -766,7 +766,7 @@ public class WorldManager { * * @return A list of all multiverse worlds that are loaded. */ - public Collection getMVWorlds() { + public Collection getLoadedWorlds() { return worldsMap.values(); } @@ -776,8 +776,8 @@ public class WorldManager { * @param world The bukkit world to check. * @return True if the world is a multiverse world that is loaded. */ - public boolean isMVWorld(@Nullable World world) { - return world != null && isMVWorld(world.getName()); + public boolean isLoadedWorld(@Nullable World world) { + return world != null && isLoadedWorld(world.getName()); } /** @@ -786,8 +786,8 @@ public class WorldManager { * @param world The offline world to check. * @return True if the world is a multiverse world that is loaded. */ - public boolean isMVWorld(@Nullable OfflineWorld world) { - return world != null && isMVWorld(world.getName()); + public boolean isLoadedWorld(@Nullable MultiverseWorld world) { + return world != null && isLoadedWorld(world.getName()); } /** @@ -796,7 +796,7 @@ public class WorldManager { * @param worldName The name of the world to check. * @return True if the world is a multiverse world that is loaded. */ - public boolean isMVWorld(@Nullable String worldName) { + public boolean isLoadedWorld(@Nullable String worldName) { return worldsMap.containsKey(worldName); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java index 0fe90deb..f2f1b653 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java @@ -35,16 +35,16 @@ public class WorldPurger { } catch (ClassNotFoundException ignore) { } } - public void purgeWorlds(List worlds) { + public void purgeWorlds(List worlds) { if (worlds == null || worlds.isEmpty()) { return; } - for (MVWorld world : worlds) { + for (LoadedMultiverseWorld world : worlds) { this.purgeWorld(world); } } - public void purgeWorld(MVWorld world) { + public void purgeWorld(LoadedMultiverseWorld world) { if (world == null) { return; } @@ -53,14 +53,14 @@ public class WorldPurger { purgeWorld(world, allMobs, !world.getSpawningAnimals(), !world.getSpawningMonsters()); } - public boolean shouldWeKillThisCreature(MVWorld world, Entity e) { + public boolean shouldWeKillThisCreature(LoadedMultiverseWorld world, Entity e) { ArrayList allMobs = new ArrayList(world.getSpawningAnimalsExceptions()); allMobs.addAll(world.getSpawningMonstersExceptions()); return this.shouldWeKillThisCreature(e, allMobs, !world.getSpawningAnimals(), !world.getSpawningMonsters()); } - public void purgeWorld(MVWorld mvworld, List thingsToKill, - boolean negateAnimals, boolean negateMonsters, CommandSender sender) { + public void purgeWorld(LoadedMultiverseWorld mvworld, List thingsToKill, + boolean negateAnimals, boolean negateMonsters, CommandSender sender) { if (mvworld == null) { return; } @@ -156,7 +156,7 @@ public class WorldPurger { return this.killDecision(e, thingsToKill, negateAnimals, negateMonsters, specifiedAnimals, specifiedMonsters); } - public void purgeWorld(MVWorld mvworld, List thingsToKill, boolean negateAnimals, boolean negateMonsters) { + public void purgeWorld(LoadedMultiverseWorld mvworld, List thingsToKill, boolean negateAnimals, boolean negateMonsters) { purgeWorld(mvworld, thingsToKill, negateAnimals, negateMonsters, null); } } 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 e86e0be6..e3e14c18 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java @@ -3,7 +3,7 @@ package com.onarandombox.MultiverseCore.worldnew.config; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.configuration.handle.ConfigurationSectionHandle; import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import io.vavr.control.Try; import org.bukkit.Difficulty; import org.bukkit.GameMode; @@ -294,7 +294,7 @@ public final class WorldConfig { return configHandle.set(configNodes.WORLD_BLACKLIST, worldBlacklist); } - public void setMVWorld(@NotNull MVWorld world) { + public void setMVWorld(@NotNull LoadedMultiverseWorld world) { configNodes.world = world; } 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 66ef14db..53276948 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java @@ -4,7 +4,7 @@ import com.onarandombox.MultiverseCore.configuration.node.ConfigNode; import com.onarandombox.MultiverseCore.configuration.node.Node; import com.onarandombox.MultiverseCore.configuration.node.NodeGroup; import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import org.bukkit.Difficulty; import org.bukkit.GameMode; import org.bukkit.Location; @@ -16,7 +16,7 @@ import java.util.List; public class WorldConfigNodes { private final NodeGroup nodes = new NodeGroup(); - MVWorld world = null; + LoadedMultiverseWorld world = null; WorldConfigNodes() { } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/entrycheck/WorldEntryChecker.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/entrycheck/WorldEntryChecker.java index ab3d8cba..47b7faae 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/entrycheck/WorldEntryChecker.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/entrycheck/WorldEntryChecker.java @@ -6,8 +6,8 @@ import com.onarandombox.MultiverseCore.permissions.CorePermissionsChecker; import com.onarandombox.MultiverseCore.utils.result.Result; import com.onarandombox.MultiverseCore.utils.result.ResultChain; import com.onarandombox.MultiverseCore.world.configuration.EntryFee; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; -import com.onarandombox.MultiverseCore.worldnew.OfflineWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; +import com.onarandombox.MultiverseCore.worldnew.MultiverseWorld; import org.bukkit.Material; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; @@ -37,11 +37,11 @@ public class WorldEntryChecker { this.sender = sender; } - public ResultChain canStayInWorld(@NotNull MVWorld world) { + public ResultChain canStayInWorld(@NotNull LoadedMultiverseWorld world) { return canEnterWorld(null, world); } - public ResultChain canEnterWorld(@Nullable MVWorld fromWorld, @NotNull MVWorld toWorld) { + public ResultChain canEnterWorld(@Nullable LoadedMultiverseWorld fromWorld, @NotNull LoadedMultiverseWorld toWorld) { return ResultChain.builder() .then(() -> canAccessWorld(toWorld)) .then(() -> isWithinPlayerLimit(toWorld)) @@ -50,7 +50,7 @@ public class WorldEntryChecker { .build(); } - public Result canAccessWorld(@NotNull OfflineWorld world) { + public Result canAccessWorld(@NotNull MultiverseWorld world) { if (!config.getEnforceAccess()) { return Result.success(WorldAccessResult.Success.NO_ENFORCE_WORLD_ACCESS); } @@ -59,7 +59,7 @@ public class WorldEntryChecker { : Result.failure(WorldAccessResult.Failure.NO_WORLD_ACCESS); } - public Result isWithinPlayerLimit(@NotNull MVWorld world) { + public Result isWithinPlayerLimit(@NotNull LoadedMultiverseWorld world) { final int playerLimit = world.getPlayerLimit(); if (playerLimit <= -1) { return Result.success(PlayerLimitResult.Success.NO_PLAYERLIMIT); @@ -72,7 +72,7 @@ public class WorldEntryChecker { : Result.failure(PlayerLimitResult.Failure.EXCEED_PLAYERLIMIT); } - public Result isNotBlacklisted(@Nullable MVWorld fromWorld, @NotNull MVWorld toWorld) { + public Result isNotBlacklisted(@Nullable LoadedMultiverseWorld fromWorld, @NotNull LoadedMultiverseWorld toWorld) { if (fromWorld == null) { return Result.success(BlacklistResult.Success.UNKNOWN_FROM_WORLD); } @@ -81,7 +81,7 @@ public class WorldEntryChecker { : Result.success(BlacklistResult.Success.NOT_BLACKLISTED); } - public Result canPayEntryFee(MVWorld world) { + public Result canPayEntryFee(LoadedMultiverseWorld world) { double price = world.getPrice(); Material currency = world.getCurrency(); if (price == 0D && (currency == null || currency == EntryFee.DISABLED_MATERIAL)) { 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 bddf4ac3..b91a29ea 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java @@ -1,7 +1,7 @@ package com.onarandombox.MultiverseCore.worldnew.helpers; import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import org.bukkit.GameRule; import org.bukkit.World; import org.jvnet.hk2.annotations.Service; @@ -33,14 +33,14 @@ public interface DataStore { */ DataStore pasteTo(T object); - class GameRulesStore implements DataStore { + class GameRulesStore implements DataStore { private Map, Object> gameRuleMap; /** * {@inheritDoc} */ @Override - public GameRulesStore copyFrom(MVWorld world) { + public GameRulesStore copyFrom(LoadedMultiverseWorld world) { this.gameRuleMap = new HashMap<>(); world.getBukkitWorld().peek(bukkitWorld -> { Arrays.stream(GameRule.values()).forEach(gameRule -> { @@ -55,7 +55,7 @@ public interface DataStore { * {@inheritDoc} */ @Override - public GameRulesStore pasteTo(MVWorld world) { + public GameRulesStore pasteTo(LoadedMultiverseWorld world) { if (gameRuleMap == null) { return this; } @@ -79,14 +79,14 @@ public interface DataStore { } } - class WorldConfigStore implements DataStore { + class WorldConfigStore implements DataStore { private Map configMap; /** * {@inheritDoc} */ @Override - public WorldConfigStore copyFrom(MVWorld world) { + public WorldConfigStore copyFrom(LoadedMultiverseWorld world) { this.configMap = new HashMap<>(); world.getConfigurablePropertyNames().forEach(name -> { world.getProperty(name).peek(value -> configMap.put(name, value)).onFailure(e -> { @@ -100,7 +100,7 @@ public interface DataStore { * {@inheritDoc} */ @Override - public WorldConfigStore pasteTo(MVWorld world) { + public WorldConfigStore pasteTo(LoadedMultiverseWorld world) { if (configMap == null) { return this; } @@ -114,7 +114,7 @@ public interface DataStore { } } - class WorldBorderStore implements DataStore { + class WorldBorderStore implements DataStore { private double borderCenterX; private double borderCenterZ; private double borderDamageAmount; @@ -126,7 +126,7 @@ public interface DataStore { * {@inheritDoc} */ @Override - public WorldBorderStore copyFrom(MVWorld world) { + public WorldBorderStore copyFrom(LoadedMultiverseWorld world) { world.getBukkitWorld().peek(bukkitWorld -> { borderCenterX = bukkitWorld.getWorldBorder().getCenter().getX(); borderCenterZ = bukkitWorld.getWorldBorder().getCenter().getZ(); @@ -142,7 +142,7 @@ public interface DataStore { * {@inheritDoc} */ @Override - public WorldBorderStore pasteTo(MVWorld world) { + public WorldBorderStore pasteTo(LoadedMultiverseWorld world) { world.getBukkitWorld().peek(bukkitWorld -> { bukkitWorld.getWorldBorder().setCenter(borderCenterX, borderCenterZ); bukkitWorld.getWorldBorder().setDamageAmount(borderDamageAmount); diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java index 47be5d18..8552f7f4 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java @@ -1,26 +1,26 @@ package com.onarandombox.MultiverseCore.worldnew.options; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import org.jetbrains.annotations.NotNull; public class CloneWorldOptions { - public static CloneWorldOptions fromTo(MVWorld world, String newWorldName) { + public static CloneWorldOptions fromTo(LoadedMultiverseWorld world, String newWorldName) { return new CloneWorldOptions(world, newWorldName); } - private final MVWorld world; + private final LoadedMultiverseWorld world; private final String newWorldName; private boolean keepGameRule = true; private boolean keepWorldConfig = true; private boolean keepWorldBorder = true; - public CloneWorldOptions(MVWorld world, String newWorldName) { + public CloneWorldOptions(LoadedMultiverseWorld world, String newWorldName) { this.world = world; this.newWorldName = newWorldName; } - public MVWorld world() { + public LoadedMultiverseWorld world() { return world; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java index 8cd3d86a..e24ad9c9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java @@ -1,17 +1,17 @@ package com.onarandombox.MultiverseCore.worldnew.options; -import com.onarandombox.MultiverseCore.worldnew.MVWorld; +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Random; public class RegenWorldOptions { - public static @NotNull RegenWorldOptions world(@NotNull MVWorld world) { + public static @NotNull RegenWorldOptions world(@NotNull LoadedMultiverseWorld world) { return new RegenWorldOptions(world); } - private final MVWorld world; + private final LoadedMultiverseWorld world; private boolean keepGameRule = true; private boolean keepWorldConfig = true; @@ -19,11 +19,11 @@ public class RegenWorldOptions { private boolean randomSeed = false; private long seed = Long.MIN_VALUE; - RegenWorldOptions(@NotNull MVWorld world) { + RegenWorldOptions(@NotNull LoadedMultiverseWorld world) { this.world = world; } - public @NotNull MVWorld world() { + public @NotNull LoadedMultiverseWorld world() { return world; } diff --git a/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt b/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt index c6ce62af..19237c50 100644 --- a/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt @@ -1,6 +1,6 @@ package org.mvplugins.multiverse.core.world -import com.onarandombox.MultiverseCore.worldnew.MVWorld +import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld import com.onarandombox.MultiverseCore.worldnew.WorldManager import com.onarandombox.MultiverseCore.worldnew.options.CreateWorldOptions import org.bukkit.World @@ -15,7 +15,7 @@ import kotlin.test.assertNotNull class WorldManagerTest : TestWithMockBukkit() { private lateinit var worldManager: WorldManager - private lateinit var world: MVWorld + private lateinit var world: LoadedMultiverseWorld @BeforeTest fun setUp() { @@ -23,7 +23,7 @@ class WorldManagerTest : TestWithMockBukkit() { throw IllegalStateException("WorldManager is not available as a service") } worldManager.createWorld(CreateWorldOptions.worldName("world")) - world = worldManager.getMVWorld("world").get() + world = worldManager.getLoadedWorld("world").get() assertNotNull(world) } @@ -37,7 +37,7 @@ class WorldManagerTest : TestWithMockBukkit() { .worldType(WorldType.FLAT) ) - val world = worldManager.getMVWorld("world_nether").get() + val world = worldManager.getLoadedWorld("world_nether").get() assertNotNull(world) assertEquals("world_nether", world.name) assertEquals(World.Environment.NETHER, world.getProperty("environment").get()) @@ -48,6 +48,6 @@ class WorldManagerTest : TestWithMockBukkit() { @Test fun `Delete world`() { worldManager.deleteWorld(world) - assertFalse(worldManager.getMVWorld("world").isDefined) + assertFalse(worldManager.getLoadedWorld("world").isDefined) } }