Exemple #1
0
  public void playerSectionRead() {
    boolean isSection = (plugin.getConfig().isConfigurationSection("players"));

    if (isSection) {
      Map<String, Object> playerList =
          plugin.getConfig().getConfigurationSection("players").getValues(false);

      if (playerList != null) {
        //				System.out.println("PlayerClassRank List");
        for (String playerName : playerList.keySet()) {
          PlayerClazz playerClazz = new PlayerClazz(playerName, "");

          Map<String, Object> playerClassRank =
              plugin.getConfig().getConfigurationSection("players." + playerName).getValues(false);
          for (String clazzName : playerClassRank.keySet()) {
            String rankName =
                plugin.getConfig().getString("players." + playerName + "." + clazzName, "");
            playerClazz.addPlayerClassRank(clazzName, rankName);
          }
          playersClazzList.put(playerName, playerClazz);
        }
        // Test output
        for (PlayerClazz playerClazz : playersClazzList.values()) {
          for (String clazzName : playerClazz.playerClazzRanks().keySet()) {
            String rankName = playerClazz.playerClazzRanks().get(clazzName);
            //						System.out.println(playerClazz.getUuid() + ":" + clazzName+ ":" + rankName);
          }
        }
      }
    }
  }
Exemple #2
0
 /**
  * set PlayerSection to ConfigSection
  *
  * @param player
  * @param className
  * @param rank
  */
 public void playerSectionWrite(PlayerClazz playerClazz) {
   for (String clazzName : playerClazz.playerClazzRanks().keySet()) {
     String rank = playerClazz.playerClazzRanks().get(clazzName);
     plugin.getConfig().set("players." + playerClazz.getUuid() + "." + clazzName, rank);
     plugin.db.i(
         "Write to config rank "
             + rank
             + " to player "
             + playerClazz.getUuid()
             + ", no world support");
   }
   plugin.saveConfig();
 }
Exemple #3
0
 /**
  * Remove ClazzRank from player set PlayerSection to ConfigSection save config to File
  *
  * @param player
  * @param className
  */
 public void playerSectionRemove(Player player, String className) {
   if (className != null) {
     plugin.db.i("Remove config " + player.getUniqueId().toString() + " : " + className);
     PlayerClazz playerClazz = playersClazzList.get(player.getUniqueId().toString());
     if (playerClazz != null) {
       if (playerClazz.playerClazzRanks().containsKey(className)) {
         playerClazz.playerClazzRanks().remove(className);
         plugin.db.i("Save player section after remove ");
         playerSectionWrite(playerClazz);
         plugin.saveConfig();
       }
     }
   }
 }