@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. 2
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();
        }
      }
    }
  }