@Override public File getDataFolder() { return ((Plugin) getPlugin()).getDataFolder(); }
@SneakyThrows public EventLogger() { Plugin plugin = BungeeTabListPlus.getInstance().getPlugin(); File dataFolder = plugin.getDataFolder(); File eventlog = new File(dataFolder, "eventlog"); if (!eventlog.exists()) { eventlog.mkdir(); } String name = UUID.randomUUID().toString() + ".log"; file = new File(eventlog, name); tmpFile = new File(eventlog, name + ".incomplete"); writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8)); ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> { try { while (msgQueue.take().call()) ; } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } catch (Exception ex) { Throwables.propagate(ex); } }); }
/** * Gets the first bStat Metrics class. * * @return The first bStats metrics class. */ private Class<?> getFirstBStatsClass() { Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats"); configPath.toFile().mkdirs(); File tempFile = new File(configPath.toFile(), "temp.txt"); try { String className = readFile(tempFile); if (className != null) { try { // Let's check if a class with the given name exists. return Class.forName(className); } catch (ClassNotFoundException ignored) { } } writeFile(tempFile, getClass().getName()); return getClass(); } catch (IOException e) { if (logFailedRequests) { plugin.getLogger().log(Level.WARNING, "Failed to get first bStats class!", e); } return null; } }
/** * Gets the first bStat Metrics class. * * @return The first bStats metrics class. */ private Class<?> getFirstBStatsClass() { Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats"); configPath.toFile().mkdirs(); File tempFile = new File(configPath.toFile(), "temp.txt"); try { String className = readFile(tempFile); if (className != null) { try { // Let's check if a class with the given name exists. return Class.forName(className); } catch (ClassNotFoundException ignored) { } } writeFile(tempFile, getClass().getName()); return getClass(); } catch (IOException e) { if (logFailedRequests) { plugin.getLogger().log(Level.WARNING, "Failed to get first bStats class!", e); } return null; } }
public boolean loadTabLists() { File tablistFolder = new File(plugin.getPlugin().getDataFolder(), "tabLists"); if (!tablistFolder.exists()) { tablistFolder.mkdirs(); try { FileOutputStream outputStream = new FileOutputStream(new File(tablistFolder, "default.yml")); ByteStreams.copy(getClass().getClassLoader().getResourceAsStream("default.yml"), outputStream); outputStream.close(); } catch (IOException e) { plugin.getLogger().log(Level.WARNING, "Failed to save default config.", e); } } for (File file : tablistFolder.listFiles()) { if (file.isFile() && file.getName().endsWith(".yml")) { try { plugin.getLogger().log(Level.INFO, "Loading {0}", file.getName()); ITabListConfig tabListConfig = Objects.requireNonNull(YamlConfig.read(new FileInputStream(file), ITabListConfig.class)); if (tabListConfig instanceof UnsupportedConfig) { plugin.getLogger().log(Level.WARNING, "Failed to load {0}. Still using the old format? https://github.com/CodeCrafter47/BungeeTabListPlus/wiki/Updating", file.getName()); } else { configs.add((Config) tabListConfig); } } catch (Throwable ex) { plugin.getLogger().log(Level.WARNING, "Failed to load " + file.getName(), ex); } } } return true; }
/** * Loads the bStats configuration. * * @throws IOException If something did not work :( */ private void loadConfig() throws IOException { Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats"); configPath.toFile().mkdirs(); File configFile = new File(configPath.toFile(), "config.yml"); if (!configFile.exists()) { writeFile(configFile, "#bStats collects some data for plugin authors like how many servers are using their plugins.", "#To honor their work, you should not disable it.", "#This has nearly no effect on the server performance!", "#Check out https://bStats.org/ to learn more :)", "enabled: true", "serverUuid: \"" + UUID.randomUUID().toString() + "\"", "logFailedRequests: false", "logSentData: false", "logResponseStatusText: false"); } Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); // Load configuration enabled = configuration.getBoolean("enabled", true); serverUUID = configuration.getString("serverUuid"); logFailedRequests = configuration.getBoolean("logFailedRequests", false); logSentData = configuration.getBoolean("logSentData", false); logResponseStatusText = configuration.getBoolean("logResponseStatusText", false); }
/** * Loads the bStats configuration. * * @throws IOException If something did not work :( */ private void loadConfig() throws IOException { Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats"); configPath.toFile().mkdirs(); File configFile = new File(configPath.toFile(), "config.yml"); if (!configFile.exists()) { writeFile(configFile, "#bStats collects some data for plugin authors like how many servers are using their plugins.", "#To honor their work, you should not disable it.", "#This has nearly no effect on the server performance!", "#Check out https://bStats.org/ to learn more :)", "enabled: true", "serverUuid: \"" + UUID.randomUUID().toString() + "\"", "logFailedRequests: false", "logSentData: false", "logResponseStatusText: false"); } Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); // Load configuration enabled = configuration.getBoolean("enabled", true); serverUUID = configuration.getString("serverUuid"); logFailedRequests = configuration.getBoolean("logFailedRequests", false); logSentData = configuration.getBoolean("logSentData", false); logResponseStatusText = configuration.getBoolean("logResponseStatusText", false); }
File file = new File(plugin.getDataFolder(), "config.yml"); config = YamlConfig.read(new FileInputStream(file), MainConfig.class); if (config.needWrite) {
if (!plugin.getDataFolder().exists()) { plugin.getDataFolder().mkdirs(); File file = new File(plugin.getDataFolder(), "config.yml"); if (!file.exists()) { config = new MainConfig(); File headsFolder = new File(plugin.getDataFolder(), "heads"); if (!entry.isDirectory() && entry.getName().startsWith("heads/")) { try { File targetFile = new File(plugin.getDataFolder(), entry.getName()); targetFile.getParentFile().mkdirs(); if (!targetFile.exists()) {