Fixes NPE caused by island delete of a null island

If a player is invited and has no island, the accept command was still
trying to delete it and causing an NPE.

Also, the island save was being done on the old island, not the new team
island.
https://github.com/BentoBoxWorld/BentoBox/issues/481
This commit is contained in:
tastybento 2019-01-22 12:53:33 -08:00
parent 4958304aa5
commit 9e0772367a

View File

@ -96,7 +96,9 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
// Set the player's home
getPlayers().setHomeLocation(playerUUID, user.getLocation());
// Delete the old island
getIslands().deleteIsland(island, true);
if (island != null) {
getIslands().deleteIsland(island, true);
}
// TODO Set the cooldown
// Reset deaths
if (getIWM().isTeamJoinDeathReset(getWorld())) {
@ -110,7 +112,7 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
if (inviter != null) {
inviter.sendMessage("commands.island.team.invite.accept.name-joined-your-island", TextVariables.NAME, user.getName());
}
getIslands().save(island);
getIslands().save(teamIsland);
});
return true;