예제 #1
0
  @Override
  public void handle(SMPPlayer p, Server server, DataInputStream reader) {
    try {
      p.setOldLocation(p.getLocation());
      double x = reader.readDouble();
      double y = reader.readDouble();
      double stance = reader.readDouble();
      double z = reader.readDouble();
      boolean onGround = reader.readBoolean();

      if ((stance - y) < 0.1d || (stance - y) > 1.65d) {
        p.kick("Illegal Stance");
      }

      if ((Math.abs(x) >= Math.abs(p.getLocation().getX()) + 100)
          || // TODO: possibly add customization for this number and an option for if it will be
             // checked at all
          (Math.abs(y) >= Math.abs(p.getLocation().getY()) + 100)
          || (Math.abs(z) >= Math.abs(p.getLocation().getZ()) + 100)) {
        p.kick("You moved too quickly");
      }

      if (Math.abs(x) > 3.2E7d || Math.abs(y) > 3.2E7d) {
        p.kick("Illegal Position");
      }
      p.getLocation().setX(x);
      p.getLocation().setY(y);
      p.getLocation().setZ(z);
      p.setStance(stance);
      p.setOnGround(onGround);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }