コード例 #1
0
  @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);
  }
コード例 #2
0
ファイル: BearTrap.java プロジェクト: TheCodingClub/furniture
  @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);
    }
  }
コード例 #3
0
 @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()));
 }
コード例 #4
0
ファイル: CheckSpeed.java プロジェクト: Shawckz/iCheat
 @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);
 }
コード例 #5
0
 @EventHandler(priority = EventPriority.HIGH)
 public void onPlayerMove(PlayerMoveEvent event) {
   if (event.isCancelled()) return;
   if (AFKUtils.isAfk(event.getPlayer())) {
     AFKUtils.unsetAfk(event.getPlayer());
     plugin.getServer().broadcastMessage(event.getPlayer().getName() + " is no longer AFK.");
     return;
   }
   if (PConfManager.getPValBoolean(event.getPlayer(), "frozen")) event.setCancelled(true);
 }
コード例 #6
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);
    }
  }
コード例 #7
0
 @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);
 }
コード例 #8
0
 @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);
       }
     }
   }
 }
コード例 #9
0
ファイル: NetServerHandler.java プロジェクト: tahg/CraftPail
  public void a(Packet10Flying packet10flying) {
    WorldServer worldserver = this.minecraftServer.a(this.player.dimension);

    this.i = true;
    double d0;

    if (!this.m) {
      d0 = packet10flying.y - this.y;
      if (packet10flying.x == this.x && d0 * d0 < 0.01D && packet10flying.z == this.z) {
        this.m = true;
      }
    }

    // CraftBukkit start
    Player player = getPlayer();
    Location from =
        new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch);
    Location to = player.getLocation();

    // Prevent 40 event-calls for less than b single pixel of movement >.>
    double delta =
        Math.pow(this.lastPosX - this.x, 2)
            + Math.pow(this.lastPosY - this.y, 2)
            + Math.pow(this.lastPosZ - this.z, 2);
    float deltaAngle =
        Math.abs(this.lastYaw - this.player.yaw) + Math.abs(this.lastPitch - this.player.pitch);

    if (delta > 1f / 256 || deltaAngle > 10f) {
      // Skip the first time we do this
      if (lastPosX != Double.MAX_VALUE) {
        PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
        server.getPluginManager().callEvent(event);

        from = event.getFrom();
        to = event.isCancelled() ? from : event.getTo();

        this.player.locX = to.getX();
        this.player.locY = to.getY();
        this.player.locZ = to.getZ();
        this.player.yaw = to.getYaw();
        this.player.pitch = to.getPitch();
      }

      this.lastPosX = this.player.locX;
      this.lastPosY = this.player.locY;
      this.lastPosZ = this.player.locZ;
      this.lastYaw = this.player.yaw;
      this.lastPitch = this.player.pitch;
    }

    if (Math.abs(packet10flying.x) > 32000000 || Math.abs(packet10flying.z) > 32000000) {
      player.teleport(player.getWorld().getSpawnLocation());
      System.err.println(
          player.getName() + " was caught trying to crash the server with an invalid position.");
      player.kickPlayer("Nope!");
      return;
    }

    if (Double.isNaN(packet10flying.x)
        || packet10flying.x == Double.POSITIVE_INFINITY
        || packet10flying.x == Double.NEGATIVE_INFINITY) {
      player.teleport(player.getWorld().getSpawnLocation());
      System.err.println(player.getName() + " was caught trying to set an invalid position.");
      player.kickPlayer("Nope!");
      return;
    }

    if (Double.isNaN(packet10flying.y)
        || packet10flying.y == Double.POSITIVE_INFINITY
        || packet10flying.y == Double.NEGATIVE_INFINITY) {
      player.teleport(player.getWorld().getSpawnLocation());
      System.err.println(player.getName() + " was caught trying to set an invalid position.");
      player.kickPlayer("Nope!");
      return;
    }

    if (Double.isNaN(packet10flying.z)
        || packet10flying.z == Double.POSITIVE_INFINITY
        || packet10flying.z == Double.NEGATIVE_INFINITY) {
      player.teleport(player.getWorld().getSpawnLocation());
      System.err.println(player.getName() + " was caught trying to set an invalid position.");
      player.kickPlayer("Nope!");
      return;
    }

    if (Double.isNaN(packet10flying.stance)
        || packet10flying.stance == Double.POSITIVE_INFINITY
        || packet10flying.stance == Double.NEGATIVE_INFINITY) {
      player.teleport(player.getWorld().getSpawnLocation());
      System.err.println(player.getName() + " was caught trying to set an invalid position.");
      player.kickPlayer("Nope!");
      return;
    }

    if (this.m && !this.player.dead) {
      // CraftBukkit end
      double d1;
      double d2;
      double d3;
      double d4;

      if (this.player.vehicle != null) {
        float f = this.player.yaw;
        float f1 = this.player.pitch;

        this.player.vehicle.f();
        d1 = this.player.locX;
        d2 = this.player.locY;
        d3 = this.player.locZ;
        double d5 = 0.0D;

        d4 = 0.0D;
        if (packet10flying.hasLook) {
          f = packet10flying.yaw;
          f1 = packet10flying.pitch;
        }

        if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
          d5 = packet10flying.x;
          d4 = packet10flying.z;
        }

        this.player.onGround = packet10flying.g;
        this.player = this.player.a(true); // CraftBukkit
        this.player.move(d5, 0.0D, d4);
        this.player.setLocation(d1, d2, d3, f, f1);
        this.player.motX = d5;
        this.player.motZ = d4;
        if (this.player.vehicle != null) {
          worldserver.vehicleEnteredWorld(this.player.vehicle, true);
        }

        if (this.player.vehicle != null) {
          this.player.vehicle.f();
        }

        this.minecraftServer.serverConfigurationManager.d(this.player);
        this.x = this.player.locX;
        this.y = this.player.locY;
        this.z = this.player.locZ;
        worldserver.playerJoinedWorld(this.player);
        return;
      }

      d0 = this.player.locY;
      this.x = this.player.locX;
      this.y = this.player.locY;
      this.z = this.player.locZ;
      d1 = this.player.locX;
      d2 = this.player.locY;
      d3 = this.player.locZ;
      float f2 = this.player.yaw;
      float f3 = this.player.pitch;

      if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
        packet10flying.h = false;
      }

      if (packet10flying.h) {
        d1 = packet10flying.x;
        d2 = packet10flying.y;
        d3 = packet10flying.z;
        d4 = packet10flying.stance - packet10flying.y;
        if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) {
          this.disconnect("Illegal stance");
          a.warning(this.player.name + " had an illegal stance: " + d4);
          return;
        }

        if (Math.abs(packet10flying.x) > 3.2E7D || Math.abs(packet10flying.z) > 3.2E7D) {
          this.disconnect("Illegal position");
          return;
        }
      }

      if (packet10flying.hasLook) {
        f2 = packet10flying.yaw;
        f3 = packet10flying.pitch;
      }

      this.player.a(true);
      this.player.br = 0.0F;
      this.player.setLocation(this.x, this.y, this.z, f2, f3);
      if (!this.m) {
        return;
      }

      d4 = d1 - this.player.locX;
      double d6 = d2 - this.player.locY;
      double d7 = d3 - this.player.locZ;
      double d8 = d4 * d4 + d6 * d6 + d7 * d7;

      // CraftBukkit start - make the movement speed check behave properly under tick degradation.
      int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
      // Added this.m condition to solve this check being triggered by teleports
      if (d8 > 100.0D * (elapsedTicks <= 0 ? 1 : elapsedTicks) && this.m) {
        a.warning(
            this.player.name
                + " moved too quickly! Elapsed ticks: "
                + (elapsedTicks == 0 ? 1 : elapsedTicks)
                + ", Distance change: "
                + d8);
        this.disconnect("You moved too quickly :( (Hacking?)");
        return;
      }
      this.lastTick = MinecraftServer.currentTick;
      // CraftBukkit end

      float f4 = 0.0625F;
      boolean flag =
          worldserver
                  .getEntities(
                      this.player,
                      this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4))
                  .size()
              == 0;

      this.player.move(d4, d6, d7);
      d4 = d1 - this.player.locX;
      d6 = d2 - this.player.locY;
      if (d6 > -0.5D || d6 < 0.5D) {
        d6 = 0.0D;
      }

      d7 = d3 - this.player.locZ;
      d8 = d4 * d4 + d6 * d6 + d7 * d7;
      boolean flag1 = false;

      if (d8 > 0.0625D && !this.player.isSleeping()) {
        flag1 = true;
        a.warning(this.player.name + " moved wrongly!");
        System.out.println("Got position " + d1 + ", " + d2 + ", " + d3);
        System.out.println(
            "Expected " + this.player.locX + ", " + this.player.locY + ", " + this.player.locZ);
      }

      this.player.setLocation(d1, d2, d3, f2, f3);
      boolean flag2 =
          worldserver
                  .getEntities(
                      this.player,
                      this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4))
                  .size()
              == 0;

      if (flag && (flag1 || !flag2) && !this.player.isSleeping()) {
        this.a(this.x, this.y, this.z, f2, f3);
        return;
      }

      AxisAlignedBB axisalignedbb =
          this.player
              .boundingBox
              .clone()
              .b((double) f4, (double) f4, (double) f4)
              .a(0.0D, -0.55D, 0.0D);

      if (!this.minecraftServer.o && !worldserver.b(axisalignedbb)) {
        if (d6 >= -0.03125D) {
          ++this.h;
          if (this.h > 80) {
            a.warning(this.player.name + " was kicked for floating too long!");
            this.disconnect("Flying is not enabled on this server");
            return;
          }
        }
      } else {
        this.h = 0;
      }

      this.player.onGround = packet10flying.g;
      this.minecraftServer.serverConfigurationManager.d(this.player);
      this.player.b(this.player.locY - d0, packet10flying.g);
    }
  }
コード例 #10
0
  /** On player move, detect they are inside a portal then teleport them appropriately. */
  @Override
  public void onPlayerMove(PlayerMoveEvent event) {
    if (event.isCancelled()) {
      return;
    }
    /** Grab the Player and our Players Session */
    final Player pl = event.getPlayer();
    final Location loc = pl.getLocation();

    MVPlayerSession ps = this.plugin.getPlayerSession(pl);
    if (ps == null
        || ps.getLocation().getBlockX() == loc.getBlockX()
            && ps.getLocation().getBlockY() == loc.getBlockY()
            && ps.getLocation().getBlockZ() == loc.getBlockZ()) {
      return;
    } else {
      ps.setLocation(loc); // Update the Players Session to the new Location.
    }

    /** Start the Price off at 0, this will change according to the Portal/World Settings. */
    Integer price = 0;
    /** Start of our Location as NULL, this allows us to check it later on. */
    Location d = null;
    /**
     * First we do a check against all the Portals we have created, if the area the user is within
     * is a Portal then we will act upon it; if not then we move onto our next check.
     */
    String ptest = utils.isPortal(pl.getLocation());
    if (ptest != null) {
      MVPortal p = this.plugin.MVPortals.get(ptest);
      price = (int) Math.round(p.getPrice());
      d = playerTeleporter.portalDestination(pl, ptest, p);
    }
    /** End of First Portal Check. */

    /**
     * If the first Portal Check failed then we will check for Any Signs around the player. This
     * check is only performed if the user is standing inside a Portal Block.
     */
    if (this.plugin.configMV.getBoolean("checksigns", true) && d == null) {
      d = playerTeleporter.portalSignMethod(pl);
    }
    /** End of Sign Based Portal Check. */

    /**
     * Standard Nether Portal Check, this will be for a Single Player like feel, customizeable...
     * Can be on or off.
     */
    if (this.plugin.configMV.getBoolean("splike", false) && d == null) {
      d = playerTeleporter.portalSPNether(pl);
    }
    /** End of Single Player Nether Check. */

    // TODO: Permissions to add here...
    /** If we have a Location set and it is NOT NULL then we can perform a teleport. */
    if (d != null) {
      if (!ps.getTeleportable()) {
        return;
      }
      if (!playerTeleporter.canTravelFromWorld(pl, d.getWorld())) {
        ps.sendMessage(
            "Sorry but you cannot travel to '" + d.getWorld().getName() + "' from this World!");
        return;
      }
      if (!playerTeleporter.canEnterWorld(pl, d.getWorld())) {
        ps.sendMessage("Sorry but you cannot enter the '" + d.getWorld().getName() + "' world.");
        return;
      }
      if (MultiVerse.useiConomy
          && !MultiVerse.Permissions.has(pl, "multiverse.portal.exempt")
          && price > 0) {
        Holdings balance = iConomy.getAccount(pl.getName()).getHoldings();
        if (balance.hasEnough(price)) {
          balance.subtract(price);
          pl.sendMessage(
              ChatColor.RED
                  + this.plugin.logPrefix
                  + " You have been charged "
                  + iConomy.format(price));
        } else {
          if (ps.getAlertable()) {
            pl.sendMessage("Sorry but you do not have the required funds for this portal");
            ps.setAlertCooldown();
          }
          return;
        }
      }
      final Location destination = d;
      plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              plugin,
              new Runnable() {
                @Override
                public void run() {
                  pl.teleport(destination);
                }
              });
      ps.setTPCooldown();
      return;
    }
    return;
  }
コード例 #11
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);
  }