This commit is contained in:
parent
b3a36c75bb
commit
8be844b59f
|
@ -26,7 +26,6 @@ import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -350,26 +349,34 @@ 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);
|
||||||
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND);
|
//BentoBox prevents people from teleporting to an island when
|
||||||
User warpOwner = Objects.requireNonNull(User.getInstance(signOwner));
|
//the user is banned from the island for example.
|
||||||
// Hide invisible players
|
//By checking if the teleport succeeded before sending the messages,
|
||||||
if (warpOwner.isOnline() && !warpOwner.getPlayer().canSee(user.getPlayer())) {
|
//we prevent issues where no one teleported, but people still
|
||||||
return;
|
//get messages about it.
|
||||||
}
|
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND).thenAccept(tpResult -> {
|
||||||
if (pvp) {
|
if(!tpResult) return;
|
||||||
user.sendMessage("protection.flags.PVP_OVERWORLD.enabled");
|
|
||||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
|
||||||
} else {
|
|
||||||
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
|
||||||
}
|
|
||||||
if (!warpOwner.equals(user)) {
|
|
||||||
final String gameMode = BentoBox
|
|
||||||
.getInstance()
|
|
||||||
.getIWM()
|
|
||||||
.getFriendlyName(actualWarp.getWorld());
|
|
||||||
|
|
||||||
warpOwner.sendMessage("warps.player-warped", "[name]", user.getName(), "[gamemode]", gameMode);
|
User warpOwner = Objects.requireNonNull(User.getInstance(signOwner));
|
||||||
}
|
// Hide invisible players
|
||||||
|
if (warpOwner.isOnline() && !warpOwner.getPlayer().canSee(user.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pvp) {
|
||||||
|
user.sendMessage("protection.flags.PVP_OVERWORLD.enabled");
|
||||||
|
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_ARROW_HIT, 1F, 1F);
|
||||||
|
} else {
|
||||||
|
user.getWorld().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_BAT_TAKEOFF, 1F, 1F);
|
||||||
|
}
|
||||||
|
if (!warpOwner.equals(user)) {
|
||||||
|
final String gameMode = BentoBox
|
||||||
|
.getInstance()
|
||||||
|
.getIWM()
|
||||||
|
.getFriendlyName(actualWarp.getWorld());
|
||||||
|
|
||||||
|
warpOwner.sendMessage("warps.player-warped", "[name]", user.getName(), "[gamemode]", gameMode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -428,6 +428,7 @@ public class WarpSignsManagerTest {
|
||||||
when(p.getLocation()).thenReturn(location);
|
when(p.getLocation()).thenReturn(location);
|
||||||
@Nullable
|
@Nullable
|
||||||
User u = User.getInstance(p);
|
User u = User.getInstance(p);
|
||||||
|
PowerMockito.when(Util.teleportAsync(any(), any(), any())).thenReturn(CompletableFuture.completedFuture(true));
|
||||||
wsm.warpPlayer(world, u, uuid);
|
wsm.warpPlayer(world, u, uuid);
|
||||||
PowerMockito.verifyStatic(Util.class);
|
PowerMockito.verifyStatic(Util.class);
|
||||||
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
|
Util.teleportAsync(eq(p), any(), eq(TeleportCause.COMMAND));
|
||||||
|
|
Loading…
Reference in New Issue