From 1f7b8ffa96a6e2d4835a09cbf014afde4cc454ae Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sat, 2 Sep 2023 22:30:06 +0800 Subject: [PATCH] Add remaining world properties methods --- .../MultiverseCore/worldnew/OfflineWorld.java | 145 +++++++++++++++++- .../MultiverseCore/worldnew/WorldManager.java | 6 +- .../worldnew/config/WorldConfig.java | 8 +- 3 files changed, 152 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java index c50fd882..db505050 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/OfflineWorld.java @@ -1,9 +1,14 @@ package com.onarandombox.MultiverseCore.worldnew; +import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType; import com.onarandombox.MultiverseCore.worldnew.config.WorldConfig; import io.vavr.control.Try; +import org.bukkit.Difficulty; +import org.bukkit.GameMode; import org.bukkit.World; +import java.util.List; + public class OfflineWorld { protected final String worldName; @@ -18,23 +23,159 @@ public class OfflineWorld { return worldName; } + public Try getProperty(String name) { + return worldConfig.getProperty(name); + } + public Try setProperty(String name, Object value) { return worldConfig.setProperty(name, value); } - public Try getProperty(String name) { - return worldConfig.getProperty(name); + public boolean getAdjustSpawn() { + return worldConfig.getAdjustSpawn(); + } + + public Try setAdjustSpawn(boolean adjustSpawn) { + return worldConfig.setAdjustSpawn(adjustSpawn); + } + + public String getAlias() { + return worldConfig.getAlias(); + } + + public Try setAlias(String alias) { + return worldConfig.setAlias(alias); + } + + public boolean getAllowFlight() { + return worldConfig.getAllowFlight(); + } + + public Try setAllowFlight(boolean allowFlight) { + return worldConfig.setAllowFlight(allowFlight); + } + + public boolean getAllowWeather() { + return worldConfig.getAllowWeather(); + } + + public Try setAllowWeather(boolean allowWeather) { + return worldConfig.setAllowWeather(allowWeather); + } + + public boolean getAutoHeal() { + return worldConfig.getAutoHeal(); + } + + public Try setAutoHeal(boolean autoHeal) { + return worldConfig.setAutoHeal(autoHeal); + } + + public boolean getAutoLoad() { + return worldConfig.getAutoLoad(); + } + + public Try setAutoLoad(boolean autoLoad) { + return worldConfig.setAutoLoad(autoLoad); + } + + public Difficulty getDifficulty() { + return worldConfig.getDifficulty(); + } + + public Try setDifficulty(Difficulty difficulty) { + return worldConfig.setDifficulty(difficulty); } public World.Environment getEnvironment() { return worldConfig.getEnvironment(); } + public GameMode getGameMode() { + return worldConfig.getGameMode(); + } + + public Try setGameMode(GameMode gameMode) { + return worldConfig.setGameMode(gameMode); + } + public String getGenerator() { return worldConfig.getGenerator(); } + public boolean isHidden() { + return worldConfig.isHidden(); + } + + public Try setHidden(boolean hidden) { + return worldConfig.setHidden(hidden); + } + + public boolean getHunger() { + return worldConfig.getHunger(); + } + + public Try setHunger(boolean hunger) { + return worldConfig.setHunger(hunger); + } + + public boolean getKeepSpawnInMemory() { + return worldConfig.getKeepSpawnInMemory(); + } + + public Try setKeepSpawnInMemory(boolean keepSpawnInMemory) { + return worldConfig.setKeepSpawnInMemory(keepSpawnInMemory); + } + + public int getPlayerLimit() { + return worldConfig.getPlayerLimit(); + } + + public Try setPlayerLimit(int playerLimit) { + return worldConfig.setPlayerLimit(playerLimit); + } + + public AllowedPortalType getPortalForm() { + return worldConfig.getPortalForm(); + } + + public Try setPortalForm(AllowedPortalType portalForm) { + return worldConfig.setPortalForm(portalForm); + } + + public boolean getPvp() { + return worldConfig.getPvp(); + } + + public Try setPvp(boolean pvp) { + return worldConfig.setPvp(pvp); + } + + public String getRespawnWorld() { + return worldConfig.getRespawnWorld(); + } + + public Try setRespawnWorld(String respawnWorld) { + return worldConfig.setRespawnWorld(respawnWorld); + } + + public double getScale() { + return worldConfig.getScale(); + } + + public Try setScale(double scale) { + return worldConfig.setScale(scale); + } + public long getSeed() { return worldConfig.getSeed(); } + + public List getWorldBlacklist() { + return worldConfig.getWorldBlacklist(); + } + + public Try setWorldBlacklist(List worldBlacklist) { + return worldConfig.setWorldBlacklist(worldBlacklist); + } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java index 7d4b6c34..28f503b3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldManager.java @@ -34,7 +34,11 @@ public class WorldManager { public void initAllWorlds() { populateOfflineWorlds(); - getOfflineWorlds().forEach(this::loadWorld); + getOfflineWorlds().forEach(offlineWorld -> { + if (offlineWorld.getAutoLoad()) { + loadWorld(offlineWorld); + } + }); saveWorldsConfig(); } 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 28e0770b..a5b27cda 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java @@ -111,11 +111,11 @@ public class WorldConfig { return configHandle.set(configNodes.ENVIRONMENT, environment); } - public GameMode getGamemode() { + public GameMode getGameMode() { return configHandle.get(configNodes.GAMEMODE); } - public Try setGamemode(GameMode gamemode) { + public Try setGameMode(GameMode gamemode) { return configHandle.set(configNodes.GAMEMODE, gamemode); } @@ -203,8 +203,8 @@ public class WorldConfig { return (List) configHandle.get(configNodes.WORLD_BLACKLIST); } - public void setWorldBlacklist(List worldBlacklist) { - configHandle.set(configNodes.WORLD_BLACKLIST, worldBlacklist); + public Try setWorldBlacklist(List worldBlacklist) { + return configHandle.set(configNodes.WORLD_BLACKLIST, worldBlacklist); } public void setMVWorld(@NotNull MVWorld world) {