Add remaining world properties methods

This commit is contained in:
Ben Woo 2023-09-02 22:30:06 +08:00
parent 35993419ca
commit 1f7b8ffa96
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
3 changed files with 152 additions and 7 deletions

View File

@ -1,9 +1,14 @@
package com.onarandombox.MultiverseCore.worldnew; package com.onarandombox.MultiverseCore.worldnew;
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
import com.onarandombox.MultiverseCore.worldnew.config.WorldConfig; import com.onarandombox.MultiverseCore.worldnew.config.WorldConfig;
import io.vavr.control.Try; import io.vavr.control.Try;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.World; import org.bukkit.World;
import java.util.List;
public class OfflineWorld { public class OfflineWorld {
protected final String worldName; protected final String worldName;
@ -18,23 +23,159 @@ public class OfflineWorld {
return worldName; return worldName;
} }
public Try<Object> getProperty(String name) {
return worldConfig.getProperty(name);
}
public Try<Void> setProperty(String name, Object value) { public Try<Void> setProperty(String name, Object value) {
return worldConfig.setProperty(name, value); return worldConfig.setProperty(name, value);
} }
public Try<Object> getProperty(String name) { public boolean getAdjustSpawn() {
return worldConfig.getProperty(name); return worldConfig.getAdjustSpawn();
}
public Try<Void> setAdjustSpawn(boolean adjustSpawn) {
return worldConfig.setAdjustSpawn(adjustSpawn);
}
public String getAlias() {
return worldConfig.getAlias();
}
public Try<Void> setAlias(String alias) {
return worldConfig.setAlias(alias);
}
public boolean getAllowFlight() {
return worldConfig.getAllowFlight();
}
public Try<Void> setAllowFlight(boolean allowFlight) {
return worldConfig.setAllowFlight(allowFlight);
}
public boolean getAllowWeather() {
return worldConfig.getAllowWeather();
}
public Try<Void> setAllowWeather(boolean allowWeather) {
return worldConfig.setAllowWeather(allowWeather);
}
public boolean getAutoHeal() {
return worldConfig.getAutoHeal();
}
public Try<Void> setAutoHeal(boolean autoHeal) {
return worldConfig.setAutoHeal(autoHeal);
}
public boolean getAutoLoad() {
return worldConfig.getAutoLoad();
}
public Try<Void> setAutoLoad(boolean autoLoad) {
return worldConfig.setAutoLoad(autoLoad);
}
public Difficulty getDifficulty() {
return worldConfig.getDifficulty();
}
public Try<Void> setDifficulty(Difficulty difficulty) {
return worldConfig.setDifficulty(difficulty);
} }
public World.Environment getEnvironment() { public World.Environment getEnvironment() {
return worldConfig.getEnvironment(); return worldConfig.getEnvironment();
} }
public GameMode getGameMode() {
return worldConfig.getGameMode();
}
public Try<Void> setGameMode(GameMode gameMode) {
return worldConfig.setGameMode(gameMode);
}
public String getGenerator() { public String getGenerator() {
return worldConfig.getGenerator(); return worldConfig.getGenerator();
} }
public boolean isHidden() {
return worldConfig.isHidden();
}
public Try<Void> setHidden(boolean hidden) {
return worldConfig.setHidden(hidden);
}
public boolean getHunger() {
return worldConfig.getHunger();
}
public Try<Void> setHunger(boolean hunger) {
return worldConfig.setHunger(hunger);
}
public boolean getKeepSpawnInMemory() {
return worldConfig.getKeepSpawnInMemory();
}
public Try<Void> setKeepSpawnInMemory(boolean keepSpawnInMemory) {
return worldConfig.setKeepSpawnInMemory(keepSpawnInMemory);
}
public int getPlayerLimit() {
return worldConfig.getPlayerLimit();
}
public Try<Void> setPlayerLimit(int playerLimit) {
return worldConfig.setPlayerLimit(playerLimit);
}
public AllowedPortalType getPortalForm() {
return worldConfig.getPortalForm();
}
public Try<Void> setPortalForm(AllowedPortalType portalForm) {
return worldConfig.setPortalForm(portalForm);
}
public boolean getPvp() {
return worldConfig.getPvp();
}
public Try<Void> setPvp(boolean pvp) {
return worldConfig.setPvp(pvp);
}
public String getRespawnWorld() {
return worldConfig.getRespawnWorld();
}
public Try<Void> setRespawnWorld(String respawnWorld) {
return worldConfig.setRespawnWorld(respawnWorld);
}
public double getScale() {
return worldConfig.getScale();
}
public Try<Void> setScale(double scale) {
return worldConfig.setScale(scale);
}
public long getSeed() { public long getSeed() {
return worldConfig.getSeed(); return worldConfig.getSeed();
} }
public List<String> getWorldBlacklist() {
return worldConfig.getWorldBlacklist();
}
public Try<Void> setWorldBlacklist(List<String> worldBlacklist) {
return worldConfig.setWorldBlacklist(worldBlacklist);
}
} }

View File

@ -34,7 +34,11 @@ public class WorldManager {
public void initAllWorlds() { public void initAllWorlds() {
populateOfflineWorlds(); populateOfflineWorlds();
getOfflineWorlds().forEach(this::loadWorld); getOfflineWorlds().forEach(offlineWorld -> {
if (offlineWorld.getAutoLoad()) {
loadWorld(offlineWorld);
}
});
saveWorldsConfig(); saveWorldsConfig();
} }

View File

@ -111,11 +111,11 @@ public class WorldConfig {
return configHandle.set(configNodes.ENVIRONMENT, environment); return configHandle.set(configNodes.ENVIRONMENT, environment);
} }
public GameMode getGamemode() { public GameMode getGameMode() {
return configHandle.get(configNodes.GAMEMODE); return configHandle.get(configNodes.GAMEMODE);
} }
public Try<Void> setGamemode(GameMode gamemode) { public Try<Void> setGameMode(GameMode gamemode) {
return configHandle.set(configNodes.GAMEMODE, gamemode); return configHandle.set(configNodes.GAMEMODE, gamemode);
} }
@ -203,8 +203,8 @@ public class WorldConfig {
return (List<String>) configHandle.get(configNodes.WORLD_BLACKLIST); return (List<String>) configHandle.get(configNodes.WORLD_BLACKLIST);
} }
public void setWorldBlacklist(List<String> worldBlacklist) { public Try<Void> setWorldBlacklist(List<String> worldBlacklist) {
configHandle.set(configNodes.WORLD_BLACKLIST, worldBlacklist); return configHandle.set(configNodes.WORLD_BLACKLIST, worldBlacklist);
} }
public void setMVWorld(@NotNull MVWorld world) { public void setMVWorld(@NotNull MVWorld world) {