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