Esempio n. 1
0
 @Override
 public IOClient create(Socket client, PacketManager pm) {
   SMPPlayer object = new SMPPlayer(client, pm);
   Packet packet = pm.getPacket("Hankshake");
   if (packet == null) return null;
   else {
     ((DynamicPacket) packet).handle(pm.server, object, object.getInputStream());
     object.kick("This is not an SMP Server!");
     return null;
   }
 }
  @Override
  public void write(SMPPlayer player, Server server, Object... obj) {
    if (obj.length >= 6) {
      ByteBuffer bb;

      if (obj[0] instanceof Integer
          && obj[1] instanceof Byte
          && obj[2] instanceof Byte
          && obj[3] instanceof Byte
          && obj[4] instanceof Byte
          && obj[5] instanceof Byte) {
        bb = ByteBuffer.allocate(10);

        bb.put(ID);
        bb.putInt((Integer) obj[0]);
        bb.put((Byte) obj[1]);
        bb.put((Byte) obj[2]);
        bb.put((Byte) obj[3]);
        bb.put((Byte) obj[4]);
        bb.put((Byte) obj[5]);

        try {
          player.writeData(bb.array());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
Esempio n. 3
0
  @Override
  public void write(SMPPlayer player, Server server, Object... obj) {
    if (obj.length >= 4) {
      ByteBuffer bb;

      if (obj[0] instanceof String
          && obj[1] instanceof Byte
          && obj[2] instanceof String
          && obj[4] instanceof Integer) {
        bb = ByteBuffer.allocate(9 + stringLength(obj[0]) + stringLength(obj[2]));

        bb.put(ID);
        putMinecraftString((String) obj[0], bb);
        bb.put((Byte) obj[1]);
        putMinecraftString((String) obj[2], bb);
        bb.putInt((Integer) obj[3]);

        try {
          player.writeData(bb.array());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
Esempio n. 4
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();
    }
  }