Advertisement
riking

FTFY

Jun 28th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1.     /** Gets or creates section if it doesn't exist.
  2.      * @return */
  3.     public static ConfigurationSection getRaffleSection() {
  4.  
  5.         rafflesConfig.saveDefaultConfig();
  6.         FileConfiguration config = rafflesConfig.getConfig();
  7.         return getOrCreateSection(config, "raffles");
  8.     }
  9.  
  10.     public static ConfigurationSection getOrCreateSection(ConfigurationSection parent, String name) {
  11.         ConfigurationSection ret = parent.getConfigurationSection(name);
  12.         return (ret != null) ? ret : parent.createSection(name);
  13.     }
  14.  
  15.     /** Saves the current raffle. */
  16.     public static void saveRaffle() {
  17.  
  18.         if (currentRaffle == null) {
  19.             ChatUtil.logSevere(Messages.RAFFLE_FAILED_TO_SAVE);
  20.             return;
  21.         }
  22.         ChatUtil.logInfo(getRaffleSection().getCurrentPath());
  23.         ConfigurationSection cs = getOrCreateSection(getRaffleSection(), currentRaffle.getId() + "");
  24.         cs.set("end-time", currentRaffle.getEndTime());
  25.         cs = getOrCreateSection(cs, "players");
  26.         for (String player : currentRaffle.getPlayers().keySet()) {
  27.             cs.set(player, currentRaffle.getPlayers().get(player));
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement