@Override
public void run()
{
for (Iterator iter = waitingPlayers.values().iterator(); iter.hasNext(); )
{
TeleportState state = (TeleportState) iter.next();
if (state.isProcessing())
{
continue;
}
state.setProcessing(true);
Player player = state.getPlayer();
if (player != null)
{
if (state.isTeleportTime())
{
if (Helper.isSameBlock(player.getLocation(), state.getLocation()))
{
Location loc = state.getDestination();
int x = loc.getBlockX();
int z = loc.getBlockZ();
if (plugin.getSettingsManager().isTeleportBlocks()) {
player.sendBlockChange(new Location(loc.getWorld(), x + 1, loc.getBlockY() - 1, z + 1), Material.GLASS, (byte) 0);
player.sendBlockChange(new Location(loc.getWorld(), x - 1, loc.getBlockY() - 1, z - 1), Material.GLASS, (byte) 0);
player.sendBlockChange(new Location(loc.getWorld(), x + 1, loc.getBlockY() - 1, z - 1), Material.GLASS, (byte) 0);
player.sendBlockChange(new Location(loc.getWorld(), x - 1, loc.getBlockY() - 1, z + 1), Material.GLASS, (byte) 0);
}
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.keep-items"))
{
dropItems(player);
}
SimpleClans.debug("teleporting");
player.teleport(new Location(loc.getWorld(), loc.getBlockX() + .5, loc.getBlockY(), loc.getBlockZ() + .5));
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("now.at.homebase"), state.getClanName()));
}
else
{
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.moved.teleport.cancelled"));
}
iter.remove();
}
else
{
if (!Helper.isSameBlock(player.getLocation(), state.getLocation()))
{
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.moved.teleport.cancelled"));
iter.remove();
}
else
{
ChatBlock.sendMessage(player, ChatColor.AQUA + "" + state.getCounter());
}
}
}
else
{
iter.remove();
}
state.setProcessing(false);
}
}
}, 0, 20L);
}