@EventHandler(priority = EventPriority.MONITOR)
  public void onPlayerMove(PlayerMoveEvent event) {

    // BAD BAD BAD test code
    //	hwh.randomlyRegisterWorld(event.getPlayer().getWorld());

    Location to = event.getTo();
    int newY = to.getBlockY();
    if (newY < HigherWorldsHack.SHARE_HEIGHT) {
      Player p = event.getPlayer();
      World w = worldStack.get(event.getTo().getWorld());
      if (w == null) return;
      Location toTeleportTo =
          new Location(w, to.getX(), HigherWorldsHack.transformPosUp(newY), to.getZ());
      HigherWorldsHack.HWH_LOGGER.log(
          Level.WARNING, "Player moved from " + to + " to " + toTeleportTo);
      p.teleport(toTeleportTo);
    } else if (newY > HigherWorldsHack.WORLD_HEIGHT - HigherWorldsHack.SHARE_HEIGHT) {
      Player p = event.getPlayer();
      World w = worldStack.inverse().get(event.getTo().getWorld());
      if (w == null) return;
      Location toTeleportTo =
          new Location(w, to.getX(), HigherWorldsHack.transformPosDown(newY), to.getZ());
      HigherWorldsHack.HWH_LOGGER.log(
          Level.WARNING, "Player moved from " + to + " to " + toTeleportTo);
      p.teleport(toTeleportTo);
    }
  }
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent e) {
    if (b) return;
    if (getObjID() == null) {
      return;
    }
    if (getObjID().getSQLAction().equals(SQLAction.REMOVE)) {
      return;
    }
    if (e.isCancelled()) {
      return;
    }

    if (e.getFrom().getWorld() == e.getTo().getWorld()
        && e.getFrom().getBlockX() == e.getTo().getBlockX()
        && e.getFrom().getBlockY() == e.getTo().getBlockY()
        && e.getFrom().getBlockZ() == e.getTo().getBlockZ()) return;

    Player player = e.getPlayer();
    if (player.getHealth() <= 0.0D) return;
    Location loc = e.getTo().getBlock().getLocation();
    Location loc2 = getLocation();
    if (loc.toVector().distance(loc2.toVector()) < 1) {
      setStatus(true);
      player.damage(main.damage);
    }
  }
	@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);
		}
	}
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerMove(PlayerMoveEvent event) {
   BlockPlatform platform = windwalkers.get(event.getPlayer().getName());
   if (platform != null) {
     Player player = event.getPlayer();
     if (isExpired(player)) {
       turnOff(player);
     } else {
       if (falling.contains(player)) {
         if (event.getTo().getY() < event.getFrom().getY()) {
           falling.remove(player);
         } else {
           return;
         }
       }
       if (!player.isSneaking()) {
         Block block = event.getTo().subtract(0, 1, 0).getBlock();
         boolean moved = platform.isMoved(block, false);
         if (moved) {
           platform.movePlatform(block, true);
           addUse(player);
           chargeUseCost(player);
         }
       }
     }
   }
 }
  /** 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());
    }
  }
  @Override
  public void onPlayerMove(PlayerMoveEvent event) {
    // We only check if a player has entered a shop if he has changed a full block.
    if (event.getTo().getBlockX() == event.getFrom().getBlockX()
        && event.getTo().getBlockY() == event.getFrom().getBlockY()
        && event.getTo().getBlockZ() == event.getFrom().getBlockZ()) {
      return;
    }

    plugin.checkPlayerPosition(event.getPlayer());
  }
 @EventHandler
 public void onPlayerMove(PlayerMoveEvent e) {
   if (plugin.worldEnabledFallout(e.getPlayer().getWorld().getName())) {
     if (e.getTo().getWorld().getBlockAt(e.getTo()).getType() == Material.WATER
         || e.getTo().getWorld().getBlockAt(e.getTo()).getType() == Material.STATIONARY_WATER) {
       if (plugin.getConfig().getDouble("maxRadiationWashable")
           >= plugin.getRadiationManager().getPlayerRadiation(e.getPlayer()))
         plugin.getRadiationManager().setPlayerRadiation(e.getPlayer(), 0.0);
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerMove(PlayerMoveEvent event) {
    final Player player = event.getPlayer();

    if (player == null || event.isCancelled()) return;

    if (Config.FLYING && event.getFrom().getWorld() == plugin.getIslandWorld()) {
      if (event.getFrom().getBlockX() != event.getTo().getBlockX()
          || event.getFrom().getBlockY() != event.getTo().getBlockY()
          || event.getFrom().getBlockZ() != event.getTo().getBlockZ())
        checkCoords(event, player, false);
    }
  }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerMove(PlayerMoveEvent event) {
   if (region.contains(event.getTo().toVector()) && !region.contains(event.getFrom().toVector())) {
     if ((filter == null || filter.evaluate(event.getPlayer()).equals(FilterState.ALLOW))
         || (TeamUtils.getTeamByPlayer(event.getPlayer()) != null
             && TeamUtils.getTeamByPlayer(event.getPlayer()).isObserver())
         || !GameHandler.getGameHandler().getMatch().isRunning()) {
       if (destination != null) {
         event.getPlayer().teleport(destination.getRandomPoint().getLocation());
         if (sound)
           event
               .getPlayer()
               .playSound(event.getPlayer().getLocation(), Sound.ENDERMAN_TELEPORT, 0.2F, 1);
       } else {
         Location newLocation = event.getTo();
         if (xRelative) newLocation.setX(newLocation.getX() + location.getX());
         else newLocation.setX(location.getX());
         if (yRelative) newLocation.setY(newLocation.getY() + location.getY());
         else newLocation.setY(location.getY());
         if (zRelative) newLocation.setZ(newLocation.getZ() + location.getZ());
         else newLocation.setZ(location.getZ());
         if (yawRelative) newLocation.setYaw(newLocation.getYaw() + yaw);
         else newLocation.setYaw(yaw);
         if (pitchRelative) newLocation.setPitch(newLocation.getPitch() + pitch);
         else newLocation.setPitch(pitch);
         event.getPlayer().teleport(newLocation);
         if (sound)
           event
               .getPlayer()
               .playSound(event.getPlayer().getLocation(), Sound.ENDERMAN_TELEPORT, 0.2F, 1);
       }
     }
   }
   if (destination != null
       && destination.contains(event.getTo().toVector())
       && !destination.contains(event.getFrom().toVector())
       && this.bidirectional) {
     if (filter == null
         || filter.evaluate(event.getPlayer()).equals(FilterState.ALLOW)
         || (TeamUtils.getTeamByPlayer(event.getPlayer()) != null
             && TeamUtils.getTeamByPlayer(event.getPlayer()).isObserver())
         || !GameHandler.getGameHandler().getMatch().isRunning()) {
       event.getPlayer().teleport(region.getRandomPoint().getLocation());
       if (sound)
         event
             .getPlayer()
             .playSound(event.getPlayer().getLocation(), Sound.ENDERMAN_TELEPORT, 0.2F, 1);
     }
   }
 }
 @EventHandler
 public void onPlayerMoveEvent(PlayerMoveEvent event) {
   if (Territory.getTerritoryAt(event.getTo()) == Territory.getTerritoryAt(event.getFrom()))
     return;
   if (Territory.getTerritoryAt(event.getTo()) == Territory.BADLANDS) {
     event.getPlayer().sendMessage(ChatColor.RED + "You are entering the Badlands");
     return;
   }
   if (Territory.getTerritoryAt(event.getTo()) == Territory.SAFE) {
     event.getPlayer().sendMessage(ChatColor.GREEN + "You are entering the Safe Zone");
     return;
   }
   // TODO CHECK FOR KINGDOMS AND FAVOR
 }
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onPlayerMove(PlayerMoveEvent event) {
    ZoneManager manager = m_plugin.getZoneManager();
    Zone fromZone = manager.getZone(event.getFrom());
    Zone toZone = manager.getZone(event.getTo());
    if (toZone != null) {
      if (!toZone.canPlayerMove(event.getPlayer())) {
        Vector direction =
            event.getFrom().toVector().subtract(event.getTo().toVector()).normalize();
        event.getPlayer().setVelocity(direction.multiply(2));
        sendMessageNoSpam(event.getPlayer(), UI.getMessage("NoMove"));
        return;
      }
    }

    if (event.getTo().equals(event.getFrom())) {
      return;
    }

    if ((fromZone == null && toZone != null)
        || (fromZone != null && toZone != null && !fromZone.getName().equals(toZone.getName()))) {
      event.getPlayer().sendMessage(toZone.getEnterMessage());
    } else if ((toZone == null && fromZone != null)
        || (fromZone != null && toZone != null && !toZone.getName().equals(fromZone.getName()))) {
      event.getPlayer().sendMessage(fromZone.getExitMessage());
    }

    if (toZone != null && fromZone != null) {
      if (toZone.getName() == fromZone.getName()) {
        Plot toPlot = toZone.getPlot(event.getTo());
        Plot fromPlot = fromZone.getPlot(event.getFrom());

        if ((fromPlot == null && toPlot != null)
            || (fromPlot != null
                && toPlot != null
                && !fromPlot.getName().equals(toPlot.getName()))) {
          sendZonePrefix(
              event.getPlayer(), toZone, "\u00A7bNow entering plot \u00A7c" + toPlot.getName());
        } else if ((toPlot == null && fromPlot != null)
            || (fromPlot != null
                && toPlot != null
                && !toPlot.getName().equals(fromPlot.getName()))) {
          sendZonePrefix(
              event.getPlayer(), toZone, "\u00A7bNow leaving plot \u00A7c" + fromPlot.getName());
        }
      }
    }
  }
  @EventHandler
  public void onEntityMove(PlayerMoveEvent e) {
    if (e.getTo().getBlockX() == e.getFrom().getBlockX()
        && e.getTo().getBlockY() == e.getFrom().getBlockY()
        && e.getTo().getBlockZ() == e.getFrom().getBlockZ()) {
      return;
    }

    Player p = (Player) e.getPlayer();
    if (p.getLocation().getBlock().getType() == Material.SNOW
        || p.getLocation().getBlock().getType() == Material.SNOW_BLOCK) {
      new UtilParticle(ParticleType.SNOW_SHOVEL, 0.1F, 3, 0.4F).sendToLocation(p.getLocation());
      new UtilParticle(ParticleType.SNOWBALL, 0.1F, 3, 0.4F).sendToLocation(p.getLocation());
      new UtilParticle(ParticleType.CLOUD, 0.1F, 3, 0.4F).sendToLocation(p.getLocation());
    }
  }
 @EventHandler
 public static void onPlayerMove(PlayerMoveEvent e) {
   Player player = e.getPlayer();
   Location locTo = e.getTo();
   Location locFrom = e.getFrom();
   if (PBMethods.WGSupportEnabled) {
     if (PBMethods.getWorldGuard() != null) {
       ApplicableRegionSet set =
           WGBukkit.getRegionManager(locTo.getWorld()).getApplicableRegions(locTo);
       for (ProtectedRegion region : set) {
         if (region != null) {
           // Checks if the player can enter the field during a Probending Match
           if (region.getId().equalsIgnoreCase(PBMethods.ProbendingField)) {
             if (PBMethods.matchStarted) {
               String teamName = PBMethods.getPlayerTeam(player.getUniqueId());
               if (teamName != null) {
                 if (!PBMethods.playingTeams.contains(teamName.toLowerCase())) {
                   player.sendMessage(Strings.Prefix + Strings.CantEnterField);
                   player.teleport(locFrom);
                   e.setCancelled(true);
                 }
               }
               if (teamName == null) {
                 player.sendMessage(Strings.Prefix + Strings.CantEnterField);
                 player.teleport(locFrom);
                 e.setCancelled(true);
               }
             }
           }
         }
       }
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGH)
  public void enterSnitchProximity(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();

    if (from.getBlockX() == to.getBlockX()
        && from.getBlockY() == to.getBlockY()
        && from.getBlockZ() == to.getBlockZ()
        && from.getWorld().equals(to.getWorld())) {
      // Player didn't move by at least one block.
      return;
    }
    Player player = event.getPlayer();
    if (vanishNoPacket.isPlayerInvisible(player)) {
      return;
    }
    String playerName = player.getName();
    Location location = player.getLocation();
    World world = location.getWorld();
    Set<Snitch> inList = playersInSnitches.get(playerName);
    if (inList == null) {
      inList = new TreeSet<Snitch>();
      playersInSnitches.put(player.getName(), inList);
    }
    Set<Snitch> snitches = snitchManager.findSnitches(world, location);
    for (Snitch snitch : snitches) {
      if (!isOnSnitch(snitch, playerName) && doesSnitchExist(snitch, true) || isDebugging()) {
        if (!inList.contains(snitch)) {
          inList.add(snitch);
          for (Player remoteplayer : playerManager.getPlayers()) {
            String remoteName = remoteplayer.getName();
            if (isOnSnitch(snitch, remoteName)) {
              remoteplayer.sendMessage(
                  ChatColor.AQUA
                      + " * "
                      + playerName
                      + " entered snitch at "
                      + snitch.getName()
                      + " ["
                      + snitch.getX()
                      + " "
                      + snitch.getY()
                      + " "
                      + snitch.getZ()
                      + "]");
            }
          }
          plugin.getJaLogger().logSnitchEntry(snitch, location, player);
        }
      }
    }
    Set<Snitch> rmList = new TreeSet<Snitch>();
    for (Snitch snitch : inList) {
      if (snitches.contains(snitch)) {
        continue;
      }
      rmList.add(snitch);
    }
    inList.removeAll(rmList);
  }
  @Override
  public void handle(Session session, SpoutPlayer player, PositionMessage message) {
    if (player == null) {
      return;
    }

    PlayerMoveEvent event =
        EventFactory.onPlayerMove(
            player,
            player.getLocation(),
            new Location(
                player.getWorld(),
                message.getX(),
                message.getY(),
                message.getZ(),
                player.getLocation().getYaw(),
                player.getLocation().getPitch()));

    if (event.isCancelled()) {
      return;
    }

    Location l = event.getTo();
    l.setYaw(player.getLocation().getYaw());
    l.setPitch(player.getLocation().getPitch());

    player.setRawLocation(l);
  }
 @EventHandler(ignoreCancelled = true)
 public void onPlayerWalksOver(PlayerMoveEvent event) {
   if (event.getFrom().getBlock().equals(event.getTo().getBlock())) {
     return;
   }
   if (dEntity.isNPC(event.getPlayer())) {
     return;
   }
   notable = NotableManager.getSavedId(new dLocation(event.getTo().getBlock().getLocation()));
   if (notable == null) {
     return;
   }
   cancelled = event.isCancelled();
   this.event = event;
   fire();
   event.setCancelled(cancelled);
 }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPlayerMove(final PlayerMoveEvent e) {
   if (e.isCancelled()) {
     return;
   }
   final Player p = e.getPlayer();
   Netstats.players().get(p.getName()).add("distance", e.getTo().distance(e.getFrom()));
 }
Exemple #18
0
 @EventHandler(priority = EventPriority.HIGH)
 public void onMove(PlayerMoveEvent e) {
   if (e.isCancelled()) return;
   Player p = e.getPlayer();
   IProfile ap = ICheat.getInstance().getCache().getProfile(p);
   double distance = e.getTo().distance(e.getFrom());
   ap.getProfileData().setBlocksPerSecond(ap.getProfileData().getBlocksPerSecond() + distance);
 }
 @EventHandler(priority = EventPriority.NORMAL)
 public void playerWalk(PlayerMoveEvent event) {
   // Player Moved
   int walkingBoots = config.getInt("walking_boots", 3);
   Player player = event.getPlayer();
   Location fromLoc = event.getFrom();
   Location toLoc = event.getTo();
   int fromX = (int) fromLoc.getX();
   int fromZ = (int) fromLoc.getZ();
   int toX = (int) toLoc.getX();
   int toZ = (int) toLoc.getZ();
   if ((fromX != toX || fromZ != toZ)
       && player.hasPermission("walkthewalk.use")
       && !player.isInsideVehicle()) {
     // Player moved to a new block, and has permission
     boolean rightBoots = false;
     if (walkingBoots != 0) {
       int invBoots = 0;
       if (player.getInventory().getBoots() != null) {
         invBoots = player.getInventory().getBoots().getTypeId();
       }
       if (invBoots == 301 && walkingBoots == 1) {
         // Leather Boots
         rightBoots = true;
       } else if (invBoots == 309 && walkingBoots == 2) {
         // Iron Boots
         rightBoots = true;
       } else if (invBoots == 317 && walkingBoots == 3) {
         // Gold Boots
         rightBoots = true;
       } else if (invBoots == 313 && walkingBoots == 4) {
         // Diamond Boots
         rightBoots = true;
       } else if (invBoots == 305 && walkingBoots == 5) {
         // Chain Boots
         rightBoots = true;
       }
     } else {
       rightBoots = true;
     }
     if (rightBoots) {
       // Player was wearing the right boots
       int xpBoost = config.getInt("xp_boost", 1);
       int boostBlocks = config.getInt("boost_blocks", 10);
       double rounding = 0.00;
       if (xpRounding.get(player.getName()) != null) {
         rounding = xpRounding.get(player.getName());
       }
       rounding += (double) xpBoost / boostBlocks;
       if (rounding >= xpBoost) {
         rounding -= xpBoost;
         player.giveExp(xpBoost);
       }
       xpRounding.put(player.getName(), rounding);
     }
   }
 }
  @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()));
  }
Exemple #21
0
 @EventHandler
 public void onPlayerMove(PlayerMoveEvent e) {
   if (Deprimo.players.contains(e.getPlayer().getName())) {
     e.getPlayer().setSneaking(true);
     if (e.getFrom().getY() < e.getTo().getY()) {
       e.getPlayer().getLocation().setY(e.getFrom().getY());
     }
   }
 }
Exemple #22
0
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Location loc =
        new Location(
            e.getTo().getWorld(),
            (int) e.getTo().getX(),
            (int) e.getTo().getY(),
            (int) e.getTo().getZ());
    if (Main.getInstance().redSpawnArea.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.RED_SPAWN, p));
    }
    if (Main.getInstance().blueSpawnArea.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.BLUE_SPAWN, p));
    }
    if (Main.getInstance().blockspawnAreas.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(getArea(loc), p));
    }
    if (blockManager.canPickUpBlock(p)) {
      blockManager.pickUpBlock(p);
    }
    if (canGetNeededBlock(p)) {
      if (p.getGameMode() == GameMode.SURVIVAL) {
        gameManager.setCarrying(p, nexusManager.getCurrentNexusColor());
        String[] data = neededBlockMaterial.split(";");
        neededBlock
            .getBlock()
            .setTypeIdAndData(Integer.valueOf(data[0]), Byte.valueOf(data[1]), false);
        neededBlock = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);

        Bukkit.broadcastMessage(
            Color.np(
                "&6The needed block was picked up by the "
                    + teamManager.getTeam(p).getTeamName()
                    + "&6 team!"));
      }
    }
    if ((int) e.getFrom().getX() != (int) e.getTo().getX()
        || (int) e.getFrom().getZ() != (int) e.getTo().getZ()
        || (int) e.getFrom().getY() != (int) e.getTo().getY()) {
      if (getTurret(loc) != null) {
        Bukkit.getPluginManager().callEvent(new TurretWalkEvent(p, getTurret(loc)));
      }
      if (isInTurret(p)) {
        Turret t = getTurret(p);
        if (t.containsUser()) {
          e.getPlayer().teleport(e.getFrom());
        }
      }
    }
    if ((int) e.getFrom().getX() != (int) e.getTo().getX()
        || (int) e.getFrom().getZ() != (int) e.getTo().getZ()) {
      if (!released || stunned.contains(p.getName())) {
        if (GameState.getState() == GameState.INGAME) {
          e.getPlayer().teleport(e.getFrom());
        }
      }
    }
  }
 @Override
 public void onPlayerMove(PlayerMoveEvent event) {
   if (global.isProtected(event.getTo())
       && !LapisProtect.permissionHandler.has(event.getPlayer(), "lapisprotect.enter")) {
     if (!global.isProtected(event.getFrom())) {
       event.getPlayer().sendRawMessage(global.chatPrefix + "This area is protected.");
       event.setCancelled(true);
     }
   }
 }
 @ArenaEventHandler(priority = EventPriority.HIGH)
 public void onPlayerMove(PlayerMoveEvent event) {
   if (!event.isCancelled()
       && arena.hasRegion()
       && tops.hasInArenaOrOptionAt(state, TransitionOption.WGNOLEAVE)
       && WorldGuardController.hasWorldGuard()) {
     /// Did we actually even move
     if (event.getFrom().getBlockX() != event.getTo().getBlockX()
         || event.getFrom().getBlockY() != event.getTo().getBlockY()
         || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
       /// Now check world
       World w = arena.getWorldGuardRegion().getWorld();
       if (w == null || w.getUID() != event.getTo().getWorld().getUID()) return;
       if (WorldGuardController.isLeavingArea(
           event.getFrom(), event.getTo(), arena.getWorldGuardRegion())) {
         event.setCancelled(true);
       }
     }
   }
 }
Exemple #25
0
 @EventHandler
 public void onMove(PlayerMoveEvent event) {
   if (ConfigUtil.get().getConfig().getBoolean("tp-to-spawn")) {
     if (event.getTo().getY() <= 0) {
       Location teleportTo =
           LocationUtil.get()
               .deserialize(ConfigUtil.get().getConfig().getString("spawn.location"));
       event.getPlayer().teleport(teleportTo);
     }
   }
 }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerJump(PlayerMoveEvent event) {
   Location from = event.getFrom();
   Location to = event.getTo();
   if (to.getBlockY() > from.getBlockY()) {
     Player player = event.getPlayer();
     if (FOPM_TFM_Util.isDoubleJumper(player)) {
       player.setAllowFlight(true);
     }
   }
 }
Exemple #27
0
  /**
   * 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);
      }
    }
  }
 @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());
   }
 }
Exemple #29
0
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void PlayerMoveEvent(PlayerMoveEvent e) {

    Location from = e.getFrom();
    Location to = e.getTo();

    if (from.getBlockX() != to.getBlockX()
        || from.getBlockY() != to.getBlockY()
        || from.getBlockZ() != to.getBlockZ()) {

      CEventHandler.handleEvent(e.getPlayer(), e, move);
      CEventHandler.handleMines(e.getPlayer(), e);
    }
  }
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    if (Concussion.getTarget(player) != null) {
      event.setCancelled(true);
      return;
    }
    if (WaterSpout.isBending(event.getPlayer())
        || AirSpout.getPlayers().contains(event.getPlayer())) {
      Vector vel = new Vector();
      vel.setX(event.getTo().getX() - event.getFrom().getX());
      vel.setY(event.getTo().getY() - event.getFrom().getY());
      vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
      // You now know the old velocity. Set to match recommended velocity
      double currspeed = vel.length();
      double maxspeed = .15;
      if (currspeed > maxspeed) {
        vel = vel.normalize().multiply(maxspeed * 0.9);
        event.getPlayer().setVelocity(vel);
      }
    }
    if (Bloodbending.isBloodbended(player)) {
      double distance1, distance2;
      Location loc = Bloodbending.getBloodbendingLocation(player);
      distance1 = event.getFrom().distance(loc);
      distance2 = event.getTo().distance(loc);
      if (distance2 > distance1) {
        player.setVelocity(new Vector(0, 0, 0));
      }
    }

    if (Dash.isDashing(player)) {
      Vector dir = event.getTo().clone().subtract(event.getFrom()).toVector();
      Dash d = Dash.getDash(player);
      d.setDirection(dir);
    }
  }