コード例 #1
0
	@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
	public void onPlayerMove(final PlayerMoveEvent event)
	{
		final IUser user = userMap.getUser(event.getPlayer());

		final ISettings settings = ess.getSettings();

		if (user.getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers())
		{
			final Location from = event.getFrom();
			final Location to = event.getTo().clone();
			to.setX(from.getX());
			to.setY(from.getY());
			to.setZ(from.getZ());
			try
			{
				event.setTo(LocationUtil.getSafeDestination(to));
			}
			catch (Exception ex)
			{
				event.setTo(to);
			}
			return;
		}

		final Location afk = user.getAfkPosition();
		if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
		{
			user.updateActivity(true);
		}
	}
コード例 #2
0
ファイル: PListener.java プロジェクト: 2n3904/Battlefields
 public void onPlayerMove(PlayerMoveEvent event) {
   Block to = event.getTo().getBlock();
   Block from = event.getFrom().getBlock();
   if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return;
   Player p = event.getPlayer();
   TeamMember m = plugin.getBattlefieldManager().getPlayer(p);
   for (Battlefield field : plugin.getBattlefieldManager().getFields()) {
     BFRegion r = field.getRegion();
     int check = r.checkMovement(p, to, from);
     if (check < 0) {
       if (m == null) return;
       if (field.isActive()) {
         event.setTo(plugin.getLastLocation(p));
         Format.sendMessage(p, "Cannot leave battlefield during a match!");
       } else {
         Format.sendMessage(
             p,
             "Leaving the battlefield '"
                 + ChatColor.WHITE
                 + field.getName()
                 + ChatColor.GRAY
                 + "'.");
         field.removePlayer(m);
         r.setPlayerState(p, false);
       }
       return;
     } else if (check > 0) {
       if (field.isActive()) {
         event.setTo(plugin.getLastLocation(p));
         Format.sendMessage(p, "Cannot enter battlefield during a match!");
       } else {
         Format.sendMessage(
             p,
             "Entering the battlefield '"
                 + ChatColor.WHITE
                 + field.getName()
                 + ChatColor.GRAY
                 + "'.");
         field.addPlayer(p);
         r.setPlayerState(p, true);
       }
       return;
     } else {
       if (p.getLocation().getBlock().getRelative(BlockFace.DOWN).getTypeId() != 0)
         plugin.setLastLocation(p);
       if (field.isActive()) field.getGametype().getListener().onPlayerMove(m, from, to);
     }
   }
 }
コード例 #3
0
 @EventHandler
 public void freeze(PlayerMoveEvent event) {
   if (unwhitelisteds.contains(event.getPlayer().getUniqueId())
       && !event.getPlayer().hasPermission("TwitterWhitelist.IgnoreWhitelist")) {
     event.setTo(event.getFrom());
   }
 }
コード例 #4
0
  private static void resetPlayer(PlayerMoveEvent event, NoCheatData data) {

    Location l = data.speedhackSetBackPoint;

    data.reset = true;
    // If we have stored a location for the player, we put him back there
    if (l != null) {
      event.setFrom(l);
      event.setTo(l);
      event.setCancelled(true);
      event.getPlayer().teleportTo(l);
    } else {
      event.setFrom(event.getFrom());
      event.setTo(event.getFrom().clone());
      event.setCancelled(true);
      event.getPlayer().teleportTo(event.getFrom());
    }
  }
コード例 #5
0
  /** Move * */
  @EventHandler
  public void onMove(PlayerMoveEvent e) {
    if (!teleported) return;
    if (MTP.getSpectators().contains(e.getPlayer().getName())) return;

    if (e.getTo().getX() != e.getFrom().getX()
        || e.getTo().getY() != e.getFrom().getY()
        || e.getTo().getZ() != e.getFrom().getZ()) {
      e.setTo(e.getFrom());
    }
  }
コード例 #6
0
 @EventHandler
 public void onPlayerMove(PlayerMoveEvent e) {
   if (deprimo.contains(e.getPlayer().getName())) {
     e.getPlayer().setSneaking(true);
     if (e.getFrom().getY() < e.getTo().getY()) {
       e.getPlayer().getLocation().setY(e.getFrom().getY());
     }
   }
   if (petrificustotalus.contains(e.getPlayer().getName())) {
     e.setTo(e.getFrom());
   }
 }
コード例 #7
0
  @EventHandler
  public void denyMapExploit(PlayerMoveEvent event) {
    // Do nothing if this module is disabled.
    if (!settings.isFactionMap()) return;

    // Do nothing if player is not in a vehicle.
    Player player = event.getPlayer();
    if (!player.isInsideVehicle()) return;

    // Do nothing if player has permission.
    if (player.hasPermission(Perm.AntiGlitch.FACTION_MAP)) return;

    // Do nothing if distance is less than 8.
    if (event.getTo().distance(event.getFrom()) < 8D) return;

    // Deny movement.
    event.setTo(event.getFrom().setDirection(event.getTo().getDirection()));
  }
コード例 #8
0
ファイル: FreezeComponent.java プロジェクト: sd-/commandbook
  /**
   * Called on player movement.
   *
   * @param event Relevant event details
   */
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();

    if (player.getVehicle() != null) return; // handled in vehicle listener
    if (event.getFrom().getBlockX() != event.getTo().getBlockX()
        || event.getFrom().getBlockY() != event.getTo().getBlockY()
        || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {

      if (sessions.getAdminSession(player).isFrozen()) {

        player.sendMessage(ChatColor.RED + "You are frozen.");

        Location newLoc = event.getFrom();
        newLoc.setX(newLoc.getBlockX() + 0.5);
        newLoc.setY(newLoc.getBlockY());
        newLoc.setZ(newLoc.getBlockZ() + 0.5);
        event.setTo(newLoc);
      }
    }
  }
コード例 #9
0
ファイル: Portal.java プロジェクト: pvtjaime/Stargate-Bukkit
  public void teleport(Player player, Portal origin, PlayerMoveEvent event) {
    Location traveller = player.getLocation();
    Location exit = getExit(traveller);

    // Handle backwards gates
    int adjust = isBackwards() ? 0 : 180;
    exit.setYaw(origin.getRotation() - traveller.getYaw() + this.getRotation() + adjust);

    // Call the StargatePortalEvent to allow plugins to change destination
    if (!origin.equals(this)) {
      StargatePortalEvent pEvent = new StargatePortalEvent(player, origin, this, exit);
      Stargate.server.getPluginManager().callEvent(pEvent);
      // Teleport is cancelled
      if (pEvent.isCancelled()) {
        origin.teleport(player, origin, event);
        return;
      }
      // Update exit if needed
      exit = pEvent.getExit();
    }

    // The new method to teleport in a move event is set the "to" field.
    event.setTo(exit);
  }
コード例 #10
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerMove(PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    try {
      if (from.getWorld() == to.getWorld() && from.distanceSquared(to) < (0.0001 * 0.0001)) {
        // If player just rotated, but didn't move, don't process this event.
        return;
      }
    } catch (IllegalArgumentException ex) {
    }

    if (!TFM_AdminWorld.getInstance().validateMovement(event)) {
      return;
    }

    final Player player = event.getPlayer();
    final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);

    for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet()) {
      Player fuckoffPlayer = fuckoff.getKey();

      if (fuckoffPlayer.equals(player) || !fuckoffPlayer.isOnline()) {
        continue;
      }

      double fuckoffRange = fuckoff.getValue();

      Location playerLocation = player.getLocation();
      Location fuckoffLocation = fuckoffPlayer.getLocation();

      double distanceSquared;
      try {
        distanceSquared = playerLocation.distanceSquared(fuckoffLocation);
      } catch (IllegalArgumentException ex) {
        continue;
      }

      if (distanceSquared < (fuckoffRange * fuckoffRange)) {
        event.setTo(
            fuckoffLocation
                .clone()
                .add(
                    playerLocation
                        .subtract(fuckoffLocation)
                        .toVector()
                        .normalize()
                        .multiply(fuckoffRange * 1.1)));
        break;
      }
    }

    // Freeze
    if (!TFM_AdminList.isSuperAdmin(player) && playerdata.isFrozen()) {
      TFM_Util.setFlying(player, true);
      event.setTo(playerdata.getFreezeLocation());
    }

    if (playerdata.isCaged()) {
      Location targetPos = player.getLocation().add(0, 1, 0);

      boolean outOfCage;
      if (!targetPos.getWorld().equals(playerdata.getCagePos().getWorld())) {
        outOfCage = true;
      } else {
        outOfCage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
      }

      if (outOfCage) {
        playerdata.setCaged(
            true,
            targetPos,
            playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER),
            playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
        playerdata.regenerateHistory();
        playerdata.clearHistory();
        TFM_Util.buildHistory(targetPos, 2, playerdata);
        TFM_Util.generateHollowCube(
            targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
        TFM_Util.generateCube(
            targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
      }
    }

    if (playerdata.isOrbiting()) {
      if (player.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0)) {
        player.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
      }
    }

    if (TFM_Jumppads.getMode().isOn()) {
      TFM_Jumppads.PlayerMoveEvent(event);
    }

    if (!(TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean()
        && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())) {
      return;
    }

    final Iterator<Command_landmine.TFM_LandmineData> landmines =
        Command_landmine.TFM_LandmineData.landmines.iterator();
    while (landmines.hasNext()) {
      final Command_landmine.TFM_LandmineData landmine = landmines.next();

      final Location location = landmine.location;
      if (location.getBlock().getType() != Material.TNT) {
        landmines.remove();
        continue;
      }

      if (landmine.player.equals(player)) {
        break;
      }

      if (!player.getWorld().equals(location.getWorld())) {
        continue;
      }

      if (!(player.getLocation().distanceSquared(location)
          <= (landmine.radius * landmine.radius))) {
        break;
      }

      landmine.location.getBlock().setType(Material.AIR);

      final TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class);
      tnt1.setFuseTicks(40);
      tnt1.setPassenger(player);
      tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));

      final TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class);
      tnt2.setFuseTicks(1);

      player.setGameMode(GameMode.SURVIVAL);
      landmines.remove();
    }
  }
コード例 #11
0
  @Override
  public void onPlayerMove(PlayerMoveEvent event) {
    Location loc = event.getTo();
    World world = loc.getWorld();
    Block b = world.getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    if (!b.getType().equals(Material.PORTAL)) {
      // Not a portal.
      return;
    }

    if (world.getEnvironment().equals(Environment.NORMAL)) {
      // First of all see if there IS a nether yet
      // Here we use "netherworld"
      World nether = main.getServer().getWorld("netherworld");
      if (nether == null) {
        nether = main.getServer().createWorld("netherworld", Environment.NETHER);
      }

      if (!nether.getEnvironment().equals(Environment.NETHER)) {
        // Don't teleport to a non-nether world
        return;
      }

      // Try to find a portal near where the player should land
      Block dest = nether.getBlockAt(b.getX() / 8, b.getY(), b.getZ() / 8);
      NetherPortal portal = NetherPortal.findPortal(dest);
      if (portal == null) {
        portal = NetherPortal.createPortal(dest);
        main.log(event.getPlayer().getName() + " portals to Nether [NEW]");
      } else {
        main.log(event.getPlayer().getName() + " portals to Nether");
      }

      // Go!
      Location spawn = portal.getSpawn();
      event.getPlayer().teleportTo(spawn);
      event.setTo(spawn);
    } else if (world.getEnvironment().equals(Environment.NETHER)) {
      // For now just head to the first world there.
      World normal = main.getServer().getWorlds().get(0);

      if (!normal.getEnvironment().equals(Environment.NORMAL)) {
        // Don't teleport to a non-normal world
        return;
      }

      // Try to find a portal near where the player should land
      Block dest = normal.getBlockAt(b.getX() * 8, b.getY(), b.getZ() * 8);
      NetherPortal portal = NetherPortal.findPortal(dest);
      if (portal == null) {
        portal = NetherPortal.createPortal(dest);
        main.log(event.getPlayer().getName() + " portals to normal world [NEW]");
      } else {
        main.log(event.getPlayer().getName() + " portals to normal world");
      }

      // Go!
      Location spawn = portal.getSpawn();
      event.getPlayer().teleportTo(spawn);
      event.setTo(spawn);
    }
  }
コード例 #12
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerMove(PlayerMoveEvent event) {
    if (!TFM_AdminWorld.getInstance().validateMovement(event)) {
      return;
    }

    Player p = event.getPlayer();
    TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);

    for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet()) {
      Player fuckoff_player = fuckoff.getKey();

      if (fuckoff_player.equals(p) || !fuckoff_player.isOnline()) {
        continue;
      }

      double fuckoff_range = fuckoff.getValue().doubleValue();

      Location mover_pos = p.getLocation();
      Location fuckoff_pos = fuckoff_player.getLocation();

      double distanceSquared;
      try {
        distanceSquared = mover_pos.distanceSquared(fuckoff_pos);
      } catch (IllegalArgumentException ex) {
        continue;
      }

      if (distanceSquared < (fuckoff_range * fuckoff_range)) {
        event.setTo(
            fuckoff_pos
                .clone()
                .add(
                    mover_pos
                        .subtract(fuckoff_pos)
                        .toVector()
                        .normalize()
                        .multiply(fuckoff_range * 1.1)));
        break;
      }
    }

    boolean do_freeze = false;
    if (TotalFreedomMod.allPlayersFrozen) {
      if (!TFM_SuperadminList.isUserSuperadmin(p)) {
        do_freeze = true;
      }
    } else {
      if (playerdata.isFrozen()) {
        do_freeze = true;
      }
    }

    if (do_freeze) {
      Location from = event.getFrom();
      Location to = event.getTo().clone();

      to.setX(from.getX());
      to.setY(from.getY());
      to.setZ(from.getZ());

      event.setTo(to);
    }

    if (playerdata.isCaged()) {
      Location target_pos = p.getLocation().add(0, 1, 0);

      boolean out_of_cage;
      if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld())) {
        out_of_cage = true;
      } else {
        out_of_cage = target_pos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
      }

      if (out_of_cage) {
        playerdata.setCaged(
            true,
            target_pos,
            playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER),
            playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
        playerdata.regenerateHistory();
        playerdata.clearHistory();
        TFM_Util.buildHistory(target_pos, 2, playerdata);
        TFM_Util.generateCube(
            target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
        TFM_Util.generateCube(
            target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
      }
    }

    if (playerdata.isOrbiting()) {
      if (p.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0)) {
        p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
      }
    }

    if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions) {
      Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
      while (landmines.hasNext()) {
        TFM_LandmineData landmine = landmines.next();

        Location landmine_pos = landmine.landmine_pos;
        if (landmine_pos.getBlock().getType() != Material.TNT) {
          landmines.remove();
          continue;
        }

        if (!landmine.player.equals(p)) {
          if (p.getWorld().equals(landmine_pos.getWorld())) {
            if (p.getLocation().distanceSquared(landmine_pos)
                <= (landmine.radius * landmine.radius)) {
              landmine.landmine_pos.getBlock().setType(Material.AIR);

              TNTPrimed tnt1 = landmine_pos.getWorld().spawn(landmine_pos, TNTPrimed.class);
              tnt1.setFuseTicks(40);
              tnt1.setPassenger(p);
              tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));

              TNTPrimed tnt2 = landmine_pos.getWorld().spawn(p.getLocation(), TNTPrimed.class);
              tnt2.setFuseTicks(1);

              p.setGameMode(GameMode.SURVIVAL);
              landmines.remove();
            }
          }
        }
      }
    }
  }
コード例 #13
0
  /* (non-Javadoc)
   * @see org.bukkit.event.player.PlayerListener#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)
   */
  @Override
  public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    Location l = event.getTo();
    Block ch = l.getWorld().getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
    Stargate st = StargateManager.getGateFromBlock(ch);

    if (st != null && st.Active && st.Target != null) {
      String gatenetwork;
      if (st.Network != null) {
        gatenetwork = st.Network.netName;
      } else {
        gatenetwork = "Public";
      }
      wxt.prettyLog(
          Level.FINE,
          false,
          "Player in gate:"
              + st.Name
              + " gate Active: "
              + st.Active
              + " Target Gate: "
              + st.Target.Name
              + " Network: "
              + gatenetwork);

      if (ConfigManager.getWormholeUseIsTeleport()
          && ((st.IsSignPowered && !WXPermissions.checkWXPermissions(p, st, PermissionType.SIGN))
              || (!st.IsSignPowered
                  && !WXPermissions.checkWXPermissions(p, st, PermissionType.DIALER)))) {
        p.sendMessage(ConfigManager.output_strings.get(StringTypes.PERMISSION_NO));
        return;
      }
      if (st.Target.IrisActive) {
        p.sendMessage(ConfigManager.errorheader + "Remote Iris is locked!");
        p.setNoDamageTicks(2);
        event.setFrom(st.TeleportLocation);
        event.setTo(st.TeleportLocation);
        p.teleport(st.TeleportLocation);
        if (p.getFireTicks() > 0) {
          p.setFireTicks(0);
        }
        return;
      }

      Location target = st.Target.TeleportLocation;
      if (WormholeXTreme.iconomy != null) {
        double cost = ConfigManager.getIconomyWormholeUseCost();
        if (!ConfigManager.getIconomyOpsExcempt()
            && !p.isOp()
            && cost != 0.0
            && st.Owner != null
            && !st.Owner.equals(p.getName())) {
          Account player_account = iConomy.getBank().getAccount(p.getName());
          double balance = player_account.getBalance();
          String currency = iConomy.getBank().getCurrency();
          if (balance >= cost) {
            player_account.subtract(cost);
            // player_account.save();
            p.sendMessage(
                ConfigManager.normalheader
                    + "Wormhole Use \u00A7F- \u00A72"
                    + cost
                    + " \u00A77"
                    + currency);
            // p.sendMessage("You were charged " + cost + " " + iConomy.getBank().getCurrency() + "
            // to use wormhole." );
            double owner_percent = ConfigManager.getIconomyWormholeOwnerPercent();

            if (owner_percent != 0.0 && st.Owner != null) {
              if (st.Owner != null && iConomy.getBank().hasAccount(st.Owner)) {
                Account own_acc = iConomy.getBank().getAccount(st.Owner);
                own_acc.add(cost * owner_percent);
                // own_acc.save();
              }
            }
          } else {
            p.sendMessage(
                ConfigManager.errorheader
                    + "Not enough "
                    + currency
                    + "! - Requires: \u00A72"
                    + cost
                    + " \u00A77- Available: \u00A74"
                    + player_account.getBalance()
                    + " \u00A77"
                    + currency);
            // p.sendMessage("Not enough " + iConomy.getBank().getCurrency() + " to use - requires:
            // " + cost);
            target = st.TeleportLocation;
          }
        }
      }

      Block target_block =
          target.getWorld().getBlockAt(target.getBlockX(), target.getBlockY(), target.getBlockZ());
      while (target_block.getType() != Material.AIR
          && target_block.getType() != Material.WATER
          && target_block.getType() != Material.LAVA) {
        target_block = target_block.getFace(BlockFace.UP);
        target.setY(target.getY() + 1.0);
      }
      event.setFrom(target);
      event.setTo(target);
      p.setNoDamageTicks(2);
      p.teleport(target);
      event.setCancelled(true);
      if (target == st.Target.TeleportLocation)
        wxt.prettyLog(
            Level.INFO,
            false,
            p.getDisplayName() + " used wormhole: " + st.Name + " to go to: " + st.Target.Name);

      if (ConfigManager.getTimeoutShutdown() == 0) {
        st.ShutdownStargate();
      }
    } else if (st != null) {
      wxt.prettyLog(
          Level.FINE, false, "Player entered gate but wasn't active or didn't have a target.");
    }
  }
コード例 #14
0
  @Override
  public void onPlayerMove(final PlayerMoveEvent event) {
    if (event.isCancelled()) {
      return;
    }
    final User user = ess.getUser(event.getPlayer());

    if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
      final Location from = event.getFrom();
      final Location to = event.getTo().clone();
      to.setX(from.getX());
      to.setY(from.getBlock().getTypeId() == 0 ? from.getY() - 1 : from.getY());
      to.setZ(from.getZ());
      event.setTo(to);
      return;
    }

    Location afk = user.getAfkPosition();
    if (afk == null
        || !event.getTo().getWorld().equals(afk.getWorld())
        || afk.distanceSquared(event.getTo()) > 9) {
      user.updateActivity(true);
    }

    if (!ess.getSettings().getNetherPortalsEnabled()) {
      return;
    }

    final Block block =
        event
            .getPlayer()
            .getWorld()
            .getBlockAt(
                event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
    final List<World> worlds = server.getWorlds();

    if (block.getType() == Material.PORTAL
        && worlds.size() > 1
        && user.isAuthorized("essentials.portal")) {
      if (user.getJustPortaled()) {
        return;
      }

      World nether = server.getWorld(ess.getSettings().getNetherName());
      if (nether == null) {
        for (World world : worlds) {
          if (world.getEnvironment() == World.Environment.NETHER) {
            nether = world;
            break;
          }
        }
        if (nether == null) {
          return;
        }
      }
      final World world = user.getWorld() == nether ? worlds.get(0) : nether;

      double factor;
      if (user.getWorld().getEnvironment() == World.Environment.NETHER
          && world.getEnvironment() == World.Environment.NORMAL) {
        factor = ess.getSettings().getNetherRatio();
      } else if (user.getWorld().getEnvironment() == World.Environment.NORMAL
          && world.getEnvironment() == World.Environment.NETHER) {
        factor = 1.0 / ess.getSettings().getNetherRatio();
      } else {
        factor = 1.0;
      }

      Location loc = event.getTo();
      int x = loc.getBlockX();
      int y = loc.getBlockY();
      int z = loc.getBlockZ();

      if (user.getWorld().getBlockAt(x, y, z - 1).getType() == Material.PORTAL) {
        z--;
      }
      if (user.getWorld().getBlockAt(x - 1, y, z).getType() == Material.PORTAL) {
        x--;
      }

      x = (int) (x * factor);
      z = (int) (z * factor);
      loc = new Location(world, x + .5, y, z + .5);

      Block dest = world.getBlockAt(x, y, z);
      NetherPortal portal = NetherPortal.findPortal(dest);
      if (portal == null) {
        if (world.getEnvironment() == World.Environment.NETHER
            || ess.getSettings().getGenerateExitPortals()) {
          portal = NetherPortal.createPortal(dest);
          LOGGER.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
          user.sendMessage(Util.i18n("generatingPortal"));
          loc = portal.getSpawn();
        }
      } else {
        LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
        user.sendMessage(Util.i18n("usingPortal"));
        loc = portal.getSpawn();
      }

      event.setFrom(loc);
      event.setTo(loc);
      try {
        user.getTeleport().now(loc, new Trade("portal", ess));
      } catch (Exception ex) {
        user.sendMessage(ex.getMessage());
      }
      user.setJustPortaled(true);
      user.sendMessage(Util.i18n("teleportingPortal"));

      event.setCancelled(true);
      return;
    }

    user.setJustPortaled(false);
  }