Skip to content

Commit

Permalink
Make sure player is online before teleporting them to the lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofpu committed Feb 23, 2024
1 parent df8f0c7 commit a73af54
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.util.UUID;

Expand Down Expand Up @@ -169,10 +170,11 @@ public void cancel() {

resetState();

// teleporting the player to the lobby location
player.getPlayer()
.teleport(ConfigurationManager.INSTANCE.getLobbyCategory()
.getLobbyLocation());
Player bukkitPlayer = player.getPlayer();
if (bukkitPlayer != null && bukkitPlayer.isOnline()) {
// teleporting the player to the lobby location
bukkitPlayer.teleport(ConfigurationManager.INSTANCE.getLobbyCategory().getLobbyLocation());
}

resetPlot();
}
Expand All @@ -181,10 +183,12 @@ private void resetState() {
player.toggleSetup();

// inactivate the setup umbrella
umbrella.inactivate(player.getPlayer());

// setting the player's gamemode back to survival
player.getPlayer().setGameMode(GameMode.SURVIVAL);
Player bukkitPlayer = player.getPlayer();
umbrella.inactivate(bukkitPlayer);
if (bukkitPlayer != null && bukkitPlayer.isOnline()) {
// setting the player's gamemode back to survival
bukkitPlayer.setGameMode(GameMode.SURVIVAL);
}
}

/**
Expand Down

0 comments on commit a73af54

Please sign in to comment.