diff --git a/pom.xml b/pom.xml index 437dfd9..08f4c90 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.knarcraft MiniGames - 1.1 + 1.2 jar MiniGames diff --git a/src/main/java/net/knarcraft/minigames/util/DropperArenaStorageHelper.java b/src/main/java/net/knarcraft/minigames/util/DropperArenaStorageHelper.java index d94e891..3e0c1e2 100644 --- a/src/main/java/net/knarcraft/minigames/util/DropperArenaStorageHelper.java +++ b/src/main/java/net/knarcraft/minigames/util/DropperArenaStorageHelper.java @@ -109,8 +109,11 @@ public final class DropperArenaStorageHelper { * @throws IOException

If unable to write to the file

*/ public static void saveSingleDropperArena(DropperArena arena) throws IOException { - YamlConfiguration configuration = new YamlConfiguration(); - ConfigurationSection arenaSection = configuration.createSection(dropperArenasConfigurationSection); + YamlConfiguration configuration = YamlConfiguration.loadConfiguration(dropperArenaFile); + ConfigurationSection arenaSection = configuration.getConfigurationSection(dropperArenasConfigurationSection); + if (arenaSection == null) { + arenaSection = configuration.createSection(dropperArenasConfigurationSection); + } saveDropperArena(arenaSection, arena); configuration.save(dropperArenaFile); } diff --git a/src/main/java/net/knarcraft/minigames/util/ParkourArenaStorageHelper.java b/src/main/java/net/knarcraft/minigames/util/ParkourArenaStorageHelper.java index ed3ef5d..37998a4 100644 --- a/src/main/java/net/knarcraft/minigames/util/ParkourArenaStorageHelper.java +++ b/src/main/java/net/knarcraft/minigames/util/ParkourArenaStorageHelper.java @@ -111,8 +111,11 @@ public final class ParkourArenaStorageHelper { * @throws IOException

If unable to write to the file

*/ public static void saveSingleParkourArena(ParkourArena arena) throws IOException { - YamlConfiguration configuration = new YamlConfiguration(); - ConfigurationSection arenaSection = configuration.createSection(parkourArenasConfigurationSection); + YamlConfiguration configuration = YamlConfiguration.loadConfiguration(parkourArenaFile); + ConfigurationSection arenaSection = configuration.getConfigurationSection(parkourArenasConfigurationSection); + if (arenaSection == null) { + arenaSection = configuration.createSection(parkourArenasConfigurationSection); + } saveParkourArena(arenaSection, arena); configuration.save(parkourArenaFile); } diff --git a/src/test/java/net/knarcraft/minigames/arena/MiniGamesArenaGroupTest.java b/src/test/java/net/knarcraft/minigames/arena/MiniGamesArenaGroupTest.java deleted file mode 100644 index 3bc00c0..0000000 --- a/src/test/java/net/knarcraft/minigames/arena/MiniGamesArenaGroupTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.knarcraft.minigames.arena; - -import net.knarcraft.minigames.arena.dropper.DropperArenaGroup; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -/** - * Tests for arena dropper groups - */ -public class MiniGamesArenaGroupTest { - - @Test - public void swapTest() { - /* - This test makes sure the order of arenas is as expected when the arenas are added to a group. It also makes - sure that swapping two items works as expected. - */ - - DropperArenaGroup arenaGroup = new DropperArenaGroup("test"); - UUID arena1Id = UUID.randomUUID(); - UUID arena2Id = UUID.randomUUID(); - UUID arena3Id = UUID.randomUUID(); - UUID arena4Id = UUID.randomUUID(); - - arenaGroup.addArena(arena1Id); - arenaGroup.addArena(arena2Id); - arenaGroup.addArena(arena3Id); - arenaGroup.addArena(arena4Id); - - List initialOrder = new ArrayList<>(); - initialOrder.add(arena1Id); - initialOrder.add(arena2Id); - initialOrder.add(arena3Id); - initialOrder.add(arena4Id); - Assertions.assertEquals(initialOrder, arenaGroup.getArenas()); - - arenaGroup.swapArenas(1, 3); - - List swapped = new ArrayList<>(); - swapped.add(arena1Id); - swapped.add(arena4Id); - swapped.add(arena3Id); - swapped.add(arena2Id); - Assertions.assertEquals(swapped, arenaGroup.getArenas()); - } - -}