Compare commits

...

9 Commits

Author SHA1 Message Date
tastybento 0a12a26b06
Merge pull request #134 from BentoBoxWorld/gitlocalize-29839
French translation
2024-06-08 10:12:36 -07:00
ISOURA b860a4dac5 Translate fr.yml via GitLocalize 2024-06-08 17:08:20 +00:00
tastybento 2da0e5e82b
Merge pull request #133 from RUYSUE/develop
updated zh-CN locale
2024-06-08 08:52:53 -07:00
RUYSUE a39b6a3f4a
Update zh-CN.yml 2024-06-08 17:20:14 +08:00
tastybento d70ee5d755
Merge pull request #132 from BentoBoxWorld/131_WarpCreateEvent_doesn't_fire
Call events correctly. #131
2024-06-05 14:12:29 -07:00
tastybento efc6b795d1 Call events correctly. #131 2024-06-05 14:09:02 -07:00
tastybento 519a2d05fc Version 1.15.0 2024-02-03 08:30:12 -08:00
tastybento 86c089b694 Update tipped arrows in GUI Panel 2024-01-21 09:09:17 -08:00
tastybento 3417633c4d Version 1.14.1 2024-01-21 09:09:12 -08:00
7 changed files with 148 additions and 48 deletions

View File

@ -66,7 +66,7 @@
<!-- Do not change unless you want different name for local builds. --> <!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number> <build.number>-LOCAL</build.number>
<!-- This allows to change between versions. --> <!-- This allows to change between versions. -->
<build.version>1.14.0</build.version> <build.version>1.15.0</build.version>
<!-- Sonar Cloud --> <!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Warps</sonar.projectKey> <sonar.projectKey>BentoBoxWorld_Warps</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization> <sonar.organization>bentobox-world</sonar.organization>

View File

@ -15,7 +15,7 @@ import world.bentobox.warps.Warp;
* @author Poslovitch * @author Poslovitch
* *
*/ */
public class WarpCreateEvent extends Event{ public class WarpCreateEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final Location warpLoc; private final Location warpLoc;

View File

@ -38,6 +38,7 @@ import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
import world.bentobox.warps.Warp; import world.bentobox.warps.Warp;
import world.bentobox.warps.event.WarpCreateEvent;
import world.bentobox.warps.event.WarpInitiateEvent; import world.bentobox.warps.event.WarpInitiateEvent;
import world.bentobox.warps.objects.WarpsData; import world.bentobox.warps.objects.WarpsData;
import world.bentobox.warps.panels.Utils; import world.bentobox.warps.panels.Utils;
@ -105,7 +106,7 @@ public class WarpSignsManager {
} }
getWarpMap(loc.getWorld()).put(playerUUID, loc); getWarpMap(loc.getWorld()).put(playerUUID, loc);
saveWarpList(); saveWarpList();
Bukkit.getPluginManager().callEvent(new WarpInitiateEvent(addon, loc, playerUUID)); Bukkit.getPluginManager().callEvent(new WarpCreateEvent(addon, loc, playerUUID));
return true; return true;
} }
@ -350,6 +351,11 @@ public class WarpSignsManager {
float yaw = Util.blockFaceToFloat(directionFacing); float yaw = Util.blockFaceToFloat(directionFacing);
final Location actualWarp = new Location(inFront.getWorld(), inFront.getBlockX() + 0.5D, inFront.getBlockY(), final Location actualWarp = new Location(inFront.getWorld(), inFront.getBlockX() + 0.5D, inFront.getBlockY(),
inFront.getBlockZ() + 0.5D, yaw, 30F); inFront.getBlockZ() + 0.5D, yaw, 30F);
WarpInitiateEvent e = new WarpInitiateEvent(addon, actualWarp, user.getUniqueId());
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled()) {
return;
}
//BentoBox prevents people from teleporting to an island when //BentoBox prevents people from teleporting to an island when
//the user is banned from the island for example. //the user is banned from the island for example.
//By checking if the teleport succeeded before sending the messages, //By checking if the teleport succeeded before sending the messages,

View File

@ -4,25 +4,50 @@ warp:
description: te téléporte au Warp d'un autre joueur description: te téléporte au Warp d'un autre joueur
parameters: "<pseudo>" parameters: "<pseudo>"
warps: warps:
deactivate: "&cAncien panneau de Warp désactivé !" deactivate: "&c Ancienne pancarte de warp désactivée !"
error: error:
does-not-exist: "&cCe Warp n'existe plus !" does-not-exist: "&c Oh ! Cette téléportation n'existe plus !"
no-permission: "&cVous n'avez pas la permission pour faire cela !" no-permission: "&c Vous n'avez pas le droit de faire cela !"
no-remove: "&cVous ne pouvez pas supprimer ce panneau !" no-remove: "&c Vous ne pouvez pas enlever cette pancarte !"
no-warps-yet: "&cIl n'y a encore aucun Warp sur ce serveur." no-warps-yet: "&c Il n'y a pas encore de téléportation disponible"
not-enough-level: "&cVotre niveau d'île n'est pas assez élevé pour faire cela not-enough-level: "&c Le niveau de votre île n'est pas assez élevé !"
!" not-on-island: "&c Vous devez être sur votre île pour faire cela !"
not-on-island: "&cVous devez être sur votre île pour faire cela !" not-safe: "&c Cette téléportation n'est pas sûre !"
not-safe: "&cCe Warp n'est pas sûr!" your-level-is: "&c Le niveau de votre île n'est que [level] et doit être supérieur
your-level-is: "&cVotre île est seulement niveau [level] et doit être niveau [required]." à [required]. Exécutez la commande level."
not-correct-rank: "&c Vous n'avez pas le grade adéquat pour poser une chaîne !"
help: help:
description: Ouvre le menu des Warps description: Ouvre le menu des Warps
next: "&6Page suivante" player-warped: "&2 [name] s'est rendu à votre pancarte de téléportation [gamemode]
player-warped: "& 2 [pseudo] s'est téléporté à votre panneau Warp !" !"
previous: "&6Page précédente" sign-removed: "&c Panneau de téléportation enlevé !"
random: "&4 Warp aléatoire " success: "&a Succès !"
sign-removed: "&cPanneau de Warp supprimé !" warpTip: "&6 Placer une pancarte de téléportation avec [text] sur le dessus"
success: "&aSuccès !" warpToPlayersSign: "&6 Téléportation a la pancarte de [player]"
title: Panneau Warp gui:
warpTip: "&6Placez un panneau et écrivez [text] sur la première ligne." titles:
warpToPlayersSign: "&6 Téléportation vers le panneau de [pseudo]" warp-title: "&0&l Pancarte de téléportation"
buttons:
previous:
name: "&f&l Page précédente"
description: "&7 Aller à la page [numéro]."
next:
name: "&f&l Page suivante"
description: "&7 Passer à la page [numéro]."
warp:
name: "&f&l [name]"
description: "[sign_text]"
random:
name: "&f&l Téléportation aléatoire"
description: "&7 Hmm, où vais-je apparaître ?"
tips:
click-to-previous: "&e Cliquez sur &7 pour afficher la page précédente."
click-to-next: "&e Cliquez sur &7 pour afficher la page suivante."
click-to-warp: "&e Cliquez sur &7 pour te téléporter."
conversations:
prefix: "&l&6 [BentoBox]: &r"
protection:
flags:
PLACE_WARP:
name: Place téléportation
description: Autoriser le placement d'un panneau téléportation

View File

@ -1,27 +1,60 @@
--- # ##########################################################################################
# This is a YML file. Be careful when editing. Check your edits in a YAML checker like #
# the one at http://yaml-online-parser.appspot.com #
# ##########################################################################################
warp: warp:
help: help:
description: 传送到该玩家的传送木牌处 description: 传送至对应玩家的坐标告示牌
parameters: "<player name>" parameters: <player name>
warps: warps:
help: deactivate: '&c检测到不活跃的坐标告示牌!'
description: 打开传送面板
title: 传送木牌
deactivate: "&c 旧传送牌已停用!"
error: error:
does-not-exist: "&c 哦不!那个传送点已经没了!" does-not-exist: '&c啊哦! 那个传送点已经不存在了!'
no-permission: "&c 你无权那样做!" no-permission: '&c你没有权限做这件事!'
no-remove: "&c 你拿不掉那个牌子的!" no-remove: '&c你不能移除该告示牌!'
no-warps-yet: "&c 暂无可用传送点" no-warps-yet: '&c尚无可用传送点.'
not-enough-level: "&c 你的岛等级不够高!" not-enough-level: '&c你空岛的等级还不够高!'
not-on-island: "&c 你得在自己的岛屿上操作!" not-on-island: '&c你必须在自己的空岛上做这件事!'
not-safe: "&c 目标传送点不安全!" not-safe: '&c该传送点不安全!'
your-level-is: "&c 你的岛现在 [level] 级,需要 [required] 级。 试试岛屿等级命令吧。" your-level-is: '&c你空岛的等级只有[level], 但必须高于[required]. 使用/is level查看等级.'
next: "&6 次页" not-correct-rank: '&c你在团队中的地位不足以让你设立传送点!'
player-warped: "&2 [name] 传送到了你的传送牌!" help:
previous: "&6 前页" description: 打开传送点面板
random: "&4 随机传送" player-warped: '&2 [name]传送到了你[gamemode]的坐标告示牌!'
sign-removed: "&c 拆掉传送牌了!" sign-removed: '&c坐标告示牌已移除!'
success: "&a 成了!" success: '&a成功!'
warpTip: "&6 放个牌子第一行写 [text]" warpTip: '&6放置一个顶部为[text]的坐标告示牌'
warpToPlayersSign: "&6 正传送到 [player] 的牌子" warpToPlayersSign: '&6正在传送至[player]的坐标告示牌'
gui:
titles:
# The title of warp panel
warp-title: '&0&l坐标告示牌'
buttons:
# Button that is used in multi-page GUIs which allows to return to previous page.
previous:
name: '&f&l上一页'
description: '&7跳转到第[number]页' # Button that is used in multi-page GUIs which allows to go to next page.
next:
name: '&f&l下一页'
description: '&7跳转到第[number]页' # Button for a warp
warp:
name: '&f&l [name]'
description: '[sign_text]' # Button for a random warp
random:
name: '&f&l随机传送'
description: '&7嗯...我会出现在哪里?'
tips:
click-to-previous: '&e点击&7 查看上一页.'
click-to-next: '&e点击&7 查看下一页.'
click-to-warp: '&e点击&7 进行传送.'
conversations:
# Prefix for messages that are send from server.
prefix: '&l&6 [BentoBox]: &r'
protection:
flags:
PLACE_WARP:
name: 放置传送点
description: 允许放置坐标告示牌

View File

@ -19,7 +19,7 @@ warps_panel:
8: warp_button 8: warp_button
3: 3:
1: 1:
icon: TIPPED_ARROW:INSTANT_HEAL::::1 icon: tipped_arrow{CustomPotionColor:11546150}
title: warps.gui.buttons.previous.name title: warps.gui.buttons.previous.name
description: warps.gui.buttons.previous.description description: warps.gui.buttons.previous.description
data: data:
@ -37,7 +37,7 @@ warps_panel:
7: warp_button 7: warp_button
8: warp_button 8: warp_button
9: 9:
icon: TIPPED_ARROW:JUMP::::1 icon: tipped_arrow{CustomPotionColor:8439583}
title: warps.gui.buttons.next.name title: warps.gui.buttons.next.name
description: warps.gui.buttons.next.description description: warps.gui.buttons.next.description
data: data:

View File

@ -8,7 +8,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -40,6 +42,7 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
@ -60,6 +63,7 @@ import world.bentobox.bentobox.managers.PlaceholdersManager;
import world.bentobox.bentobox.managers.PlayersManager; import world.bentobox.bentobox.managers.PlayersManager;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
import world.bentobox.warps.config.Settings; import world.bentobox.warps.config.Settings;
import world.bentobox.warps.event.WarpCreateEvent;
import world.bentobox.warps.event.WarpInitiateEvent; import world.bentobox.warps.event.WarpInitiateEvent;
import world.bentobox.warps.managers.SignCacheManager; import world.bentobox.warps.managers.SignCacheManager;
import world.bentobox.warps.managers.WarpSignsManager; import world.bentobox.warps.managers.WarpSignsManager;
@ -349,7 +353,7 @@ public class WarpSignsManagerTest {
public void testAddWarp() { public void testAddWarp() {
Location loc = mock(Location.class); Location loc = mock(Location.class);
assertTrue(wsm.addWarp(uuid, loc)); assertTrue(wsm.addWarp(uuid, loc));
verify(pim).callEvent(any(WarpInitiateEvent.class)); verify(pim).callEvent(any(WarpCreateEvent.class));
} }
/** /**
@ -441,6 +445,38 @@ public class WarpSignsManagerTest {
PowerMockito.verifyStatic(Util.class); PowerMockito.verifyStatic(Util.class);
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND)); Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
verify(player).sendMessage(anyString()); verify(player).sendMessage(anyString());
verify(pim).callEvent(any(WarpInitiateEvent.class));
}
/**
* Test method for {@link WarpSignsManager#warpPlayer(org.bukkit.World, world.bentobox.bentobox.api.user.User, java.util.UUID)}.
*/
@Test
public void testWarpPlayerEventCancelled() {
// Capture the event passed to callEvent
ArgumentCaptor<WarpInitiateEvent> eventCaptor = ArgumentCaptor.forClass(WarpInitiateEvent.class);
// Simulate the event being called and cancelled
doAnswer(invocation -> {
WarpInitiateEvent event = (WarpInitiateEvent) invocation.getArgument(0);
event.setCancelled(true);
return null;
}).when(pim).callEvent(eventCaptor.capture());
Player p = mock(Player.class);
when(p.getUniqueId()).thenReturn(UUID.randomUUID());
when(p.getWorld()).thenReturn(world);
when(p.getName()).thenReturn("tastybento");
when(p.getLocation()).thenReturn(location);
when(p.isOnline()).thenReturn(true);
when(p.canSee(any(Player.class))).thenReturn(true);
@Nullable
User u = User.getInstance(p);
PowerMockito.when(Util.teleportAsync(any(), any(), any())).thenReturn(CompletableFuture.completedFuture(true));
wsm.warpPlayer(world, u, uuid);
PowerMockito.verifyStatic(Util.class, never());
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
verify(player, never()).sendMessage(anyString());
} }
/** /**