Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -833,13 +833,11 @@ public void on(final PlayerQuitEvent event) {
return;
}

// Kill the player to trigger the death handler which ends the match.
// Do NOT call PlayerUtil.reset() or info.restore() here — the player is dead
// and modifying their state causes corruption (e.g. stuck in adventure-like mode).
// PlayerInfo stays in cache and will be restored via PlayerRespawnEvent on rejoin.
player.setHealth(0);
player.getInventory().clear();
player.getInventory().setArmorContents(null);
player.updateInventory();

final PlayerInfo info = playerManager.get(player);
info.restore(player);
}

@EventHandler(ignoreCancelled = true)
Expand Down Expand Up @@ -892,8 +890,6 @@ public void on(final PlayerTeleportEvent event) {
if (!config.isLimitTeleportEnabled()
|| event.getCause() == TeleportCause.ENDER_PEARL
|| event.getCause() == TeleportCause.SPECTATE
|| event.getCause() == TeleportCause.PLUGIN
|| event.getCause() == TeleportCause.UNKNOWN
|| !arenaManager.isInMatch(player)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;

import java.util.Set;

Expand Down Expand Up @@ -53,8 +52,7 @@ public void on(final PlayerTeleportEvent event) {
final Player player = event.getPlayer();

if (player.isOp() || player.isDead() || player.hasPermission(Permissions.ADMIN) || player.hasPermission(Permissions.TP_BYPASS) ||
player.hasMetadata(Teleport.METADATA_KEY) || arenaManager.isInMatch(player) || spectateManager.isSpectating(player) ||
event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.UNKNOWN) {
player.hasMetadata(Teleport.METADATA_KEY) || arenaManager.isInMatch(player) || spectateManager.isSpectating(player)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public void tryTeleport(final Player player, final Location location) {
player.removePassenger(entity);
}

// Wake up sleeping players (bed) and eject from vehicles,
// otherwise player.teleport() fails with "Player is dead or is vehicle"
if (player.isSleeping()) {
player.wakeup(false);
}

if (player.isInsideVehicle()) {
player.leaveVehicle();
}

player.closeInventory();

if (essentials != null) {
Expand Down
Loading