mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-10 10:17:41 +01:00
Add entryfee, spawning and spawn location
This commit is contained in:
parent
1f7b8ffa96
commit
7828c92926
@ -7,6 +7,8 @@ import com.onarandombox.MultiverseCore.worldnew.MVWorld;
|
||||
import io.vavr.control.Try;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -103,6 +105,22 @@ public class WorldConfig {
|
||||
return configHandle.set(configNodes.DIFFICULTY, difficulty);
|
||||
}
|
||||
|
||||
public double getEntryFeeAmount() {
|
||||
return configHandle.get(configNodes.ENTRY_FEE_AMOUNT);
|
||||
}
|
||||
|
||||
public Try<Void> setEntryFeeAmount(double entryFeeAmount) {
|
||||
return configHandle.set(configNodes.ENTRY_FEE_AMOUNT, entryFeeAmount);
|
||||
}
|
||||
|
||||
public Material getEntryFeeCurrency() {
|
||||
return configHandle.get(configNodes.ENTRY_FEE_CURRENCY);
|
||||
}
|
||||
|
||||
public Try<Void> setEntryFeeCurrency(Material entryFeeCurrency) {
|
||||
return configHandle.set(configNodes.ENTRY_FEE_CURRENCY, entryFeeCurrency);
|
||||
}
|
||||
|
||||
public World.Environment getEnvironment() {
|
||||
return configHandle.get(configNodes.ENVIRONMENT);
|
||||
}
|
||||
@ -199,8 +217,64 @@ public class WorldConfig {
|
||||
return configHandle.set(configNodes.SEED, seed);
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
return configHandle.get(configNodes.SPAWN_LOCATION);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawnLocation(Location spawnLocation) {
|
||||
return configHandle.set(configNodes.SPAWN_LOCATION, spawnLocation);
|
||||
}
|
||||
|
||||
public boolean getSpawningAnimals() {
|
||||
return configHandle.get(configNodes.SPAWNING_ANIMALS);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawningAnimals(boolean spawningAnimals) {
|
||||
return configHandle.set(configNodes.SPAWNING_ANIMALS, spawningAnimals);
|
||||
}
|
||||
|
||||
public int getSpawningAnimalsAmount() {
|
||||
return configHandle.get(configNodes.SPAWNING_ANIMALS_AMOUNT);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawningAnimalsAmount(int spawningAnimalsAmount) {
|
||||
return configHandle.set(configNodes.SPAWNING_ANIMALS_AMOUNT, spawningAnimalsAmount);
|
||||
}
|
||||
|
||||
public List<String> getSpawningAnimalsExceptions() {
|
||||
return configHandle.get(configNodes.SPAWNING_ANIMALS_EXCEPTIONS);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawningAnimalsExceptions(List<String> spawningAnimalsExceptions) {
|
||||
return configHandle.set(configNodes.SPAWNING_ANIMALS_EXCEPTIONS, spawningAnimalsExceptions);
|
||||
}
|
||||
|
||||
public boolean getSpawningMonsters() {
|
||||
return configHandle.get(configNodes.SPAWNING_MONSTERS);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawningMonsters(boolean spawningMonsters) {
|
||||
return configHandle.set(configNodes.SPAWNING_MONSTERS, spawningMonsters);
|
||||
}
|
||||
|
||||
public int getSpawningMonstersAmount() {
|
||||
return configHandle.get(configNodes.SPAWNING_MONSTERS_AMOUNT);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawningMonstersAmount(int spawningMonstersAmount) {
|
||||
return configHandle.set(configNodes.SPAWNING_MONSTERS_AMOUNT, spawningMonstersAmount);
|
||||
}
|
||||
|
||||
public List<String> getSpawningMonstersExceptions() {
|
||||
return configHandle.get(configNodes.SPAWNING_MONSTERS_EXCEPTIONS);
|
||||
}
|
||||
|
||||
public Try<Void> setSpawningMonstersExceptions(List<String> spawningMonstersExceptions) {
|
||||
return configHandle.set(configNodes.SPAWNING_MONSTERS_EXCEPTIONS, spawningMonstersExceptions);
|
||||
}
|
||||
|
||||
public List<String> getWorldBlacklist() {
|
||||
return (List<String>) configHandle.get(configNodes.WORLD_BLACKLIST);
|
||||
return configHandle.get(configNodes.WORLD_BLACKLIST);
|
||||
}
|
||||
|
||||
public Try<Void> setWorldBlacklist(List<String> worldBlacklist) {
|
||||
|
@ -7,6 +7,8 @@ import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.worldnew.MVWorld;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -68,6 +70,16 @@ public class WorldConfigNodes {
|
||||
})
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Double> ENTRY_FEE_AMOUNT = node(ConfigNode.builder("entry-fee.amount", Double.class)
|
||||
.defaultValue(0.0)
|
||||
.name("entryfee-amount")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Material> ENTRY_FEE_CURRENCY = node(ConfigNode.builder("entry-fee.currency", Material.class)
|
||||
.defaultValue(Material.AIR) // TODO: Convert from material ID
|
||||
.name("entryfee-currency")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<World.Environment> ENVIRONMENT = node(ConfigNode.builder("environment", World.Environment.class)
|
||||
.defaultValue(World.Environment.NORMAL)
|
||||
.name("environment")
|
||||
@ -136,6 +148,40 @@ public class WorldConfigNodes {
|
||||
.name("seed")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Location> SPAWN_LOCATION = node(ConfigNode.builder("spawn-location", Location.class)
|
||||
.name("spawn-location")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> SPAWNING_ANIMALS = node(ConfigNode.builder("spawning.animals.spawn", Boolean.class)
|
||||
.defaultValue(true)
|
||||
.name("spawning-animals")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Integer> SPAWNING_ANIMALS_AMOUNT = node(ConfigNode.builder("spawning.animals.amount", Integer.class)
|
||||
.defaultValue(-1)
|
||||
.name("spawning-animals-amount")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<List> SPAWNING_ANIMALS_EXCEPTIONS = node(ConfigNode.builder("spawning.animals.exceptions", List.class)
|
||||
.defaultValue(new ArrayList<>())
|
||||
.name("spawning-animals-exceptions")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> SPAWNING_MONSTERS = node(ConfigNode.builder("spawning.monsters.spawn", Boolean.class)
|
||||
.defaultValue(true)
|
||||
.name("spawning-monsters")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Integer> SPAWNING_MONSTERS_AMOUNT = node(ConfigNode.builder("spawning.monsters.amount", Integer.class)
|
||||
.defaultValue(-1)
|
||||
.name("spawning-monsters-amount")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<List> SPAWNING_MONSTERS_EXCEPTIONS = node(ConfigNode.builder("spawning.monsters.exceptions", List.class)
|
||||
.defaultValue(new ArrayList<>())
|
||||
.name("spawning-monsters-exceptions")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<List> WORLD_BLACKLIST = node(ConfigNode.builder("world-blacklist", List.class)
|
||||
.defaultValue(new ArrayList<>())
|
||||
.name("world-blacklist")
|
||||
@ -150,8 +196,4 @@ public class WorldConfigNodes {
|
||||
}
|
||||
|
||||
// TODO: Migrate color and style into alias
|
||||
// TODO: spawning
|
||||
// TODO: entryfee
|
||||
// TODO: spawnLocation
|
||||
// TODO: worldBlacklist
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import kotlin.test.assertNotNull
|
||||
|
||||
class WorldConfigMangerTest : TestWithMockBukkit() {
|
||||
|
||||
private lateinit var worldConfigFile : WorldsConfigManager
|
||||
private lateinit var worldConfigManager : WorldsConfigManager
|
||||
|
||||
@BeforeTest
|
||||
fun setUp() {
|
||||
@ -21,13 +21,13 @@ class WorldConfigMangerTest : TestWithMockBukkit() {
|
||||
assertNotNull(defaultConfig)
|
||||
File(Path.of(multiverseCore.dataFolder.absolutePath, "worlds2.yml").absolutePathString()).writeText(defaultConfig)
|
||||
|
||||
worldConfigFile =
|
||||
worldConfigManager =
|
||||
WorldsConfigManager(multiverseCore)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `World config is loaded`() {
|
||||
assertTrue(worldConfigFile.isLoaded)
|
||||
assertTrue(worldConfigManager.isLoaded)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -37,24 +37,24 @@ class WorldConfigMangerTest : TestWithMockBukkit() {
|
||||
|
||||
@Test
|
||||
fun `Add a new world to config`() {
|
||||
val worldConfig = worldConfigFile.addWorldConfig("newworld")
|
||||
worldConfigFile.save()
|
||||
val worldConfig = worldConfigManager.addWorldConfig("newworld")
|
||||
worldConfigManager.save()
|
||||
compareConfigFile("worlds2.yml", "/newworld_worlds.yml")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Updating existing world properties`() {
|
||||
val worldConfig = worldConfigFile.getWorldConfig("world")
|
||||
val worldConfig = worldConfigManager.getWorldConfig("world")
|
||||
worldConfig.setProperty("adjust-spawn", true)
|
||||
worldConfig.setProperty("alias", "newalias")
|
||||
worldConfigFile.save()
|
||||
worldConfigManager.save()
|
||||
compareConfigFile("worlds2.yml", "/properties_worlds.yml")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Delete world section from config`() {
|
||||
worldConfigFile.deleteWorldConfig("world")
|
||||
worldConfigFile.save()
|
||||
worldConfigManager.deleteWorldConfig("world")
|
||||
worldConfigManager.save()
|
||||
compareConfigFile("worlds2.yml", "/delete_worlds.yml")
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.mvplugins.multiverse.core.world
|
||||
|
||||
import com.onarandombox.MultiverseCore.worldnew.config.WorldConfig
|
||||
import com.onarandombox.MultiverseCore.worldnew.config.WorldsConfigManager
|
||||
import org.bukkit.Location
|
||||
import org.mvplugins.multiverse.core.TestWithMockBukkit
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
@ -60,6 +61,10 @@ class WorldConfigTest : TestWithMockBukkit() {
|
||||
val blacklists = listOf("a", "b", "c")
|
||||
assertTrue(worldConfig.setProperty("world-blacklist", blacklists).isSuccess)
|
||||
assertEquals(blacklists, worldConfig.getProperty("world-blacklist").get())
|
||||
|
||||
val location = Location(null, 1.0, 2.0, 3.0)
|
||||
assertTrue(worldConfig.setProperty("spawn-location", location).isSuccess)
|
||||
assertEquals(location, worldConfig.getProperty("spawn-location").get())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -6,6 +6,9 @@ world:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NORMAL
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -18,6 +21,15 @@ world:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
world_nether:
|
||||
adjust-spawn: false
|
||||
@ -27,6 +39,9 @@ world_nether:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NETHER
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -39,4 +54,13 @@ world_nether:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
|
@ -6,6 +6,9 @@ world_nether:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NETHER
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -18,4 +21,13 @@ world_nether:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
|
@ -6,6 +6,9 @@ world:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NORMAL
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -18,6 +21,15 @@ world:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
world_nether:
|
||||
adjust-spawn: false
|
||||
@ -27,6 +39,9 @@ world_nether:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NETHER
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -39,6 +54,15 @@ world_nether:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
newworld:
|
||||
adjust-spawn: false
|
||||
@ -48,6 +72,9 @@ newworld:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NORMAL
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -60,4 +87,13 @@ newworld:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
|
@ -6,6 +6,9 @@ world:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NORMAL
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -18,6 +21,15 @@ world:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
world_nether:
|
||||
adjust-spawn: false
|
||||
@ -27,6 +39,9 @@ world_nether:
|
||||
auto-heal: true
|
||||
auto-load: true
|
||||
difficulty: NORMAL
|
||||
entry-fee:
|
||||
amount: 0.0
|
||||
currency: AIR
|
||||
environment: NETHER
|
||||
gamemode: SURVIVAL
|
||||
generator: ''
|
||||
@ -39,4 +54,13 @@ world_nether:
|
||||
respawn-world: ''
|
||||
scale: 1.0
|
||||
seed: -9223372036854775808
|
||||
spawning:
|
||||
animals:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
monsters:
|
||||
spawn: true
|
||||
amount: -1
|
||||
exceptions: []
|
||||
world-blacklist: []
|
||||
|
Loading…
Reference in New Issue
Block a user