From 178529adb123275d5929aa57f8294e7a5005484f Mon Sep 17 00:00:00 2001 From: Huynh Tien Date: Sat, 29 Jan 2022 09:42:56 +0700 Subject: [PATCH] Fix null in reject invite (#1933) * remove debug * fix null in reject invite --- .../island/team/IslandTeamInviteRejectCommand.java | 12 +++++++----- .../flags/protection/InventoryListener.java | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteRejectCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteRejectCommand.java index 963f24065..b09644b77 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteRejectCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteRejectCommand.java @@ -1,6 +1,7 @@ package world.bentobox.bentobox.api.commands.island.team; import java.util.List; +import java.util.Optional; import java.util.UUID; import world.bentobox.bentobox.api.commands.CompositeCommand; @@ -40,14 +41,15 @@ public class IslandTeamInviteRejectCommand extends CompositeCommand { return false; } + Optional.ofNullable(itc.getInviter(playerUUID)) + .map(User::getInstance) + .ifPresent(inviter -> + inviter.sendMessage("commands.island.team.invite.reject.name-rejected-your-invite", TextVariables.NAME, user.getName()) + ); + // Remove this player from the global invite list itc.removeInvite(user.getUniqueId()); user.sendMessage("commands.island.team.invite.reject.you-rejected-invite"); - - User inviter = User.getInstance(itc.getInviter(playerUUID)); - if (inviter != null) { - inviter.sendMessage("commands.island.team.invite.reject.name-rejected-your-invite", TextVariables.NAME, user.getName()); - } } else { // Someone typed /island reject and had not been invited user.sendMessage("commands.island.team.invite.errors.none-invited-you"); diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/InventoryListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/InventoryListener.java index 090341a63..5f408b2a3 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/InventoryListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/InventoryListener.java @@ -85,7 +85,6 @@ public class InventoryListener extends FlagListener { checkIsland(e, player, e.getInventory().getLocation(), Flags.CHEST); } else if (!(inventoryHolder instanceof Player)) { - BentoBox.getInstance().logDebug(inventoryHolder.getClass().toGenericString()); // All other containers checkIsland(e, player, e.getInventory().getLocation(), Flags.CONTAINER); }