From 142cd5339bd29619ce9fc86d1e79a6b287f5dea6 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 4 Apr 2024 03:00:03 +0200 Subject: [PATCH 1/2] Fixes a bug in arena saving Saving a single arena caused all other arena data of that type to be deleted. --- README.md | 30 +++++------ .../util/DropperArenaStorageHelper.java | 7 ++- .../util/ParkourArenaStorageHelper.java | 7 ++- .../arena/MiniGamesArenaGroupTest.java | 51 ------------------- 4 files changed, 25 insertions(+), 70 deletions(-) delete mode 100644 src/test/java/net/knarcraft/minigames/arena/MiniGamesArenaGroupTest.java diff --git a/README.md b/README.md index b692ea7..2331435 100644 --- a/README.md +++ b/README.md @@ -204,26 +204,26 @@ This command allows editing the specified property for the specified parkour are These are all the options that can be changed for an arena. -| Option | Details | -|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| name | The name of the arena. Used mainly to select the arena in commands. Note that underscore (_) cannot be used if you want to utilize placeholders, as it's used to split placeholder arguments. | -| spawnLocation | The spawn location of any player joining the arena. Use `56.546,64.0,44.45` to specify coordinates, or `here`, `this` or any other string to select your current location. | -| exitLocation | The location players will be sent to when exiting the arena. If not set, the player will be sent to where they joined from. Valid values are the same as for spawnLocation. | -| winBlockType | The type of block players must hit to win the arena. It can be any material as long as it's a block, and not a type of air. | -| winLocation | The location players must reach to win the arena (see spawnLocation for valid values). If set, this overrides, and is used instead of, the win block type. | -| checkpointAdd | Adds a new checkpoint to the arena's checkpoints (see spawnLocation for valid values). | -| checkpointClear | Clears all current checkpoints. Give any value to execute. If not given a value, current checkpoints are shown. | -| killPlaneBlocks | A comma-separated list of materials which will force a loss when stepped on. +WOOL and other [material tags](#notes-about-material-tags) are supported as well. | -| obstacleBlocks | A comma-separated list of materials which will force a loss when touched from any direction. +WOOL and other [material tags](#notes-about-material-tags) are supported as well. | +| Option | Details | +|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| name | The name of the arena. Used mainly to select the arena in commands. Note that underscore (_) cannot be used if you want to utilize placeholders, as it's used to split placeholder arguments. | +| spawnLocation | The spawn location of any player joining the arena. Use `56.546,64.0,44.45` to specify coordinates, or `here`, `this` or any other string to select your current location. | +| exitLocation | The location players will be sent to when exiting the arena. If not set, the player will be sent to where they joined from. Valid values are the same as for spawnLocation. | +| winBlockType | The type of block players must hit to win the arena. It can be any material as long as it's a block, and not a type of air. | +| winLocation | The location players must reach to win the arena (see spawnLocation for valid values). If set, this overrides, and is used instead of, the win block type. | +| checkpointAdd | Adds a new checkpoint to the arena's checkpoints (see spawnLocation for valid values). | +| checkpointClear | Clears all current checkpoints. Give any value to execute. If not given a value, current checkpoints are shown. | +| killPlaneBlocks | A comma-separated list of materials which will force a loss when stepped on. +WOOL and other [material tags](#notes-about-material-tags) are supported as well. | +| obstacleBlocks | A comma-separated list of materials which will force a loss when touched from any direction. +WOOL and other [material tags](#notes-about-material-tags) are supported as well. | ## Configuration options ### Shared -| Name | Type | Default | Description | -|-----------------------------------|---------------------|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| liquidHitBoxDepth | -1 < decimal < 0 | -0.8 | This decides how far inside a non-solid block the player must go before detection triggers (-1, 0). The closer to -1 it is, the more accurate it will seem to the player, but the likelihood of not detecting the hit increases. | -| solidHitBoxDistance | 0 < decimal < 1 | 0.2 | This decides the distance the player must be from a block below them before a hit triggers (0, 1). If too low, the likelihood of detecting the hit decreases, but it won't look like the player hit the block without being near. | +| Name | Type | Default | Description | +|---------------------|------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| liquidHitBoxDepth | -1 < decimal < 0 | -0.8 | This decides how far inside a non-solid block the player must go before detection triggers (-1, 0). The closer to -1 it is, the more accurate it will seem to the player, but the likelihood of not detecting the hit increases. | +| solidHitBoxDistance | 0 < decimal < 1 | 0.2 | This decides the distance the player must be from a block below them before a hit triggers (0, 1). If too low, the likelihood of detecting the hit decreases, but it won't look like the player hit the block without being near. | ### Dropper 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()); - } - -} From a23d0c769f93204ff5841dfd369be7832bfe7b7f Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 4 Apr 2024 03:01:28 +0200 Subject: [PATCH 2/2] Bumps version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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