public ExpansionCloudManager(PlaceholderAPIPlugin plugin) { this.plugin = plugin; expansionsDir = new File(plugin.getDataFolder(), "expansions"); final boolean result = expansionsDir.mkdirs(); if (result) { plugin.getLogger().info("Created Expansions Directory"); } }
private PlaceholderExpansion createInstance(Class<?> klass) { if (klass == null) { return null; } PlaceholderExpansion ex = null; if (!PlaceholderExpansion.class.isAssignableFrom(klass)) { return null; } try { Constructor<?>[] c = klass.getConstructors(); if (c.length == 0) { ex = (PlaceholderExpansion) klass.newInstance(); } else { for (Constructor<?> con : c) { if (con.getParameterTypes().length == 0) { ex = (PlaceholderExpansion) klass.newInstance(); break; } } } } catch (Throwable t) { plugin.getLogger() .severe("Failed to init placeholder expansion from class: " + klass.getName()); plugin.getLogger().severe(t.getMessage()); } return ex; } }
public void fetch() { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { try { HttpsURLConnection con = (HttpsURLConnection) new URL( "https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID).openConnection(); con.setRequestMethod("GET"); spigotVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine(); } catch (Exception ex) { plugin.getLogger().info("Failed to check for updates on spigot."); return; } if (spigotVersion == null || spigotVersion.isEmpty()) { return; } updateAvailable = spigotIsNewer(); if (!updateAvailable) { return; } Bukkit.getScheduler().runTask(plugin, () -> { plugin.getLogger() .info("An update for PlaceholderAPI (v" + getSpigotVersion() + ") is available at:"); plugin.getLogger() .info("https://www.spigotmc.org/resources/placeholderapi." + RESOURCE_ID + "/"); Bukkit.getPluginManager().registerEvents(this, plugin); }); }); }
plugin.getLogger().info("Attempting download of expansion: " + ex.getName() + (player != null ? " by user: " + player : "") + " from url: " + ver.getUrl()); plugin.getLogger().info("Download of expansion: " + ex.getName() + " complete!"); plugin.getLogger() .warning("Failed to download expansion: " + ex.getName() + " from: " + ver.getUrl());
VersionSpecific nms = (VersionSpecific) expansion; if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) { plugin.getLogger() .info( "Your server version is not compatible with expansion: " + expansion.getIdentifier() Bukkit.getPluginManager().registerEvents(l, plugin); plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier()); if (expansion instanceof Taskable) { ((Taskable) expansion).start();
@Override public void onEnable() { config.loadDefConfig(); setupOptions(); getCommand("placeholderapi").setExecutor(new PlaceholderAPICommands(this)); new PlaceholderListener(this); getLogger().info("Placeholder expansion registration initializing..."); expansionManager.registerAllExpansions(); if (config.checkUpdates()) { new UpdateChecker(this).fetch(); } if (config.isCloudEnabled()) { enableCloud(); } setupMetrics(); }