1
0
mirror of https://github.com/BentoBoxWorld/Warps.git synced 2024-11-15 23:25:27 +01:00

Objects.requireNonNull for User

This commit is contained in:
tastybento 2021-08-08 17:36:03 -07:00
parent 0003c91cca
commit 3cd93f39dd
2 changed files with 7 additions and 5 deletions

View File

@ -322,7 +322,7 @@ public class WarpSignsManager {
if (!prefix.isEmpty())
{
icon = Material.matchMaterial(
this.getPermissionValue(User.getInstance(uuid),
this.getPermissionValue(Objects.requireNonNull(User.getInstance(uuid)),
prefix + "island.warp",
this.addon.getSettings().getIcon()));
}
@ -352,7 +352,7 @@ public class WarpSignsManager {
final Location actualWarp = new Location(inFront.getWorld(), inFront.getBlockX() + 0.5D, inFront.getBlockY(),
inFront.getBlockZ() + 0.5D, yaw, 30F);
Util.teleportAsync(user.getPlayer(), actualWarp, TeleportCause.COMMAND);
User warpOwner = User.getInstance(signOwner);
User warpOwner = Objects.requireNonNull(User.getInstance(signOwner));
// Hide invisible players
if (warpOwner.isOnline() && !warpOwner.getPlayer().canSee(user.getPlayer())) {
return;

View File

@ -3,6 +3,7 @@ package world.bentobox.warps.listeners;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import org.bukkit.Bukkit;
@ -84,14 +85,14 @@ public class WarpSignsListener implements Listener {
public void onPlayerLeave(TeamLeaveEvent e) {
// Remove any warp signs from this game mode
addon.getWarpSignsManager().removeWarp(e.getIsland().getWorld(), e.getPlayerUUID());
User.getInstance(e.getPlayerUUID()).sendMessage("warps.deactivate");
Objects.requireNonNull(User.getInstance(e.getPlayerUUID())).sendMessage("warps.deactivate");
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerLeave(TeamKickEvent e) {
// Remove any warp signs from this game mode
addon.getWarpSignsManager().removeWarp(e.getIsland().getWorld(), e.getPlayerUUID());
User.getInstance(e.getPlayerUUID()).sendMessage("warps.deactivate");
Objects.requireNonNull(User.getInstance(e.getPlayerUUID())).sendMessage("warps.deactivate");
}
/**
@ -111,6 +112,7 @@ public class WarpSignsListener implements Listener {
return;
}
User user = User.getInstance(e.getPlayer());
if (user == null) return;
UUID owner = addon.getWarpSignsManager().getWarpOwnerUUID(b.getLocation()).orElse(null);
if (isPlayersSign(e.getPlayer(), b, inWorld)) {
addon.getWarpSignsManager().removeWarp(b.getLocation());
@ -149,7 +151,7 @@ public class WarpSignsListener implements Listener {
return;
}
String title = e.getLine(0);
User user = User.getInstance(e.getPlayer());
User user = Objects.requireNonNull(User.getInstance(e.getPlayer()));
// Check if someone is changing their own sign
if (title.equalsIgnoreCase(addon.getSettings().getWelcomeLine())) {
// Welcome sign detected - check permissions