Skip to content

Commit

Permalink
Objects.requireNonNull for User
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Aug 9, 2021
1 parent 0003c91 commit 3cd93f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/world/bentobox/warps/WarpSignsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public SignCacheItem getSignInfo(@NonNull World world, @NonNull UUID uuid) {
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()));
}
Expand Down Expand Up @@ -352,7 +352,7 @@ private void warpPlayer(@NonNull User user, @NonNull Location inFront, @NonNull
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -84,14 +85,14 @@ public void run() {
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");
}

/**
Expand All @@ -111,6 +112,7 @@ public void onSignBreak(BlockBreakEvent e) {
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());
Expand Down Expand Up @@ -149,7 +151,7 @@ public void onSignWarpCreate(SignChangeEvent e) {
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
Expand Down

0 comments on commit 3cd93f3

Please sign in to comment.