Move some methods
This commit is contained in:
parent
e307801bdd
commit
04562288dd
@ -91,6 +91,35 @@ public class Chairs extends JavaPlugin {
|
||||
protected HashMap<String, Block> sitblockbr = new HashMap<String, Block>();
|
||||
protected HashMap<String, Location> sitstopteleportloc = new HashMap<String, Location>();
|
||||
protected HashMap<String, Integer> sittask = new HashMap<String, Integer>();
|
||||
protected void sitPlayer(Player player, Location sitlocation)
|
||||
{
|
||||
if (notifyplayer && !msgSitting.isEmpty()) {
|
||||
player.sendMessage(msgSitting);
|
||||
}
|
||||
Block block = sitlocation.getBlock();
|
||||
sitstopteleportloc.put(player.getName(), player.getLocation());
|
||||
Entity arrow = block.getWorld().spawnArrow(block.getLocation().add(0.5, 0 , 0.5), new Vector(0, 0.1, 0), 0, 0);
|
||||
player.teleport(sitlocation);
|
||||
player.setSneaking(false);
|
||||
arrow.setPassenger(player);
|
||||
sit.put(player.getName(), arrow);
|
||||
sitblock.put(block, player.getName());
|
||||
sitblockbr.put(player.getName(), block);
|
||||
startReSitTask(player);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
protected void startReSitTask(final Player player)
|
||||
{
|
||||
int task =
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
reSitPlayer(player);
|
||||
}
|
||||
},1000,1000);
|
||||
sittask.put(player.getName(), task);
|
||||
}
|
||||
protected void reSitPlayer(final Player player)
|
||||
{
|
||||
player.eject();
|
||||
|
@ -15,12 +15,10 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.material.Stairs;
|
||||
import org.bukkit.material.Step;
|
||||
import org.bukkit.material.WoodenStep;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
|
||||
@ -59,16 +57,6 @@ public class EventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.sit.containsKey(player.getName()))
|
||||
{
|
||||
plugin.unSitPlayer(player,false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -84,12 +72,11 @@ public class EventListener implements Listener {
|
||||
{
|
||||
event.setCancelled(true);
|
||||
Location sitLocation = getSitLocation(block, player.getLocation().getYaw());
|
||||
sitPlayer(player, sitLocation);
|
||||
plugin.sitPlayer(player, sitLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean sitAllowed(Player player, Block block)
|
||||
{
|
||||
Stairs stairs = null;
|
||||
@ -271,34 +258,6 @@ public class EventListener implements Listener {
|
||||
}
|
||||
|
||||
|
||||
private void sitPlayer(Player player, Location sitlocation)
|
||||
{
|
||||
if (plugin.notifyplayer && !plugin.msgSitting.isEmpty()) {
|
||||
player.sendMessage(plugin.msgSitting);
|
||||
}
|
||||
Block block = sitlocation.getBlock();
|
||||
plugin.sitstopteleportloc.put(player.getName(), player.getLocation());
|
||||
player.teleport(sitlocation);
|
||||
player.setSneaking(false);
|
||||
Entity arrow = block.getWorld().spawnArrow(block.getLocation().add(0.5, 0 , 0.5), new Vector(0, 0, 0), 0, 0);
|
||||
arrow.setPassenger(player);
|
||||
plugin.sit.put(player.getName(), arrow);
|
||||
plugin.sitblock.put(block, player.getName());
|
||||
plugin.sitblockbr.put(player.getName(), block);
|
||||
startReSitTask(player);
|
||||
}
|
||||
private void startReSitTask(final Player player)
|
||||
{
|
||||
int task =
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
plugin.reSitPlayer(player);
|
||||
}
|
||||
},1000,1000);
|
||||
plugin.sittask.put(player.getName(), task);
|
||||
}
|
||||
|
||||
private boolean isValidChair(Block block) {
|
||||
for (ChairBlock cb : plugin.allowedBlocks) {
|
||||
|
Loading…
Reference in New Issue
Block a user