From c7b1afe4d85a6cc32399610de87e3256b1f79148 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 10 Apr 2023 15:27:08 -0700 Subject: [PATCH] Bug fix release 4.1.1 (#101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Version 3.2.1 * Remove potential NPE issues * Version 3.3.0 * Added config option to show or not show particles. * Add Chinese Translation (#63) * Rename zh_CN.json to zh_CN.yml (#64) I'm so stupid. I made a mistake in the format. sorry! * Add a clearer message when WBAPI is not found (#65) It is not mandatory to use WorldBorderAPI, so it should be clear for the user that they have a choice besides integrating with it. * Remove `hooked` field (refactor) (#66) Removing the `hooked` field because it was used locally and could be removed as a simple refactoring to shorter and simpler code. * Unify wording of WBAPI-excluded configs (#67) * Unify wording of WBAPI-excluded configs * Add `show-particles` to README * Clarify message for show-particles setting * Implement per-player border type (#69) * Rename PlayerBorder.barrier to show * Move player event handlers to PlayerListener * Remove PlayerBorder * Implement PerPlayerBorderProxy Currently defaulting to Customer (non-wbapi) border * Add BorderTypeCommand * Create BorderType * Add messages to BorderTypeCommand * Prepare PerPlayerBorderProxy for handling edge cases The user may not have a border type set, then we return with the default. The user's border type may be unavailable now for two reasons: 1. Border type has been disabled after a server/plugin restart 2. Border type is obsolete and does not exist anymore (forward compatibility). * Fix message reference at BorderTypeCommand * Use null for missing wbapiBorder It is fine since it is never used * Avoid wbapi "border show" spam on player move * At command, replace args.isEmpty() with size() != 1 To also show help if more parameters are passed than necessary * Small refactor * Fix set-type permission in addon.yml * Update README Co-authored-by: tastybento * Cleanup documentation (#70) * Remove commented code * Purify config.yml As I see, this is just another place to duplicate our settings, documentation and changes to these. This file is generated if missing. * Cleanup Settings.java This is another place where we duplicated documentation. * Purify README.md * Fix failing test: testIsUseWbapi * Revert "Cleanup Settings.java" This reverts commit f8e931cc3511904410a6c60199e4e6df2267b8c0. * Format Settings.java and add documentation link * Regenerate config.yml * Avoid raw Optional#get * Enum elements should be all caps by convention. * Use isEmpty. Using Collection.size() to test for emptiness works, but using Collection.isEmpty() makes the code more readable and can be more performant. The time complexity of any isEmpty() method implementation should be O(1) whereas some implementations of size() can be O(n). In this case, it's not a big deal, just a code smell. * Map to new variable * 1.18 support for Particle.BARRIER_BLOCK * Translate id.yml via GitLocalize (#71) Co-authored-by: Alunite? * Translate hu.yml via GitLocalize (#72) Co-authored-by: VerusBungee * Taiwan translation (#73) * Translate zh-TW.yml via GitLocalize * Update zh-TW.yml Co-authored-by: davgo0103 Co-authored-by: tastybento * korean translation (#74) * Translate ko.yml via GitLocalize * Update ko.yml Co-authored-by: chickiyeah Co-authored-by: tastybento * Polish translation (#75) * Translate pl.yml via GitLocalize * Update pl.yml Co-authored-by: PICIGIT Co-authored-by: tastybento * Switch to use new Bukkit / Paper WorldBorder API (#78) * Switch to use new Bukkit / Paper WorldBorder API * Fix nether vanilla border (#80) Vanilla World Border automatically converts coordinates by dimension multiplayer. So in the nether it is required to counter it with extra processing. Co-authored-by: BuildTools * disabled enderpearls and chorus fruits + fix (#82) * run show task ; teleport visitors back in boundaries, bypass spectators (#83) * Implement a toggle between border types just by writing border type command. Requested by #87 * Implement new placeholder: %border_type% Requested by #86 * Disable border changing from other worlds. This could lead to a showing up a virtual border where it should not be. * Translate ru.yml via GitLocalize (#93) Co-authored-by: Marmur2020 * Translate pl.yml via GitLocalize (#92) Co-authored-by: wiktorm12 * Update French translation (#91) * Translate fr.yml via GitLocalize * Translate fr.yml via GitLocalize Co-authored-by: HipppB Co-authored-by: organizatsiya * Translate de.yml via GitLocalize (#89) Co-authored-by: 0x4096 * Update Spanish translation (#90) * Translate es.yml via GitLocalize * Translate es.yml via GitLocalize Co-authored-by: roy0510 Co-authored-by: plebexer * Update to Java 17 * Permission cannot have a - in it. Changed the permission for the type command to "border.type" instead of "border.set-type" because with the hyphen in it, Bukkit always grants the permission for some reason. Addresses #96 * Added test class for type command Had to make some classes non-final so they can be mocked. * Added IslandBorderCommand test class * Add ${argLine} to get jacoco coverage * Fix code smells. * Fix code smell * Fix Jacoco errors * Use default settings in config if player does not have permissions. (#98) Redoes the config.yml as well. Adds test classes. Relates to #97 * Config types (#99) * Use default settings in config if player does not have permissions. Redoes the config.yml as well. Adds test classes. Relates to #97 * Remove unused import. * Adds offset config to enable border to be bigger than protection range #75 Adds test class for ShowBarrier. * Added ShowVirtualWorldBorder test class #75 * Finishes up https://github.com/BentoBoxWorld/Border/issues/97 * Fixes #100. Island border was set for home island not visitor's island. --------- Co-authored-by: hutu <63152686+hutuY@users.noreply.github.com> Co-authored-by: Károly Ozsvárt Co-authored-by: gitlocalize-app[bot] <55277160+gitlocalize-app[bot]@users.noreply.github.com> Co-authored-by: Alunite? Co-authored-by: VerusBungee Co-authored-by: davgo0103 Co-authored-by: chickiyeah Co-authored-by: PICIGIT Co-authored-by: evlad Co-authored-by: BuildTools Co-authored-by: BONNe Co-authored-by: Marmur2020 Co-authored-by: wiktorm12 Co-authored-by: HipppB Co-authored-by: organizatsiya Co-authored-by: 0x4096 Co-authored-by: roy0510 Co-authored-by: plebexer --- pom.xml | 2 +- .../bentobox/border/commands/IslandBorderCommand.java | 7 ++++--- .../bentobox/border/commands/IslandBorderCommandTest.java | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index e664e96..eaeb901 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ ${build.version}-SNAPSHOT - 4.1.0 + 4.1.1 -LOCAL BentoBoxWorld_Border diff --git a/src/main/java/world/bentobox/border/commands/IslandBorderCommand.java b/src/main/java/world/bentobox/border/commands/IslandBorderCommand.java index 50869fd..2963909 100644 --- a/src/main/java/world/bentobox/border/commands/IslandBorderCommand.java +++ b/src/main/java/world/bentobox/border/commands/IslandBorderCommand.java @@ -38,8 +38,7 @@ public boolean canExecute(User user, String label, List args) { user.sendMessage("general.errors.wrong-world"); return false; } - - island = getIslands().getIsland(getWorld(), user); + island = addon.getIslands().getIslandAt(user.getLocation()).orElse(null); return island != null; } @@ -53,7 +52,9 @@ public boolean execute(User user, String label, List args) { } else { user.sendMessage("border.toggle.border-on"); user.putMetaData(BorderShower.BORDER_STATE_META_DATA, new MetaDataValue(true)); - addon.getBorderShower().showBorder(user.getPlayer(), island); + if (island != null) { + addon.getBorderShower().showBorder(user.getPlayer(), island); + } } return true; } diff --git a/src/test/java/world/bentobox/border/commands/IslandBorderCommandTest.java b/src/test/java/world/bentobox/border/commands/IslandBorderCommandTest.java index 1979bf1..45b2bed 100644 --- a/src/test/java/world/bentobox/border/commands/IslandBorderCommandTest.java +++ b/src/test/java/world/bentobox/border/commands/IslandBorderCommandTest.java @@ -123,7 +123,9 @@ public void setUp() throws Exception { // Islands when(plugin.getIslands()).thenReturn(im); + when(addon.getIslands()).thenReturn(im); when(im.getIsland(world, user)).thenReturn(island); + when(im.getIslandAt(any())).thenReturn(Optional.of(island)); // IWM when(plugin.getIWM()).thenReturn(iwm); @@ -174,7 +176,7 @@ public void testCanExecuteWrongWorld() { */ @Test public void testCanExecuteNoIsland() { - when(im.getIsland(world, user)).thenReturn(null); + when(im.getIslandAt(any())).thenReturn(Optional.empty()); assertFalse(ic.canExecute(user, "", Collections.emptyList())); verify(user, never()).sendMessage("general.errors.wrong-world"); }