public void reloadConf(CommandSender s) { boolean cloudEnabled = this.expansionCloud != null; expansionManager.clean(); PlaceholderAPI.unregisterAllProvidedExpansions(); reloadConfig(); setupOptions(); expansionManager.registerAllExpansions(); if (!config.isCloudEnabled()) { disableCloud(); } else if (!cloudEnabled) { enableCloud(); } s.sendMessage(ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.getRegisteredIdentifiers().size() + " &aplaceholder hooks successfully registered!")); }
@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(); }
public String dateFormat() { return plugin.getConfig().getString("date_format"); } }
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"); } }
public ExpansionManager(PlaceholderAPIPlugin instance) { plugin = instance; File f = new File(PlaceholderAPIPlugin.getInstance().getDataFolder(), "expansions"); if (!f.exists()) { f.mkdirs(); } }
public void setCloudEnabled(boolean b) { plugin.getConfig().set("cloud_enabled", b); plugin.reloadConfig(); }
Map<String, Object> defaults = ((Configurable) expansion).getDefaults(); String pre = "expansions." + expansion.getIdentifier() + "."; FileConfiguration cfg = plugin.getConfig(); boolean save = false; for (Entry<String, Object> entries : defaults.entrySet()) { plugin.saveConfig(); plugin.reloadConfig(); 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(); if (plugin.getExpansionCloud() != null) { CloudExpansion ce = plugin.getExpansionCloud().getCloudExpansion(expansion.getIdentifier()); if (ce != null) { ce.setHasExpansion(true);
Msg.msg(s, "PlaceholderAPI &7version &b&o" + plugin.getDescription().getVersion(), "&fCreated by&7: &bextended_clip", "&fPapi commands: &b/papi help", Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)", "&b/papi", "&fView plugin info/version info", "&fReload the config settings"); if (s.hasPermission("placeholderapi.ecloud")) { if (plugin.getExpansionCloud() == null) { Msg.msg(s, "&b/papi enablecloud", "&fEnable the expansion cloud"); if (plugin.getExpansionCloud() == null) { Msg.msg(s, "&7The expansion cloud is not enabled!"); return true; if (plugin.getExpansionCloud() != null) { Msg.msg(s, "&7The cloud is already enabled!"); return true; plugin.enableCloud(); plugin.getPlaceholderAPIConfig().setCloudEnabled(true); Msg.msg(s, "&aThe cloud has been enabled!"); return true; if (plugin.getExpansionCloud() == null) { Msg.msg(s, "&7The cloud is already disabled!");
public void fetch(boolean allowUnverified) { plugin.getLogger().info("Fetching available expansion information..."); plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { cexp.setName(name); PlaceholderExpansion ex = plugin.getExpansionManager().getRegisteredExpansion(cexp.getName()); plugin.getLogger().info(count + " placeholder expansions are available on the cloud."); plugin.getLogger().info(updates + " installed expansions have updates available.");
private void setupMetrics() { Metrics m = new Metrics(this); m.addCustomChart(new Metrics.SimplePie("using_expansion_cloud", () -> getExpansionCloud() != null ? "yes" : "no")); m.addCustomChart( new Metrics.SimplePie("using_spigot", () -> getServerVersion().isSpigot() ? "yes" : "no")); m.addCustomChart(new Metrics.AdvancedPie("expansions_used", () -> { Map<String, Integer> map = new HashMap<>(); Map<String, PlaceholderHook> p = PlaceholderAPI.getPlaceholders(); if (!p.isEmpty()) { for (PlaceholderHook hook : p.values()) { if (hook instanceof PlaceholderExpansion) { PlaceholderExpansion ex = (PlaceholderExpansion) hook; map.put(ex.getRequiredPlugin() == null ? ex.getIdentifier() : ex.getRequiredPlugin(), 1); } } } return map; })); }
.equalsIgnoreCase("fetch")) { msg(s, "&aRefresh task started. Use &f/papi ecloud list all &ain a few!!"); plugin.getExpansionCloud().clean(); plugin.getExpansionCloud().fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions()); return true; if (plugin.getExpansionCloud().getCloudExpansions().isEmpty()) { msg(s, "&7No cloud expansions are available at this time."); return true; plugin.getExpansionCloud().clean(); msg(s, "&aThe cache has been cleared!!"); return true; msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bexpansions available on the cloud.", "&7A total of &f" + plugin.getExpansionCloud().getCloudAuthorCount() + " &7authors have contributed to the expansion cloud."); if (plugin.getExpansionCloud().getToUpdateCount() > 0) { msg(s, "&eYou have &f" + plugin.getExpansionCloud().getToUpdateCount() + " &eexpansions installed that have updates available."); CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]); CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]); CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]); || plugin.getExpansionManager().getRegisteredExpansion(expansion.getName()) == null) {
private void applyConfig() { this.debug = config.getBoolean("Debug"); this.tabListEnabled = config.getBoolean("Tablist.Enabled"); this.longNametagsEnabled = config.getBoolean("Tablist.LongTags"); this.refreshTagOnWorldChange = config.getBoolean("RefreshTagOnWorldChange"); DISABLE_PUSH_ALL_TAGS = config.getBoolean("DisablePush"); if (config.getBoolean("MetricsEnabled")) { Metrics m = new Metrics(NametagEdit.getPlugin(NametagEdit.class)); m.addCustomChart(new Metrics.SimplePie("using_spigot", () -> PlaceholderAPIPlugin.getServerVersion().isSpigot() ? "yes" : "no")); } clearEmptyTeamTask = createTask("ClearEmptyTeamsInterval", clearEmptyTeamTask, new Runnable() { @Override public void run() { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "nte teams clear"); } }); refreshNametagTask = createTask("RefreshInterval", refreshNametagTask, new Runnable() { @Override public void run() { nametagManager.reset(); applyTags(); } }); }
/** * Quick getter for the {@link PlaceholderAPIPlugin} instance * * @return {@link PlaceholderAPIPlugin} instance */ public PlaceholderAPIPlugin getPlaceholderAPI() { return PlaceholderAPIPlugin.getInstance(); }
public UpdateChecker(PlaceholderAPIPlugin i) { plugin = i; pluginVersion = i.getDescription().getVersion(); }
@Override public void onDisable() { disableCloud(); PlaceholderAPI.unregisterAll(); expansionManager.clean(); expansionManager = null; Bukkit.getScheduler().cancelTasks(this); serverVersion = null; instance = null; }
@EventHandler public void onEnable(PluginEnableEvent event) { ExpansionManager m = plugin.getExpansionManager(); PlaceholderExpansion e = m.getCachedExpansion(event.getPlugin().getName().toLowerCase()); if (e != null && e.canRegister()) { if (e.isRegistered() || m.registerExpansion(e)) { m.removeCachedExpansion(e.getRequiredPlugin()); } } }
@EventHandler public void onExpansionUnregister(ExpansionUnregisterEvent event) { if (event.getExpansion() instanceof Listener) { HandlerList.unregisterAll((Listener) event.getExpansion()); } if (event.getExpansion() instanceof Taskable) { ((Taskable) event.getExpansion()).stop(); } if (event.getExpansion() instanceof Cacheable) { ((Cacheable) event.getExpansion()).clear(); } if (plugin.getExpansionCloud() != null) { CloudExpansion ex = plugin.getExpansionCloud() .getCloudExpansion(event.getExpansion().getName()); if (ex != null) { ex.setHasExpansion(false); ex.setShouldUpdate(false); } } }
public static List<Class<?>> getClasses(String folder, String fileName, Class<?> type) { List<Class<?>> list = new ArrayList<>(); try { File f = new File(PlaceholderAPIPlugin.getInstance().getDataFolder(), folder); if (!f.exists()) { return list; } FilenameFilter fileNameFilter = (dir, name) -> { if (fileName != null) { return name.endsWith(".jar") && name.replace(".jar", "") .equalsIgnoreCase(fileName.replace(".jar", "")); } return name.endsWith(".jar"); }; File[] jars = f.listFiles(fileNameFilter); if (jars == null) { return list; } for (File file : jars) { list = gather(file.toURI().toURL(), list, type); } return list; } catch (Throwable t) { } return null; }
public boolean isCloudEnabled() { return plugin.getConfig().getBoolean("cloud_enabled"); }
public String booleanFalse() { return plugin.getConfig().getString("boolean.false"); }