Change the name of Cord Classes

This commit is contained in:
Daniel 2022-10-04 10:09:09 -04:00
parent 2402b7a412
commit f039c04e08
10 changed files with 62 additions and 43 deletions

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

@ -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());
}
}