public void reloadLocalizedStrings() {
    File localizedStringsFile =
        new File(plugin.getDataFolder().getPath() + "/localization/" + languageFile);
    if (this.isDefault()) {
      if (defaultLocalizedStrings == null) {
        localizedStrings = defaultLocalizedStrings;
      }
      return;
    } else if (!localizedStringsFile.exists()) {

      CivLog.warning(
          "Configuration file:"
              + languageFile
              + " was missing. You must create this file in plugins/Civcraft/localization/");
      CivLog.warning("Using default_lang.yml");
      this.setLanguageFile("");
      return;
    }
    localizedStrings = YamlConfiguration.loadConfiguration(localizedStringsFile);

    CivLog.info("Loading Configuration file:" + languageFile);
    // read the config.yml into memory
    YamlConfiguration cfg = new YamlConfiguration();
    try {
      cfg.load(localizedStringsFile);
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (InvalidConfigurationException e1) {
      e1.printStackTrace();
    }
    localizedStrings.setDefaults(cfg);
  }
  public void reloadDefaultLocalizedStrings() {
    String defaultLanguageFile = "default_lang.yml";
    File defaultLocalizedStringsFile =
        new File(plugin.getDataFolder().getPath() + "/localization/" + defaultLanguageFile);
    CivLog.warning(
        "Configuration file:" + defaultLanguageFile + " in use. Updating to disk from Jar.");
    try {
      CivSettings.streamResourceToDisk("/localization/" + defaultLanguageFile);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    defaultLocalizedStrings = YamlConfiguration.loadConfiguration(defaultLocalizedStringsFile);

    CivLog.info("Loading Configuration file:" + defaultLanguageFile);
    // read the config.yml into memory
    YamlConfiguration cfg = new YamlConfiguration();
    try {
      cfg.load(defaultLocalizedStringsFile);
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (InvalidConfigurationException e1) {
      e1.printStackTrace();
    }
    defaultLocalizedStrings.setDefaults(cfg);
  }
Esempio n. 3
0
  public void setupLore(String id) {
    ConfigMission mission = CivSettings.missions.get(this.getId());

    if (mission == null) {
      CivLog.warning("Couldn't find mission with id:" + id + " to set the lore.");
      return;
    }

    for (String str : mission.description) {
      this.addLore(str);
    }
    this.addLore(CivColor.Yellow + mission.cost + " Coins.");
    this.addLore(CivColor.Gold + "Soulbound");
  }