Skip to content

Commit

Permalink
Allow arena signs to be broken while sneaking.
Browse files Browse the repository at this point in the history
This commit "fixes" the problem introduced in the "no sign edits" commit
by not invoking the sign actions for interact events where the player is
sneaking. This is not the ideal way to go about it, but since we need to
bump the Spigot API version to access the sign change event that would
fix the underlying issue, this will have to do for now.

Fixes #791
  • Loading branch information
garbagemule committed Aug 18, 2024
1 parent a33f016 commit ca195eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ These changes will (most likely) be included in the next version.
- The `shuffle-positions` ability now correctly shuffles the position of the boss as well if `monster-teleport` is set to `false`.
- The `obsidian-bomb` ability no longer breaks boss waves.
- Text on Arena Signs is no longer explicitly truncated. This fixes an issue where color codes would count towards the character limit, causing the text that would otherwise fit on the sign to be cut off.
- Arena Signs can once again be destroyed, but it is necessary to break them while sneaking.

## [0.108] - 2024-01-01
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public void on(PlayerInteractEvent event) {
if (!(block.getState() instanceof Sign)) {
return;
}
if (event.getPlayer().isSneaking()) {
return;
}

ArenaSign sign = signStore.findByLocation(block.getLocation());
if (sign != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,27 @@ public void noSignBlockNoFun() {
verifyNoInteractions(signStore, invokesSignAction);
}

@Test
public void sneakingPlayerNoFun() {
Block block = mock(Block.class);
when(block.getState()).thenReturn(mock(Sign.class));
Player player = mock(Player.class);
when(player.isSneaking()).thenReturn(true);
PlayerInteractEvent event = event(player, block);

subject.on(event);

verifyNoInteractions(signStore, invokesSignAction);
}

@Test
public void nonArenaSignNoFun() {
Block block = mock(Block.class);
when(block.getState()).thenReturn(mock(Sign.class));
Player player = mock(Player.class);
when(player.isSneaking()).thenReturn(false);
when(signStore.findByLocation(any())).thenReturn(null);
PlayerInteractEvent event = event(null, block);
PlayerInteractEvent event = event(player, block);

subject.on(event);

Expand All @@ -68,9 +83,10 @@ public void arenaSignInvokesAction() {
Block block = mock(Block.class);
when(block.getLocation()).thenReturn(location);
when(block.getState()).thenReturn(mock(Sign.class));
Player player = mock(Player.class);
when(player.isSneaking()).thenReturn(false);
ArenaSign sign = new ArenaSign(location, "", "", "");
when(signStore.findByLocation(location)).thenReturn(sign);
Player player = mock(Player.class);
PlayerInteractEvent event = event(player, block);

subject.on(event);
Expand Down

0 comments on commit ca195eb

Please sign in to comment.