Beispiel #1
0
  @Opcode(opcode = 2)
  public void decodeWorldStatus(LSIncomingPacket in) {
    int state = in.readByte() & 0xFF;
    int world = in.readByte() & 0xFF;
    RemoteWorld w = api.worlds.get(world);

    if (state == 0) {
      // World is being removed
      assert w != null : "World is null, but removing it?";
      assert w.players.size() == 0 : "Players are still on world, but world is being destroyed";
      api.worlds.remove(world);
    } else if (state == 1) {
      // assert w == null : "Adding a world, but it is not null";

      w = new RemoteWorld();
      // World is being added
      w.worldId = world;
      w.ip = in.readPJStr1();
      w.name = in.readPJStr1();
      w.activity = in.readPJStr1();
      w.country = in.readByte() & 0xFF;
      w.flags = in.readByte() & 0xFF;
      api.worlds.put(world, w);
    } else {
      throw new IllegalArgumentException("Bad state, given " + state);
    }
  }
Beispiel #2
0
  // TODO - Document this
  @Opcode(opcode = 1)
  public void decodeClientStatus(LSIncomingPacket in) {
    int state = in.readByte() & 0xFF;
    int world = in.readByte() & 0xFF;
    String name = in.readPJStr1();

    RemoteWorld w = api.worlds.get(world);
    assert w != null : "World not found " + world;

    if (state == 0) {
      // Player is logging off
      w.players.remove(name);
      // TODO: Throw event
    } else if (state == 1) {
      // Player is logging on
      w.players.add(name);
      // TODO: Throw event
    } else {
      throw new IllegalArgumentException("Bad state, given " + state);
    }
  }