Skip to content

Commit

Permalink
Adds option to not give a safety block. Fixes #118
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jan 2, 2024
1 parent b626b75 commit cb1496d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 31 deletions.
38 changes: 23 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<java.version>17</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.19.3-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.20.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
Expand Down Expand Up @@ -120,21 +120,14 @@
</repositories>

<dependencies>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mockito (Unit testing) -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
<!-- Mockito (Unit testing) This goes at the top to ensure the dependencies are accurate. -->
<!-- This is required for PowerMockito to work and must be placed before it -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.30.2-GA</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
Expand All @@ -146,12 +139,25 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>${bentobox.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -270,6 +276,8 @@
<!-- This is required to prevent Jacoco from adding
synthetic fields to a JavaBean class (causes errors in testing) -->
<exclude>**/*Names*</exclude>
<!-- Prevents the Material is too large to mock error -->
<exclude>org/bukkit/Material*</exclude>
</excludes>
</configuration>
<executions>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/world/bentobox/border/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "return-teleport")
private boolean returnTeleport = true;

@ConfigComment("")
@ConfigComment("Place a safety block under the player if they get teleported back into a non-safe spot.")
@ConfigEntry(path = "return-teleport-safety-block")
private boolean returnTeleportBlock = true;

@ConfigComment("")
@ConfigComment("Barrier blocks on/off. Only applies if the border type is BARRIER.")
@ConfigComment("If false, the border is indicated by particles only.")
Expand Down Expand Up @@ -173,4 +178,18 @@ public void setBarrierOffset(int barrierOffset) {
this.barrierOffset = barrierOffset;
getBarrierOffset();
}

/**
* @return the returnTeleportBlock
*/
public boolean isReturnTeleportBlock() {
return returnTeleportBlock;
}

/**
* @param returnTeleportBlock the returnTeleportBlock to set
*/
public void setReturnTeleportBlock(boolean returnTeleportBlock) {
this.returnTeleportBlock = returnTeleportBlock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void onPlayerLeaveIsland(PlayerMoveEvent e) {
if (r != null) {
inTeleport.add(p.getUniqueId());
Location targetPos = r.getHitPosition().toLocation(p.getWorld(), p.getLocation().getYaw(), p.getLocation().getPitch());
if (!addon.getIslands().isSafeLocation(targetPos)) {
if (addon.getSettings().isReturnTeleportBlock() && !addon.getIslands().isSafeLocation(targetPos)) {
switch (targetPos.getWorld().getEnvironment()) {
case NETHER:
targetPos.getBlock().getRelative(BlockFace.DOWN).setType(Material.NETHERRACK);
Expand Down
43 changes: 28 additions & 15 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# Border addon configuration file
# Border addon configuration file {$version}
# See the documentation at https://docs.bentobox.world/en/latest/addons/Border/
#
#
# This list stores GameModes in which Border addon should not work.
# To disable addon it is necessary to write its name in new line that starts with -. Example:
# disabled-gamemodes:
# - BSkyBlock
disabled-gamemodes: []
#
# Use vanilla world border.
use-vanilla: true
#
#
# Border type. Options are VANILLA, which uses the vanillia-style board or BARRIER,
# which uses particles and barrier blocks. If players have permission to use the barrier type
# they may override this option. If they do not have permission or lose the permission
# then this setting will be used.
type: VANILLA
#
# Teleport players back inside the border if they somehow get outside.
# This will teleport players back inside if they toggle the border with a command.
return-teleport: true
#
# Only applies if vanilla isn't used.
# Use barrier blocks. If false, the border is indicated by particles only.
#
# Place a safety block under the player if they get teleported back into a non-safe spot.
return-teleport-safety-block: true
#
# Barrier blocks on/off. Only applies if the border type is BARRIER.
# If false, the border is indicated by particles only.
use-barrier-blocks: true
#
# Default border behavior
#
# Turn on barrier by default.
show-by-default: true
#
# Only applies if vanilla isn't used.
#
# Only applies if VANILLA type isn't used.
# Show max-protection range border. This is a visual border only and not a barrier.
# This setting is useful for game modes where the protection range can move around, like Boxed
show-max-border: true
#
# Only applies if vanilla isn't used.
#
# Only applies if VANILLA type isn't used.
# Enables/disables all types of wall particles shown by the addon
show-particles: true
#
# Barrier offset.
# The barrier normally occurs at the protection range limit but this value extends it outwards.
# This does not extend the protection range, but will enable players to go outside their protected area.
# The barrier will not go further than the island distance. Minimum and default value is 0.
barrier-offset: 0

0 comments on commit cb1496d

Please sign in to comment.