diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac22f52..12bdefc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,22 +11,22 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: '17' - name: Cache SonarCloud packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} diff --git a/pom.xml b/pom.xml index 6185cdb..eac6074 100644 --- a/pom.xml +++ b/pom.xml @@ -59,14 +59,14 @@ 2.0.9 1.19.4-R0.1-SNAPSHOT - 1.23.0 + 2.0.0-SNAPSHOT 2.7.0-SNAPSHOT ${build.version}-SNAPSHOT -LOCAL - 1.13.0 + 1.14.0 BentoBoxWorld_Warps bentobox-world @@ -312,7 +312,7 @@ org.jacoco jacoco-maven-plugin - 0.8.7 + 0.8.10 true diff --git a/src/main/java/world/bentobox/warps/commands/WarpsCommand.java b/src/main/java/world/bentobox/warps/commands/WarpsCommand.java index 108a255..de81de5 100644 --- a/src/main/java/world/bentobox/warps/commands/WarpsCommand.java +++ b/src/main/java/world/bentobox/warps/commands/WarpsCommand.java @@ -34,7 +34,7 @@ public WarpsCommand(Warp addon) { */ @Override public void setup() { - this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warp" : "island.warp"); + this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warps" : "island.warps"); this.setOnlyPlayer(true); this.setDescription("warps.help.description"); } diff --git a/src/main/java/world/bentobox/warps/managers/WarpSignsManager.java b/src/main/java/world/bentobox/warps/managers/WarpSignsManager.java index d15394b..ab93c41 100644 --- a/src/main/java/world/bentobox/warps/managers/WarpSignsManager.java +++ b/src/main/java/world/bentobox/warps/managers/WarpSignsManager.java @@ -21,6 +21,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -200,15 +201,15 @@ public void loadWarpList() { warpsData = handler.loadObject(WARPS); // Load into map if (warpsData != null) { - warpsData.getWarpSigns().forEach((k,v) -> { - if (k != null && k.getWorld() != null) { - if (k.getWorld().isChunkLoaded(k.getBlockX() >> 4, k.getBlockZ() >> 4) - && !k.getBlock().getType().name().contains("SIGN")) { + warpsData.getWarpSigns().forEach((location,uuid) -> { + if (location != null && location.getWorld() != null) { + if (location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4) + && !location.getBlock().getType().name().contains("SIGN")) { return; } // Add to map - getWarpMap(k.getWorld()).put(v, k); + getWarpMap(location.getWorld()).put(uuid, location); } }); } else { @@ -424,7 +425,7 @@ public void warpPlayer(@NonNull World world, @NonNull User user, @NonNull UUID o } // Find out which direction the warp is facing Block b = warpSpot.getBlock(); - if (b.getType().name().contains("WALL_SIGN")) { + if (Tag.WALL_SIGNS.isTagged(b.getType())) { org.bukkit.block.data.type.WallSign s = (org.bukkit.block.data.type.WallSign) b.getBlockData(); BlockFace directionFacing = s.getFacing(); Location inFront = b.getRelative(directionFacing).getLocation(); @@ -437,7 +438,13 @@ public void warpPlayer(@NonNull World world, @NonNull User user, @NonNull UUID o warpPlayer(user, oneDown, owner, directionFacing, pvp); return; } - } else if (b.getType().name().contains("SIGN")) { + } else if (Tag.ALL_HANGING_SIGNS.isTagged(b.getType())) { + Location below = b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN).getLocation(); + if ((addon.getIslands().isSafeLocation(below))) { + warpPlayer(user, below, owner, BlockFace.DOWN, pvp); + return; + } + } else if (Tag.STANDING_SIGNS.isTagged(b.getType())) { org.bukkit.block.data.type.Sign s = (org.bukkit.block.data.type.Sign) b.getBlockData(); BlockFace directionFacing = s.getRotation(); Location inFront = b.getRelative(directionFacing).getLocation(); diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index 09642b4..a75733f 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -10,7 +10,10 @@ softdepend: AcidIsland, BSkyBlock, CaveBlock, SkyGrid, AOneBlock permissions: '[gamemode].island.warp': - description: Player can use warp or warps commands + description: Player can use warp command + default: true + '[gamemode].island.warps': + description: Player can use the warps command default: true '[gamemode].island.addwarp': description: Player can create a welcome warp sign diff --git a/src/main/resources/locales/es.yml b/src/main/resources/locales/es.yml index eab36e9..a23cda9 100644 --- a/src/main/resources/locales/es.yml +++ b/src/main/resources/locales/es.yml @@ -1,31 +1,53 @@ -########################################################################################################### -# Este es un archivo YML. Tenga cuidado al editar. Revisa tus ediciones en un verificador de YAML como # -# el de http://yaml-online-parser.appspot.com # -########################################################################################################### - -warp: - help: - description: "Teletransportarte hacia el warp del jugador" - parameters: -warps: - deactivate: "&c¡El cartel viejo ha sido desactivado!" - error: - does-not-exist: "&c¡Oh vaya! !Ese warp ya no existe!" - no-permission: "&c¡No tienes permiso para hacer eso!" - no-remove: "&c¡No puedes quitar ese cartel!" - no-warps-yet: "&cNo hay warps disponibles aún" - not-enough-level: "&c¡Tu nivel de isla no es lo suficientemente alto!" - not-on-island: "&c¡Debes estar en tu isla para hacer eso!" - not-safe: "&c¡Ese warp no es seguro!" - your-level-is: "&cTu nivel de isla es solo [level] y debe ser mayor que [required]" - help: - description: "Abre el panel de warps" - next: "&6Siguiente página" - player-warped: "&2[name] ¡se ha teletransportado a tu warp!" - previous: "&6Página anterior" - random: "&4Teletransporte aleatorio" - sign-removed: "&c¡Cartel removido!" - success: "&a¡Éxito!" - title: "Carteles de Warps" - warpTip: "&6Coloca un cartel que contenga el texto [text] arriba" - warpToPlayersSign: "&6Teletransportandote al warp de [player]" +--- +warp: + help: + description: Teletransportarte hacia el warp del jugador + parameters: "" +warps: + deactivate: "&c ¡Antiguo cartel de teletransportación desactivado!" + error: + does-not-exist: "&c ¡Oh, chasquido! ¡Ese teletransporte ya no existe!" + no-permission: "&c ¡No tienes permisos para hacer eso!" + no-remove: "&c ¡No puedes quitar ese cartel!" + no-warps-yet: "&c No hay teletransportes disponibles todavía" + not-enough-level: "&c ¡Tu nivel de isla no es lo suficientemente alto!" + not-on-island: "&c ¡Debes estar en tu isla para hacer eso!" + not-safe: "&c ¡Ese teletransporte no es seguro!" + your-level-is: "&c Tu nivel de isla es solo [level] y debe ser mayor que [required]. + Ejecuta el comando de nivel." + not-correct-rank: "&c ¡No tienes el rango correcto para crear un teletransporte!" + help: + description: Abre el panel de warps + player-warped: "&2 [name] se ha teletransportado a tu cartel de teletransportación + de [gamemode]!" + sign-removed: "&c Cartel de teletransportación eliminado!" + success: "&a Éxito!" + warpTip: "&6 Coloca un cartel con [text] en la parte superior" + warpToPlayersSign: "&6 Teletransportandote al cartel del jugador [player]" + gui: + titles: + warp-title: "&0&l Carteles de Teletransporte" + buttons: + previous: + name: "&f&l Página Anterior" + description: "&7 Ir a la página [number]" + next: + name: "&f&l Siguiente Página" + description: "&7 Ir a la página [number]" + warp: + name: "&f&l [name]" + description: "[sign_text]" + random: + name: "&f&l Teletransporte aleatorio" + description: "&7 Hmm, ¿Dónde apareceré?" + tips: + click-to-previous: "&e Clic &7 para ver la página anterior." + click-to-next: "&e Clic &7 para ver la página siguiente." + click-to-warp: "&e Clic &7 para teletransportarse." + conversations: + prefix: "&l&6 [BentoBox]: &r" +protection: + flags: + PLACE_WARP: + name: Colocar Teletransporte + description: Permitir colocar un cartel de teletransporte diff --git a/src/main/resources/locales/id.yml b/src/main/resources/locales/id.yml index c7e4a8e..26ec210 100644 --- a/src/main/resources/locales/id.yml +++ b/src/main/resources/locales/id.yml @@ -7,22 +7,46 @@ warps: deactivate: "&c Tanda warp lama dinonaktifkan!" error: does-not-exist: "&c Oh! Warp itu tidak ada lagi!" - no-permission: "&c Anda tidak memiliki izin untuk melakukan itu!" - no-remove: "&c Anda tidak dapat menghapus tanda itu!" + no-permission: "&c Kamu tidak punya izin untuk melakukan itu!" + no-remove: "&c Kamu tidak bisa menghapus tanda itu!" no-warps-yet: "&c Belum ada warps yang tersedia" not-enough-level: "&c Level pulaumu tidak cukup tinggi!" - not-on-island: "&c Anda harus berada di pulau Anda untuk melakukan itu!" - not-safe: "&c Lengkungan itu tidak aman!" + not-on-island: "&c Kamu harus berada di pulaumu untuk melakukan itu!" + not-safe: "&c Warp itu tidak aman!" your-level-is: "&c Level pulau Anda hanya [level] dan harus lebih tinggi dari [required]. Jalankan perintah level." + not-correct-rank: "&c Kamu tidak punya rank yang benar untuk mengatur warp!" help: description: buka panel warps - next: "&6 Halaman berikutnya" - player-warped: "&2 [name] mengunjungi tanda warp Anda!" - previous: "&6 Halaman sebelumnya" - random: "&4 Warp Acak" + player-warped: "&2 [name] nge-warp ke tanda warp [gamemode] kamu!" sign-removed: "&c Tanda warp dihilangkan!" success: "&a Sukses!" - title: Tanda Warp warpTip: "&6 Tempatkan tanda warp dengan [text] di atas\n" - warpToPlayersSign: "&6 Pergi ke tanda [player]'s" + warpToPlayersSign: "&6 Pergi ke tanda [player]" + gui: + titles: + warp-title: "&0&l Tanda Warp" + buttons: + previous: + name: "&f&l Halaman Sebelumnya" + description: "&7 Beralih ke halaman [number]" + next: + name: "&f&l Halaman Selanjutnya" + description: "&7 Beralih ke halaman [number]" + warp: + name: "&f&l [name]" + description: "[sign_text]" + random: + name: "&f&l Warp Acak" + description: "&7 Hmm, di mana aku akan muncul?" + tips: + click-to-previous: "&e Klik &7 untuk melihat halaman sebelumnya." + click-to-next: "&e Klik &7 untuk melihat halaman selanjutnya." + click-to-warp: "&e Klik &7 untuk warp." + conversations: + prefix: "&l&6 [BentoBox]: &r" +protection: + flags: + PLACE_WARP: + name: Tempatkan Warp + description: Izinkan menempatkan tanda warp diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml index 7dc32e8..6209a9a 100644 --- a/src/main/resources/locales/pl.yml +++ b/src/main/resources/locales/pl.yml @@ -4,16 +4,16 @@ warp: description: teleportuje cię do tabliczki innego gracza parameters: "" warps: - deactivate: "&c Stary teleport zdezaktywowany!" + deactivate: "&c Stary teleport został zdezaktywowany!" error: does-not-exist: "&c Ten teleport nie istnieje." no-permission: "&c Brak uprawnień!" no-remove: "&c Nie możesz usunąć tej tabliczki!" - no-warps-yet: "&c Nie ma jeszcze teleportów." + no-warps-yet: "&c Nie ma jeszcze stworzonych teleportów." not-enough-level: "&c Twój poziom wyspy nie jest wystarczająco wysoki!" not-on-island: "&c Musisz być na wyspie, by to zrobić." not-safe: "&c Ten teleport nie jest bezpieczny!" - your-level-is: "&c Twój poziom wyspy to [level], a musi wynosić co namniej [required]. + your-level-is: "&c Twój poziom wyspy to [level], a musi wynosić co najmniej [required]. Użyj komendy /is level." help: description: otwiera panel warpów @@ -34,7 +34,7 @@ warps: description: "&7 Przełącz na stronę [number]" warp: name: "&f&l [name]" - description: "[sing_text]" + description: "[sign_text]" random: name: "&f&l Losowa wyspa" description: "&7 Hmm, gdzie się pojawię?" diff --git a/src/main/resources/locales/uk.yml b/src/main/resources/locales/uk.yml new file mode 100644 index 0000000..0c9abbf --- /dev/null +++ b/src/main/resources/locales/uk.yml @@ -0,0 +1,52 @@ +--- +warp: + help: + description: телепортація на знак варпа гравця + parameters: "" +warps: + deactivate: "&c Старий знак варпу деактивовано!" + error: + does-not-exist: "&c О, чорт! Того викривлення більше не існує!" + no-permission: "&c Ви не маєте на це дозволу!" + no-remove: "&c Ви не можете видалити цей знак!" + no-warps-yet: "&c Ще немає доступних варпів" + not-enough-level: "&c Рівень вашого острова недостатньо високий!" + not-on-island: "&c Для цього ви повинні бути на своєму острові!" + not-safe: "&c Ця варп небезпечна!" + your-level-is: "&c Рівень вашого острова становить лише [level] і має бути вищим + за [required]. Виконайте команду рівня." + not-correct-rank: "&c Ви не маєте належного рангу, щоб встановити варп!" + help: + description: відкрити панель варпів + player-warped: "&2 [name] телепортовано до вашого знака варпу [gamemode]!" + sign-removed: "&c Знак варпу видалено!" + success: "&a Успіх!" + warpTip: "&6 Розмістіть знак варпу з [text] угорі" + warpToPlayersSign: "&6 Телепортація на знак [player]." + gui: + titles: + warp-title: "&0&l Знаки варпів" + buttons: + previous: + name: "&f&l Попередня сторінка" + description: "&7 Перейти на сторінку [number]." + next: + name: "&f&l Наступна сторінка" + description: "&7 Перейти на сторінку [number]." + warp: + name: "&f&l [name]" + description: "[sign_text]" + random: + name: "&f&l Випадковий варп" + description: "&7 Хм, а де я з'явлюся?" + tips: + click-to-previous: "&e Натисніть &7, щоб переглянути попередню сторінку." + click-to-next: "&e Натисніть &7, щоб переглянути наступну сторінку." + click-to-warp: "&e Натисніть &7, щоб деформувати." + conversations: + prefix: "&l&6 [BentoBox]: &r" +protection: + flags: + PLACE_WARP: + name: Розмістіть варп + description: Дозволити розміщення варпів diff --git a/src/test/java/world/bentobox/warps/WarpSignsManagerTest.java b/src/test/java/world/bentobox/warps/WarpSignsManagerTest.java index 8a53f70..ea51cb0 100644 --- a/src/test/java/world/bentobox/warps/WarpSignsManagerTest.java +++ b/src/test/java/world/bentobox/warps/WarpSignsManagerTest.java @@ -25,6 +25,7 @@ import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Server; +import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; @@ -203,6 +204,9 @@ public void setUp() throws Exception { PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); when(Bukkit.getPluginManager()).thenReturn(pim); + // Tags + when(Tag.STANDING_SIGNS.isTagged(Material.ACACIA_SIGN)).thenReturn(true); + // Players Manager when(plugin.getPlayers()).thenReturn(pm); when(pm.getName(uuid)).thenReturn("tastybento"); diff --git a/src/test/java/world/bentobox/warps/commands/WarpsCommandTest.java b/src/test/java/world/bentobox/warps/commands/WarpsCommandTest.java index 07a046f..27fd6ff 100644 --- a/src/test/java/world/bentobox/warps/commands/WarpsCommandTest.java +++ b/src/test/java/world/bentobox/warps/commands/WarpsCommandTest.java @@ -123,7 +123,7 @@ public void warpCommandWarps() { @Test public void testSetupWarpCompositeCommand() { warpCommandWarpsCompositeCommand(); - assertEquals("bskyblock.island.warp", wc.getPermission()); + assertEquals("bskyblock.island.warps", wc.getPermission()); assertTrue(wc.isOnlyPlayer()); assertEquals("warps.help.description", wc.getDescription()); } @@ -134,7 +134,7 @@ public void testSetupWarpCompositeCommand() { @Test public void testSetupWarp() { warpCommandWarps(); - assertEquals(Warp.WELCOME_WARP_SIGNS + ".warp", wc.getPermission()); + assertEquals(Warp.WELCOME_WARP_SIGNS + ".warps", wc.getPermission()); assertTrue(wc.isOnlyPlayer()); assertEquals("warps.help.description", wc.getDescription()); }