Example #1
0
  private void saveSignsFile() {
    if (!getConfig().getBoolean("signs-enabled", true)) {
      return;
    }

    saveQueued = false;
    try {
      signs.save(this.signsFile);
    } catch (IOException e) {
      getLogger().severe("PlayerVaults has encountered an error trying to save the signs file.");
      getLogger().severe("Please report this error to drtshock.");
      e.printStackTrace();
    }
  }
Example #2
0
  private void loadLang() {
    File lang = new File(getDataFolder(), "lang.yml");
    OutputStream out = null;
    InputStream defLangStream = this.getResource("lang.yml");
    if (!lang.exists()) {
      try {
        getDataFolder().mkdir();
        lang.createNewFile();
        if (defLangStream != null) {
          out = new FileOutputStream(lang);
          int read;
          byte[] bytes = new byte[1024];

          while ((read = defLangStream.read(bytes)) != -1) {
            out.write(bytes, 0, read);
          }
          YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defLangStream);
          Lang.setFile(defConfig);
          return;
        }
      } catch (IOException e) {
        e.printStackTrace(); // So they notice
        getLogger().severe("[PlayerVaults] Couldn't create language file.");
        getLogger().severe("[PlayerVaults] This is a fatal error. Now disabling");
        this.setEnabled(false); // Without it loaded, we can't send them messages
      } finally {
        if (defLangStream != null) {
          try {
            defLangStream.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
        if (out != null) {
          try {
            out.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
    }

    YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang);
    for (Lang item : Lang.values()) {
      if (conf.getString(item.getPath()) == null) {
        conf.set(item.getPath(), item.getDefault());
      }
    }

    Lang.setFile(conf);
    try {
      conf.save(lang);
    } catch (IOException e) {
      getLogger().log(Level.WARNING, "PlayerVaults: Failed to save lang.yml.");
      getLogger()
          .log(Level.WARNING, "PlayerVaults: Report this stack trace to drtshock and gomeow.");
      e.printStackTrace();
    }
  }
Example #3
0
  private void loadSigns() {
    if (!getConfig().getBoolean("signs-enabled", true)) {
      return;
    }

    getCommand("pvsign").setExecutor(new SignCommand());
    getServer().getPluginManager().registerEvents(new SignListener(this), this);
    File signs = new File(getDataFolder(), "signs.yml");
    if (!signs.exists()) {
      try {
        signs.createNewFile();
      } catch (IOException e) {
        getLogger()
            .severe("PlayerVaults has encountered a fatal error trying to load the signs file.");
        getLogger().severe("Please report this error to drtshock.");
        e.printStackTrace();
      }
    }
    this.signsFile = signs;
    this.signs = YamlConfiguration.loadConfiguration(signs);
  }