Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Release 4.8.5 by tastybento · Pull Request #183 · BentoBoxWorld/Border · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7791295
Pin MockBukkit to Maven Central 4.110.0 instead of jitpack snapshot
tastybento May 30, 2026
c2d1258
Update Modrinth game-versions to current MC range
tastybento Jun 3, 2026
b7e276e
Merge pull request #175 from BentoBoxWorld/chore/modrinth-game-versions
tastybento Jun 3, 2026
eb42b95
Add files via upload
tastybento Jun 28, 2026
302f1c6
ci: add CurseForge publish workflow (publishes the release asset)
tastybento Jun 28, 2026
7b8bbc0
ci: pin reusable workflow to SHA and enable Hangar publish
tastybento Jun 28, 2026
881eb96
ci: bump pinned reusable workflow to 71bf927bce32586216baa6995f21852d…
tastybento Jun 28, 2026
2cf22e8
Merge pull request #176 from BentoBoxWorld/ci/curseforge-publish
tastybento Jun 28, 2026
7e7370b
ci: bump pinned reusable workflow to fe4b1f0
tastybento Jul 1, 2026
af9a1a2
Merge pull request #177 from BentoBoxWorld/ci/bump-publish-workflow-f…
tastybento Jul 1, 2026
8eefdf5
ci: bump pinned publish-platforms.yml to ca2dcd1
tastybento Jul 3, 2026
b34600c
Merge pull request #178 from BentoBoxWorld/ci/bump-publish-platforms-…
tastybento Jul 3, 2026
a54d174
Declare the border colour and bordertype permissions
tastybento Jul 27, 2026
3372630
Merge pull request #180 from BentoBoxWorld/fix/179-border-permission-…
tastybento Jul 27, 2026
fc72038
ci: bump publish-platforms pin to the multipart-JSON fix
tastybento Jul 29, 2026
92aa243
Merge pull request #181 from BentoBoxWorld/ci/publish-platforms-pin
tastybento Jul 30, 2026
8819b3b
Stop death bounce-back from hijacking the drops
tastybento Jul 31, 2026
6d2cb01
Merge pull request #182 from BentoBoxWorld/fix/deathchest-drops-compat
tastybento Jul 31, 2026
59d5336
Update build.version from 4.8.4 to 4.8.5
tastybento Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/modrinth-publish.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,14 @@ jobs:
paper
spigot
game-versions: |-
1.21.4
1.21.5
1.21.6
1.21.7
1.21.8
1.21.9
1.21.10
1.21.11
26.1
26.1.1
26.1.2
files: ${{ github.workspace }}/target/Border-${{ github.event.release.tag_name }}.jar
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Border — .github/workflows/publish.yml
# Publishes the jar attached to a GitHub release to CurseForge and Hangar via the
# shared BentoBoxWorld/.github reusable workflow. Downloads the release asset instead of
# rebuilding from source. The reusable workflow is pinned to a commit SHA (Sonar
# githubactions:S7637). workflow_dispatch lets you (re)publish a given version.

name: Publish release to CurseForge and Hangar

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.3)"
required: true
type: string

jobs:
publish:
uses: bentoboxworld/.github/.github/workflows/publish-platforms.yml@1f91a0edf72e8c86d671b3b8fdd3121ac6fb88e1 # master
with:
use_release_asset: "true" # publish the jar attached to the release; do not rebuild
hangar_slug: "Border" # blank = skip Hangar
curseforge_id: "1515484"
game_versions: "26.2,26.1.2,26.1.1,26.1,1.21.11,1.21.10,1.21.9,1.21.8,1.21.7,1.21.6,1.21.5"
version: ${{ inputs.version }} # empty on release events -> falls back to the release tag
secrets:
HANGAR_API_KEY: ${{ secrets.HANGAR_API_KEY }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
8 changes: 4 additions & 4 deletions pom.xml
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>4.8.4</build.version>
<build.version>4.8.5</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand DownExpand Up@@ -142,9 +142,9 @@

<dependencies>
<dependency>
<groupId>com.github.MockBukkit</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.21-SNAPSHOT</version>
<groupId>org.mockbukkit.mockbukkit</groupId>
<artifactId>mockbukkit-v1.21</artifactId>
<version>4.110.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
62 changes: 52 additions & 10 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
package world.bentobox.border.listeners;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All@@ -23,6 +25,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDismountEvent;
import org.bukkit.event.entity.EntityMountEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand DownExpand Up@@ -71,10 +74,18 @@
public class PlayerListener implements Listener {

private static final Vector XZ = new Vector(1, 0, 1);
/** How close to a death spot, in blocks, an item must spawn to count as a death drop. */
private static final double DEATH_DROP_RADIUS_SQUARED = 5 * 5D;
private final Border addon;
private final Set<UUID> inTeleport;
private final BorderShower show;
private final Map<Player, BukkitTask> mountedPlayers = new HashMap<>();
/** Death spots whose drops the server has yet to spawn. Entries last one tick. */
private final List<DeathDrops> pendingDeathDrops = new ArrayList<>();

/** A death whose drops will spawn this tick, and the island they must stay on. */
private record DeathDrops(Location location, Island island) {
}

/**
* Constructs a new PlayerListener.
Expand DownExpand Up@@ -500,21 +511,52 @@ && isOn(event.getPlayer())
}

/**
* Bounces items back to inside the barrier if dropped when a player dies
* Remembers where a player died so that the items the server is about to drop there can
* be bounced back inside the barrier.
* <p>
* The drops list must not be touched here: taking the items out of the event and dropping
* them by hand breaks every plugin that stores death drops (death chests, graves, keep
* inventory). Instead this runs at MONITOR, after those plugins have decided what happens
* to the items, and only notes the death spot. Whatever the server then actually drops is
* picked up in {@link #onDeathDropSpawn(ItemSpawnEvent)} and tracked from there.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
if (addon.getSettings().isBounceBack()
&& addon.inGameWorld(event.getPlayer().getWorld())
&& isOn(event.getPlayer())) {
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
event.getDrops().forEach(item -> trackItem(event.getPlayer().getWorld().dropItemNaturally(loc, item), is));
event.getDrops().clear(); // We handled them
});
if (!addon.getSettings().isBounceBack()
|| event.getDrops().isEmpty()
|| !addon.inGameWorld(event.getPlayer().getWorld())
|| !isOn(event.getPlayer())) {
return;
}
Location loc = event.getPlayer().getLocation();
addon.getIslands().getIslandAt(Objects.requireNonNull(loc)).ifPresent(is -> {
DeathDrops deathDrops = new DeathDrops(loc, is);
pendingDeathDrops.add(deathDrops);
// The server spawns the drops in this tick, straight after the event returns
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> pendingDeathDrops.remove(deathDrops));
});
}

/**
* Tracks death drops as the server spawns them, so they cannot leave the island's
* protection zone. Items spawning this tick near a recorded death spot are the drops the
* server kept after every plugin had its say on the death event.
*
* @param event event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onDeathDropSpawn(ItemSpawnEvent event) {
if (pendingDeathDrops.isEmpty()) {
return;
}
Location loc = event.getLocation();
pendingDeathDrops.stream()
.filter(dd -> Objects.equals(loc.getWorld(), dd.location().getWorld()))
.filter(dd -> loc.distanceSquared(dd.location()) <= DEATH_DROP_RADIUS_SQUARED)
.findFirst()
.ifPresent(dd -> trackItem(event.getEntity(), dd.island()));
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/addon.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,18 @@ permissions:
'[gamemode].border.type':
description: Player can use border type setting command
default: true
'[gamemode].bordertype':
'[gamemode].border.bordertype':
description: Player can use bordertype command to change the border type
default: false
default: false
'[gamemode].border.color':
description: Player can use border color setting command
default: true
'[gamemode].border.color.red':
description: Player can set their border color to red
default: op
'[gamemode].border.color.green':
description: Player can set their border color to green
default: op
'[gamemode].border.color.blue':
description: Player can set their border color to blue
default: op
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
package world.bentobox.border.listeners;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All@@ -11,6 +12,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All@@ -19,8 +21,12 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
Expand DownExpand Up@@ -74,6 +80,16 @@ class PlayerListenerTest extends CommonTestSetup {
private Vehicle vehicle;
@Mock
private GameModeAddon gma;
@Mock
private PlayerDeathEvent deathEvent;
@Mock
private ItemSpawnEvent itemSpawnEvent;
@Mock
private Item item;
@Mock
private ItemStack itemStack;
@Mock
private Location farAway;

private MockedStatic<User> mockedUser;

Expand DownExpand Up@@ -464,4 +480,84 @@ void testOnProtectionRangeChange() {
verify(show).showBorder(player, island);
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
* The drops must be left in the event for death chest plugins and the server to handle.
*/
@Test
void testOnPlayerDeathLeavesDropsAlone() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
assertEquals(1, drops.size());
verify(world, never()).dropItemNaturally(any(Location.class), any(ItemStack.class));
// The death spot is remembered, and forgotten again next tick
verify(sch).runTask(eq(plugin), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
* An item spawning at a fresh death spot is a death drop and gets the bounce-back tracking.
*/
@Test
void testDeathDropsAreTrackedWhenTheySpawn() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(itemSpawnEvent.getLocation()).thenReturn(to);
when(itemSpawnEvent.getEntity()).thenReturn(item);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch).runTaskTimer(eq(plugin), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnWithNoRecentDeathIsIgnored() {
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onDeathDropSpawn(org.bukkit.event.entity.ItemSpawnEvent)}.
*/
@Test
void testItemSpawnFarFromDeathIsNotTracked() {
List<ItemStack> drops = new ArrayList<>();
drops.add(itemStack);
when(deathEvent.getPlayer()).thenReturn(player);
when(deathEvent.getDrops()).thenReturn(drops);
pl.onPlayerDeath(deathEvent);
when(farAway.getWorld()).thenReturn(world);
when(farAway.distanceSquared(to)).thenReturn(100.0);
when(itemSpawnEvent.getLocation()).thenReturn(farAway);
pl.onDeathDropSpawn(itemSpawnEvent);
verify(sch, never()).runTaskTimer(any(), any(Runnable.class), eq(1L), eq(1L));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathBounceBackDisabled() {
settings.setBounceBack(false);
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

/**
* Test method for {@link world.bentobox.border.listeners.PlayerListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/
@Test
void testOnPlayerDeathNoDrops() {
when(deathEvent.getDrops()).thenReturn(new ArrayList<>());
pl.onPlayerDeath(deathEvent);
verify(sch, never()).runTask(any(), any(Runnable.class));
}

}
Loading