private void loadingRequiredLibs() { try { final File[] libs = new File[] { new File(this.getDataFolder() + "/lib/", "c3p0-0.9.5.jar"), new File(this.getDataFolder() + "/lib/", "mchange-commons-java-0.2.9.jar") }; for (final File lib : libs) { if (!lib.exists()) { JarUtils.extractFromJar(lib.getName(), lib.getAbsolutePath()); } } for (final File lib : libs) { if (!lib.exists()) { this.getLogger() .warning( "There was a critical error loading bedwars plugin! Could not find lib: " + lib.getName()); Bukkit.getServer().getPluginManager().disablePlugin(this); return; } this.addClassPath(JarUtils.getJarUrl(lib)); } } catch (final Exception e) { e.printStackTrace(); } }
public void loadShop() { File file = new File(Main.getInstance().getDataFolder(), "shop.yml"); if (!file.exists()) { // create default file this.saveResource("shop.yml", false); // wait until it's really saved try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } this.shopConfig = new YamlConfiguration(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); this.shopConfig.load(reader); } catch (Exception e) { this.getServer() .getConsoleSender() .sendMessage( ChatWriter.pluginMessage( ChatColor.RED + "Couldn't load shop! Error in parsing shop!")); e.printStackTrace(); } }
public String getYamlDump(YamlConfiguration config) { try { String fullstring = config.saveToString(); String endstring = fullstring; endstring = Utils.unescape_perl_string(fullstring); return endstring; } catch (Exception ex) { ex.printStackTrace(); } return null; }
public void saveConfiguration() { File file = new File(Main.getInstance().getDataFolder(), "config.yml"); try { file.mkdirs(); String data = this.getYamlDump((YamlConfiguration) this.getConfig()); FileOutputStream stream = new FileOutputStream(file); OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8"); try { writer.write(data); } finally { writer.close(); stream.close(); } } catch (Exception ex) { ex.printStackTrace(); } }
public void loadConfigInUTF() { File configFile = new File(this.getDataFolder(), "config.yml"); if (!configFile.exists()) { return; } try { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), "UTF-8")); this.getConfig().load(reader); } catch (Exception e) { e.printStackTrace(); } if (this.getConfig() == null) { return; } // load breakable materials this.breakableTypes = new ArrayList<Material>(); for (String material : this.getConfig().getStringList("breakable-blocks")) { if (material.equalsIgnoreCase("none")) { continue; } Material mat = Utils.parseMaterial(material); if (mat == null) { continue; } if (this.breakableTypes.contains(mat)) { continue; } this.breakableTypes.add(mat); } }