Exemplo n.º 1
0
 static {
   try {
     auth = AuthFactory.create(Config.AUTH_CLASS);
     System.out.println("Authentication Scheme: " + auth.getClass().getSimpleName());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 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;
  }