Move eject code

This commit is contained in:
Shevchik 2013-09-01 16:10:18 +04:00
parent 244a453390
commit c110202161
4 changed files with 14 additions and 11 deletions

View File

@ -113,15 +113,22 @@ public class Chairs extends JavaPlugin {
} }
} }
public HashMap<String, Entity> sit = new HashMap<String, Entity>(); protected HashMap<String, Entity> sit = new HashMap<String, Entity>();
public HashMap<Block, String> sitblock = new HashMap<Block, String>(); protected HashMap<Block, String> sitblock = new HashMap<Block, String>();
public HashMap<String, Block> sitblockbr = new HashMap<String, Block>(); protected HashMap<String, Block> sitblockbr = new HashMap<String, Block>();
protected HashMap<String, Location> sitstopteleportloc = new HashMap<String, Location>();
protected void ejectPlayer(Player player)
{
player.eject();
unSit(player);
}
protected void unSit(Player player) { protected void unSit(Player player) {
if (sit.containsKey(player.getName())) if (sit.containsKey(player.getName()))
{ {
sit.get(player.getName()).remove(); sit.get(player.getName()).remove();
sitblock.remove(sitblockbr.get(player.getName())); sitblock.remove(sitblockbr.get(player.getName()));
sitblockbr.remove(player.getName()); sitblockbr.remove(player.getName());
sitstopteleportloc.remove(player.getName());
sit.remove(player.getName()); sit.remove(player.getName());
if (notifyplayer && !msgStanding.isEmpty()) { if (notifyplayer && !msgStanding.isEmpty()) {
player.sendMessage(msgStanding); player.sendMessage(msgStanding);

View File

@ -60,8 +60,7 @@ public class EventListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (plugin.sit.containsKey(player.getName())) if (plugin.sit.containsKey(player.getName()))
{ {
player.eject(); plugin.ejectPlayer(player);
plugin.unSit(player);
} }
} }
@ -71,10 +70,8 @@ public class EventListener implements Listener {
Block b = event.getBlock(); Block b = event.getBlock();
if (plugin.sitblock.containsKey(b)) if (plugin.sitblock.containsKey(b))
{ {
String playername = plugin.sitblock.get(b); Player player = Bukkit.getPlayerExact(plugin.sitblock.get(b));
Player player = Bukkit.getPlayerExact(playername); plugin.ejectPlayer(player);
player.eject();
plugin.unSit(player);
} }
} }

View File

@ -41,8 +41,7 @@ public class PacketListener {
//just eject player if he is sitting on chair //just eject player if he is sitting on chair
if (pluginInstance.sit.containsKey(player.getName())) if (pluginInstance.sit.containsKey(player.getName()))
{ {
player.eject(); pluginInstance.ejectPlayer(player);
pluginInstance.unSit(player);
} }
} }
} }

Binary file not shown.