Move unSit to main plugin class.
This commit is contained in:
parent
699d7a5ec3
commit
1fd11f4fb9
@ -39,9 +39,6 @@ public class Chairs extends JavaPlugin {
|
||||
public int sitEffectInterval;
|
||||
private File pluginFolder;
|
||||
private File configFile;
|
||||
public HashMap<String, Entity> sit = new HashMap<String, Entity>();
|
||||
public HashMap<Block, String> sitblock = new HashMap<Block, String>();
|
||||
public HashMap<String, Block> sitblockbr = new HashMap<String, Block>();
|
||||
public static final String PLUGIN_NAME = "Chairs";
|
||||
public static final String LOG_HEADER = "[" + PLUGIN_NAME + "]";
|
||||
static final Logger log = Bukkit.getLogger();
|
||||
@ -116,8 +113,20 @@ public class Chairs extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProtocolLibLoaded() {
|
||||
return (getServer().getPluginManager().getPlugin("ProtocolLib") != null);
|
||||
public HashMap<String, Entity> sit = new HashMap<String, Entity>();
|
||||
public HashMap<Block, String> sitblock = new HashMap<Block, String>();
|
||||
public HashMap<String, Block> sitblockbr = new HashMap<String, Block>();
|
||||
protected void unSit(Player player) {
|
||||
if (sit.containsKey(player.getName()))
|
||||
{
|
||||
sit.get(player.getName()).remove();
|
||||
sitblock.remove(sitblockbr.get(player.getName()));
|
||||
sitblockbr.remove(player.getName());
|
||||
sit.remove(player.getName());
|
||||
if (notifyplayer && !msgStanding.isEmpty()) {
|
||||
player.sendMessage(msgStanding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
|
@ -48,20 +48,11 @@ public class EventListener implements Listener {
|
||||
return true;
|
||||
}
|
||||
} else if (plugin.sit.containsKey(player.getName())) {
|
||||
unSit(player);
|
||||
plugin.unSit(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void unSit(Player player) {
|
||||
plugin.sit.get(player.getName()).remove();
|
||||
plugin.sitblock.remove(plugin.sitblockbr.get(player.getName()));
|
||||
plugin.sitblockbr.remove(player.getName());
|
||||
plugin.sit.remove(player.getName());
|
||||
if (plugin.notifyplayer && !plugin.msgStanding.isEmpty()) {
|
||||
player.sendMessage(plugin.msgStanding);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
@ -70,7 +61,7 @@ public class EventListener implements Listener {
|
||||
if (plugin.sit.containsKey(player.getName()))
|
||||
{
|
||||
player.eject();
|
||||
unSit(player);
|
||||
plugin.unSit(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +74,7 @@ public class EventListener implements Listener {
|
||||
String playername = plugin.sitblock.get(b);
|
||||
Player player = Bukkit.getPlayerExact(playername);
|
||||
player.eject();
|
||||
unSit(player);
|
||||
plugin.unSit(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class PacketListener {
|
||||
if (pluginInstance.sit.containsKey(player.getName()))
|
||||
{
|
||||
player.eject();
|
||||
unSit(player);
|
||||
pluginInstance.unSit(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,18 +51,7 @@ public class PacketListener {
|
||||
}
|
||||
|
||||
|
||||
private void unSit(Player player) {
|
||||
if (pluginInstance.sit.containsKey(player.getName()))
|
||||
{
|
||||
pluginInstance.sit.get(player.getName()).remove();
|
||||
pluginInstance.sitblock.remove(pluginInstance.sitblockbr.get(player.getName()));
|
||||
pluginInstance.sitblockbr.remove(player.getName());
|
||||
pluginInstance.sit.remove(player.getName());
|
||||
if (pluginInstance.notifyplayer && !pluginInstance.msgStanding.isEmpty()) {
|
||||
player.sendMessage(pluginInstance.msgStanding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user