Fix issue with players falling through the ground after logout.

This commit is contained in:
cnaude 2013-03-31 14:44:50 -07:00
parent 4144e06170
commit d97c1adaf0
3 changed files with 16 additions and 4 deletions

View File

@ -15,6 +15,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -74,6 +75,13 @@ public class Chairs extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
for (String pName : sit.keySet()) {
Player player = getServer().getPlayer(pName);
Location loc = player.getLocation().clone();
loc.setY(loc.getY() + 1);
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
}
if (ignoreList != null) { if (ignoreList != null) {
ignoreList.save(); ignoreList.save();
} }

View File

@ -20,6 +20,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.material.Stairs; import org.bukkit.material.Stairs;
import org.bukkit.material.Step; import org.bukkit.material.Step;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
@ -73,9 +74,12 @@ public class EventListener implements Listener {
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
String pName = event.getPlayer().getName(); Player player = event.getPlayer();
if (plugin.sit.containsKey(pName)) { if (plugin.sit.containsKey(player.getName())) {
plugin.sit.remove(pName); plugin.sendStand(player);
Location loc = player.getLocation().clone();
loc.setY(loc.getY() + 1);
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
} }
} }

View File

@ -1,5 +1,5 @@
name: Chairs name: Chairs
version: 2.0.0 version: 2.0.1
description: Let players sit on blocks. description: Let players sit on blocks.
authors: authors:
- spoothie - spoothie