diff --git a/src/main/java/de/butzlabben/world/data/objects/PlayerData.java b/src/main/java/de/butzlabben/world/data/objects/PlayerData.java index bac1f02..bf64723 100644 --- a/src/main/java/de/butzlabben/world/data/objects/PlayerData.java +++ b/src/main/java/de/butzlabben/world/data/objects/PlayerData.java @@ -8,19 +8,34 @@ public class PlayerData { //TODO Write Tests private List playerWorlds; - + /** + * Inits a new Player Object + */ public PlayerData() { playerWorlds = new ArrayList(); } + /** + * adds a world to the playerWorlds Array + * @param world the world data object to be added + */ public void addWorld(PlayerWorld world) { playerWorlds.add(world); } + /** + * gets the current count of worlds that the player owns + * @return + */ public int getWorldCount() { return playerWorlds.size(); } + /** + * returns the world at a certain index + * @param index index of the world you want + * @return the World Data Object + */ public PlayerWorld getWorldAt(int index) { return playerWorlds.get(index); } diff --git a/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java b/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java index 6d94358..75bb550 100644 --- a/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java +++ b/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java @@ -4,11 +4,21 @@ public class PlayerWorld { private int worldNumber; private long lastLoaded; + /** + * Creates an new Player World Data Structure if the worldNumber given + * @param worldNumber the index of the world held by the player + */ public PlayerWorld(int worldNumber) { this.worldNumber = worldNumber; this.lastLoaded = -1; } + /** + * gets the world player index + * (player index = the index of the world in the player's + * world array) + * @return the world number + */ public int getWorldNumber() { return worldNumber; } diff --git a/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java b/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java index 0b1dd60..9af4cef 100644 --- a/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java +++ b/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java @@ -13,10 +13,21 @@ import java.util.Map; public class WorldSystemData { public Map players; + + /** + * Creates the WorldSystemData objects + * and creates a blank map to hold player data + * with the uuid is the key + */ public WorldSystemData() { players = new HashMap(); } + /** + * Adds a Player to the data record + * @param uuid the UUID of the player to be added + * @return returns whether the player was added successfully or not + */ public Boolean addplayer(String uuid) { if (players.get(uuid) == null) { players.put(uuid, new PlayerData()); @@ -25,16 +36,30 @@ public class WorldSystemData { return false; } + /** + * adds a world Object to the player specified + * @param uuid the UUID of the player + * @param world the World Object to be added + */ public void addWorldToPlayer(String uuid, PlayerWorld world) { if (players.get(uuid) != null) { players.get(uuid).addWorld(world); } } + /** + * Gets the Amount of playerdata stored by WorldSystem + * @return player count + */ public int getPlayers() { return players.size(); } + /** + * returns the player data of the specifed uuid + * @param uuid the UUID of the player you want + * @return returns the player data object + */ public PlayerData getPlayer(String uuid) { return players.get(uuid); } diff --git a/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java b/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java index 52f33cc..37b45ae 100644 --- a/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java +++ b/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java @@ -7,6 +7,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class TestPlayerData { + /** + * Tests the Basic Initalization of a PlayerData Object + */ @Test public void testPlayerDataInit() { PlayerData pd = new PlayerData(); @@ -14,19 +17,33 @@ public class TestPlayerData { assertEquals(0, pd.getWorldCount()); } + /** + * Tests adding one world to the player + */ @Test public void testAddWorld() { PlayerData pd = new PlayerData(); pd.addWorld(new PlayerWorld(pd.getWorldCount())); assertEquals(1, pd.getWorldCount()); + } + + /** + * Tests adding multiple worlds to the player + */ + @Test + public void testAddMultipleWorlds() { + PlayerData pd = new PlayerData(); for (int i = 0; i < 5; i++) { pd.addWorld(new PlayerWorld(pd.getWorldCount())); } - assertEquals(6, pd.getWorldCount()); + assertEquals(5, pd.getWorldCount()); } + /** + * Tests geting a world at a specified index + */ @Test public void testGetWorldAtIndex() { PlayerData pd = new PlayerData(); diff --git a/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java b/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java index 900c72e..9964ed7 100644 --- a/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java +++ b/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java @@ -6,12 +6,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class TestPlayerWorld { + /** + * Tests the basic initiazlization of a new World with an id of 0 + */ @Test public void testPlayerWorldInit() { PlayerWorld pw = new PlayerWorld(0); assertEquals(0,pw.getWorldNumber()); } + /** + * Test the initiazlization of a world with a index other than 0 + */ @Test public void testPlayerWorldInit2() { PlayerWorld pw = new PlayerWorld(6); diff --git a/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java b/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java index 028661a..7c3e0b3 100644 --- a/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java +++ b/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java @@ -6,6 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class TestWorldSystemData { + /** + * Test the base initiaztaion of the WorldSystemData Object + */ @Test public void testWorldSystemDataInit() { WorldSystemData wsd = new WorldSystemData(); @@ -13,6 +16,9 @@ public class TestWorldSystemData { assertEquals(0, wsd.getPlayers()); } + /** + * Tests adding a basic player + */ @Test public void testAddPlayer() { WorldSystemData wsd = new WorldSystemData(); @@ -23,6 +29,9 @@ public class TestWorldSystemData { } + /** + * Test adding multiple Players + */ @Test public void testAddMultiplePlayers() { WorldSystemData wsd = new WorldSystemData(); @@ -38,7 +47,9 @@ public class TestWorldSystemData { } - + /** + * Tests adding Duplicate PLayers + */ @Test public void testAddDulpicatePlayer() { WorldSystemData wsd = new WorldSystemData(); @@ -51,6 +62,9 @@ public class TestWorldSystemData { assertEquals(1, wsd.getPlayers()); } + /** + * Tests adding a world to a player + */ @Test public void testAddWorldToPlayer() { WorldSystemData wsd = new WorldSystemData(); @@ -62,7 +76,9 @@ public class TestWorldSystemData { assertEquals(1, wsd.getPlayer("Blank_UUID").getWorldCount()); } - + /** + * Tests adding mulitple worlds a player + */ @Test public void testAddMultipleWorldsToPlayer() { WorldSystemData wsd = new WorldSystemData(); diff --git a/target/classes/de/butzlabben/world/data/objects/PlayerData.class b/target/classes/de/butzlabben/world/data/objects/PlayerData.class index 2d2c1f6..4c6d7fc 100644 Binary files a/target/classes/de/butzlabben/world/data/objects/PlayerData.class and b/target/classes/de/butzlabben/world/data/objects/PlayerData.class differ diff --git a/target/classes/de/butzlabben/world/data/objects/PlayerWorld.class b/target/classes/de/butzlabben/world/data/objects/PlayerWorld.class index e6bcb10..3a283a3 100644 Binary files a/target/classes/de/butzlabben/world/data/objects/PlayerWorld.class and b/target/classes/de/butzlabben/world/data/objects/PlayerWorld.class differ diff --git a/target/classes/de/butzlabben/world/data/objects/WorldSystemData.class b/target/classes/de/butzlabben/world/data/objects/WorldSystemData.class index d75b56e..110cddd 100644 Binary files a/target/classes/de/butzlabben/world/data/objects/WorldSystemData.class and b/target/classes/de/butzlabben/world/data/objects/WorldSystemData.class differ diff --git a/target/test-classes/de/butzlabben/world/data/objects/TestPlayerData.class b/target/test-classes/de/butzlabben/world/data/objects/TestPlayerData.class index 5e9ff98..b13c4d1 100644 Binary files a/target/test-classes/de/butzlabben/world/data/objects/TestPlayerData.class and b/target/test-classes/de/butzlabben/world/data/objects/TestPlayerData.class differ diff --git a/target/test-classes/de/butzlabben/world/data/objects/TestPlayerWorld.class b/target/test-classes/de/butzlabben/world/data/objects/TestPlayerWorld.class index d1f88d0..04e32ff 100644 Binary files a/target/test-classes/de/butzlabben/world/data/objects/TestPlayerWorld.class and b/target/test-classes/de/butzlabben/world/data/objects/TestPlayerWorld.class differ diff --git a/target/test-classes/de/butzlabben/world/data/objects/TestWorldSystemData.class b/target/test-classes/de/butzlabben/world/data/objects/TestWorldSystemData.class index 5752482..34303e4 100644 Binary files a/target/test-classes/de/butzlabben/world/data/objects/TestWorldSystemData.class and b/target/test-classes/de/butzlabben/world/data/objects/TestWorldSystemData.class differ