Exemplo n.º 1
0
 private void convertFiles() {
   /** create database */
   try {
     recMan = RecordManagerFactory.createRecordManager(name2UUID.getAbsolutePath());
     String recordName = "nameToUUID";
     treeMap = recMan.hashMap(recordName);
     // Load all the files from the player folder
     FilenameFilter ymlFilter =
         new FilenameFilter() {
           public boolean accept(File dir, String name) {
             String lowercaseName = name.toLowerCase();
             if (lowercaseName.endsWith(".yml")) {
               return true;
             } else {
               return false;
             }
           }
         };
     int count = 0;
     for (final File file : plugin.getPlayersFolder().listFiles(ymlFilter)) {
       if (count % 1000 == 0) {
         System.out.println("[ASkyBlock]: Processed " + count + " names to database");
       }
       count++;
       try {
         // Get UUID
         String uuid = file.getName().substring(0, file.getName().length() - 4);
         // System.out.println("DEBUG: UUID is " + uuid);
         final UUID playerUUID = UUID.fromString(uuid);
         // Get the player's name
         Scanner scanner = new Scanner(file);
         while (scanner.hasNextLine()) {
           final String lineFromFile = scanner.nextLine();
           if (lineFromFile.contains("playerName:")) {
             // Check against potentialUnowned list
             String playerName = lineFromFile.substring(lineFromFile.indexOf(' ')).trim();
             // System.out.println("DEBUG: Player name is " + playerName);
             treeMap.put(playerName.toLowerCase(), playerUUID);
             break;
           }
         }
         scanner.close();
       } catch (Exception ex) {
         System.err.println(
             "[ASkyBlock/AcidIsland]: Problem reading " + file.getName() + " skipping...");
         // ex.printStackTrace();
       }
     }
     /** Map changes are not persisted yet, commit them (save to disk) */
     recMan.commit();
     System.out.println("[ASkyBlock]: Complete. Processed " + count + " names to database");
     // Set flag
     dbReady = true;
   } catch (Exception e) {
     System.err.println("[ASkyBlock/AcidIsland] : Problem creating database");
   }
 }
Exemplo n.º 2
0
 /**
  * Gets the UUID for this player name or null if not known. Case insensitive!
  *
  * @param playerName
  */
 public UUID getPlayerUUID(String playerName) {
   return treeMap.get(playerName.toLowerCase());
 }
Exemplo n.º 3
0
 /**
  * Saves the player name to the database. Case insensitive!
  *
  * @param playerName
  * @param playerUUID
  */
 public void savePlayerName(String playerName, UUID playerUUID) {
   treeMap.put(playerName.toLowerCase(), playerUUID);
 }