コード例 #1
0
  public void handlePacket(Packet p, IoSession session) throws Exception {
    final long uID = ((LSPacket) p).getUID();
    World world = (World) session.getAttachment();
    long user = p.readLong();
    String ip = DataConversions.IPToString(p.readLong());
    byte[] pass = p.readBytes(p.readInt());
    String UID = p.readString();
    byte loginCode = validatePlayer(user, pass, ip, UID);

    builder.setUID(uID);
    if (loginCode == 0 || loginCode == 1 || loginCode == 99) {
      try {
        badClients.add(DataConversions.hashToUsername(user));
        System.out.println("UID: " + UID + " Player: " + DataConversions.hashToUsername(user));
      } catch (Exception e) {
        System.out.println("Exception in UID printer :" + e.getMessage());
      }

      builder.setPlayer(Server.getServer().findSave(user, world), loginCode);
      world.registerPlayer(user, ip, UID);
    } else {
      builder.setPlayer(null, loginCode);
    }

    LSPacket packet = builder.getPacket();
    if (packet != null) {
      session.write(packet);
    }
  }
コード例 #2
0
  private byte validatePlayer(long user, byte[] pass, String ip, String UID) {
    Server server = Server.getServer();
    byte returnVal = 0;

    if (UIDTracker.isActive(UID)) {
      return 8;
    }

    if (!Server.storage.playerExists(user)) {
      if (Config.AUTO_REGISTER) {
        PlayerSave p =
            Server.storage.registerPlayer(user, pass, DataConversions.hashToUsername(user));
        Server.storage.savePlayer(p);
      } else {
        return 10;
      }
    }

    if (!auth.validate(user, pass, new StringBuilder())) {
      return 2;
    }

    if (Server.storage.isBanned(user)) {
      System.out.println(
          "Banned player: " + DataConversions.hashToUsername(user) + " trying to login.");
      return 6;
    }

    if (Server.storage.getGroupID(user) >= 5) {
      returnVal = 99;
    }

    long owner = Server.storage.getOwner(user);
    for (World w : server.getWorlds()) {
      for (Entry<Long, Long> player : w.getPlayers()) {
        if (player.getKey() == user) {
          return 3;
        }
        if (player.getValue() == owner) {
          return 9;
        }
      }
      if (w.hasPlayer(user)) {
        return 3;
      }
    }
    return returnVal;
  }
コード例 #3
0
 public void handlePacket(Packet p, IoSession session) throws Exception {
   long user = p.readLong();
   World world = (World) session.getAttachment();
   world.unregisterPlayer(user);
 }