mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
Avoids NPE in Admin Delete
This commit is contained in:
parent
d6b0859d40
commit
6d7f0eaf6d
@ -5,6 +5,8 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
@ -67,6 +69,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
||||
// Delete player and island
|
||||
// Get the target's island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||
Vector vector = null;
|
||||
if (oldIsland != null) {
|
||||
// Check if player is online and on the island
|
||||
User target = User.getInstance(targetUUID);
|
||||
@ -84,10 +87,15 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
||||
getPlugin().getVault().ifPresent(vault -> vault.withdraw(target, vault.getBalance(target)));
|
||||
}
|
||||
}
|
||||
vector = oldIsland.getCenter().toVector();
|
||||
getIslands().deleteIsland(oldIsland, true, targetUUID);
|
||||
}
|
||||
getPlayers().clearHomeLocations(getWorld(), targetUUID);
|
||||
user.sendMessage("commands.admin.delete.deleted-island", "[xyz]", Util.xyz(getIslands().getIsland(getWorld(), targetUUID).getCenter().toVector()));
|
||||
if (vector == null) {
|
||||
user.sendMessage("general.success");
|
||||
} else {
|
||||
user.sendMessage("commands.admin.delete.deleted-island", "[xyz]", Util.xyz(vector));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user