From f09dcbe7ff48b6acfd2593ffcf10f2443d4e7b6a Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 16 May 2024 15:34:53 +0200 Subject: [PATCH] Updates README, and allows the un-setting of kill plane and obstacle blocks --- README.md | 42 ++++++++++--------- .../minigames/arena/parkour/ParkourArena.java | 8 ++-- .../minigames/command/EditArenaCommand.java | 10 ++++- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d0a579c..c933268 100644 --- a/README.md +++ b/README.md @@ -141,14 +141,16 @@ This command allows editing the specified property for the specified dropper 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. | -| 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. | -| verticalVelocity | The vertical velocity set for players in the arena (basically their falling speed). It must be greater than 0, but max 75. `12.565` and other decimals are allowed. | -| horizontalVelocity | The horizontal velocity (technically fly speed) set for players in the arena. It must be between 0 and 1, and cannot be 0. Decimals are allowed. | -| 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. | +| Option | Details | +|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| name | The name of the arena. Used mainly to select the arena in commands. | +| 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. | +| verticalVelocity | The vertical velocity set for players in the arena (basically their falling speed). It must be greater than 0, but max 75. `12.565` and other decimals are allowed. | +| horizontalVelocity | The horizontal velocity (technically fly speed) set for players in the arena. It must be between 0 and 1, and cannot be 0. Decimals are allowed. | +| 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. | +| allowedDamageCauses | A list of damage causes that can affect players in the arena. The damage is simulated, rather than real damage. Reaching 0 health triggers a loss. Note: Fall damage cannot be allowed. | +| lossTriggerDamageCauses | A list of damage causes that will trigger a loss for the arena. Useful for arenas where players need to dodge arrows or similar. Note: Fall damage already causes a loss. | #### /dropperGroupSet @@ -209,17 +211,19 @@ 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. | +| allowedDamageCauses | A list of damage causes that can affect players in the arena. The damage is simulated, rather than real damage. Reaching 0 health triggers a loss. | +| lossTriggerDamageCauses | A list of damage causes that will trigger a loss for the arena. Useful for arenas where players need to dodge arrows or similar. | ## Configuration options diff --git a/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java b/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java index a936e11..a7bab58 100644 --- a/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java +++ b/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java @@ -485,8 +485,8 @@ public class ParkourArena implements Arena { * * @param killPlaneBlockNames

The names of the blocks that will cause players to lose

*/ - public boolean setKillPlaneBlocks(@NotNull Set killPlaneBlockNames) { - if (killPlaneBlockNames.isEmpty()) { + public boolean setKillPlaneBlocks(@Nullable Set killPlaneBlockNames) { + if (killPlaneBlockNames == null || killPlaneBlockNames.isEmpty()) { this.killPlaneBlockNames = null; this.killPlaneBlocks = null; } else { @@ -507,8 +507,8 @@ public class ParkourArena implements Arena { * * @param obstacleBlockNames

The names of the obstacle blocks

*/ - public boolean setObstacleBlocks(@NotNull Set obstacleBlockNames) { - if (obstacleBlockNames.isEmpty()) { + public boolean setObstacleBlocks(@Nullable Set obstacleBlockNames) { + if (obstacleBlockNames == null || obstacleBlockNames.isEmpty()) { this.obstacleBlockNames = null; this.obstacleBlocks = null; } else { diff --git a/src/main/java/net/knarcraft/minigames/command/EditArenaCommand.java b/src/main/java/net/knarcraft/minigames/command/EditArenaCommand.java index 497f6c7..a1f1454 100644 --- a/src/main/java/net/knarcraft/minigames/command/EditArenaCommand.java +++ b/src/main/java/net/knarcraft/minigames/command/EditArenaCommand.java @@ -1,11 +1,13 @@ package net.knarcraft.minigames.command; import net.knarcraft.minigames.config.DropperConfiguration; +import net.knarcraft.minigames.util.InputValidationHelper; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.command.CommandExecutor; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.HashSet; import java.util.List; @@ -120,9 +122,13 @@ public abstract class EditArenaCommand implements CommandExecutor { * @param input

The input string to get as a set

* @return

The resulting string set

*/ - @NotNull + @Nullable protected Set asSet(@NotNull String input) { - return new HashSet<>(List.of(input.split(","))); + if (InputValidationHelper.isEmptyValue(input)) { + return null; + } else { + return new HashSet<>(List.of(input.split(","))); + } } }