Properly unsit player
This commit is contained in:
parent
ab080914b0
commit
e6d1a1ed76
@ -83,8 +83,10 @@ public class Chairs extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for (String pName : new HashSet<String>(sit.keySet())) {
|
||||
ejectPlayerOnDisable(Bukkit.getPlayerExact(pName));
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
if (sit.containsKey(player.getName())) {
|
||||
unSitPlayer(player, true);
|
||||
}
|
||||
}
|
||||
if (ignoreList != null) {
|
||||
ignoreList.save();
|
||||
@ -184,11 +186,21 @@ public class Chairs extends JavaPlugin {
|
||||
}
|
||||
protected void unSitPlayer(final Player player, boolean ignoretp)
|
||||
{
|
||||
final Entity arrow = sit.get(player.getName());
|
||||
sit.remove(player.getName());
|
||||
player.eject();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
arrow.remove();
|
||||
}
|
||||
},20);
|
||||
final Location tploc = sitstopteleportloc.get(player.getName());
|
||||
if (tploc != null && !ignoretp)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
player.teleport(tploc);
|
||||
@ -196,28 +208,16 @@ public class Chairs extends JavaPlugin {
|
||||
}
|
||||
},1);
|
||||
}
|
||||
clearSitInfo(player);
|
||||
}
|
||||
private void ejectPlayerOnDisable(Player player)
|
||||
{
|
||||
player.eject();
|
||||
clearSitInfo(player);
|
||||
}
|
||||
protected void clearSitInfo(Player player) {
|
||||
if (sit.containsKey(player.getName()))
|
||||
{
|
||||
sit.get(player.getName()).remove();
|
||||
sitblock.remove(sitblockbr.get(player.getName()));
|
||||
sitblockbr.remove(player.getName());
|
||||
sitstopteleportloc.remove(player.getName());
|
||||
sit.remove(player.getName());
|
||||
Bukkit.getScheduler().cancelTask(sittask.get(player.getName()));
|
||||
sittask.remove(player.getName());
|
||||
if (notifyplayer && !msgStanding.isEmpty()) {
|
||||
if (notifyplayer && !msgStanding.isEmpty())
|
||||
{
|
||||
player.sendMessage(msgStanding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(),"config.yml"));
|
||||
|
@ -281,14 +281,7 @@ public class EventListener implements Listener {
|
||||
}
|
||||
|
||||
private boolean isSitting(Player player) {
|
||||
if (plugin.sit.containsKey(player.getName())) {
|
||||
if (player.isInsideVehicle()) {
|
||||
return true;
|
||||
} else {
|
||||
plugin.clearSitInfo(player);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return plugin.sit.containsKey(player.getName());
|
||||
}
|
||||
|
||||
private int getChairWidth(Block block, BlockFace face) {
|
||||
|
Loading…
Reference in New Issue
Block a user