Compare commits

...

2 Commits

Author SHA1 Message Date
Daniel 7b9942d5cc Finished the Config System 2022-10-04 23:46:51 -04:00
Daniel f039c04e08 Change the name of Cord Classes 2022-10-04 10:09:09 -04:00
13 changed files with 75 additions and 45 deletions

View File

@ -82,15 +82,22 @@ wsWorldSpawn:
#Warning: Spelling Matters, Capitalization Does not
worldGameMode: 'Survival'
# places the player at their last known location in the world
useLastLocation: false
useLastLocation: false;
#The point the player should be placed when entering a WS World
#for the first Time
defaultWorldSpawnPoint:
worldName: 'world'
x: 0
y: 60
z: 0
#############
# Dev Tools #
#############
# These Config Options are for the Devlopment and Maintenace
# Of World System. These features are not for production.
devcmds: false;
###################
# World Gamerules #
###################

View File

@ -0,0 +1,2 @@
package de.butzlabben.world.config;public class GameruleConfig {
}

View File

@ -1,7 +1,8 @@
package de.butzlabben.world.config;
import de.butzlabben.world.exceptions.InvalidConfigFormatException;
import de.butzlabben.world.utils.PlanerCords;
import de.butzlabben.world.utils.Location;
import de.butzlabben.world.utils.Location2D;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.configuration.file.YamlConfiguration;
@ -12,7 +13,6 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Dictionary;
public class PluginConfig {
@ -177,8 +177,8 @@ public class PluginConfig {
return config.getInt("worldBorderDefaultSize");
}
public PlanerCords getWorldBorderCords() {
return new PlanerCords(config.getInt("worldBorderCenter.x"), config.getInt("worldBorderCenter.y"));
public Location2D getWorldBorderCords() {
return new Location2D(config.getInt("worldBorderCenter.x"), config.getInt("worldBorderCenter.y"));
}
//World Entering/Exiting Getters
@ -188,6 +188,13 @@ public class PluginConfig {
return stringToGamemode(config.getString("serverSpawn.serverGamemode"));
}
public Location getServerSpawnPoint() {
return new Location(
config.getInt("serverSpawn.serverSpawnPoint.x"),
config.getInt("serverSpawn.serverSpawnPoint.y"),
config.getInt("serverSpawn.serverSpawnPoint.z"));
}

View File

@ -1,16 +0,0 @@
package de.butzlabben.world.utils;
public class CubicCords extends PlanerCords {
private int z;
public CubicCords(int x, int y, int z)
{
super(x, y);
this.z = z;
}
public int getZ() {
return this.z;
}
}

View File

@ -0,0 +1,17 @@
package de.butzlabben.world.utils;
public class Location extends Location2D
{
private int y;
public Location(int x, int y, int z)
{
super(x, z);
this.y = y;
}
public int getY() {
return this.y;
}
}

View File

@ -0,0 +1,20 @@
package de.butzlabben.world.utils;
public class Location2D
{
private int x;
private int z;
public Location2D(int x, int z) {
this.x = x;
this.z = z;
}
public int getX() {
return this.x;
}
public int getZ() {
return this.z;
}
}

View File

@ -1,20 +0,0 @@
package de.butzlabben.world.utils;
public class PlanerCords
{
private int x;
private int y;
public PlanerCords(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
}

View File

@ -0,0 +1,2 @@
package de.butzlabben.world.config;public class TestGameRules {
}

View File

@ -1,6 +1,5 @@
package de.butzlabben.world.config;
import de.butzlabben.world.utils.PlanerCords;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.junit.jupiter.api.Test;
@ -108,9 +107,9 @@ public class TestPluginConfig {
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(0, cfg.getWorldBorderCords().getX());
assertEquals(0, cfg.getWorldBorderCords().getY());
assertEquals(0, cfg.getWorldBorderCords().getZ());
}
@ -124,4 +123,16 @@ public class TestPluginConfig {
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(GameMode.SURVIVAL, cfg.getServerGamemode());
}
@Test
public void testGetServerSpawnPoint() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(0, cfg.getServerSpawnPoint().getX());
assertEquals(60, cfg.getServerSpawnPoint().getY());
assertEquals(0, cfg.getServerSpawnPoint().getZ());
}
}