/** * The name of this expansion * * @return {@link #getIdentifier()} by default, name of this expansion if specified */ public String getName() { return getIdentifier(); }
/** * Check if this placeholder identfier has already been registered * * @return true if the identifier for this expansion is already registered */ public boolean isRegistered() { Validate.notNull(getIdentifier(), "Placeholder identifier can not be null!"); return PlaceholderAPI.getRegisteredIdentifiers().contains(getIdentifier()); }
/** * Attempt to register this PlaceholderExpansion * * @return true if this expansion is now registered with PlaceholderAPI */ public boolean register() { Validate.notNull(getIdentifier(), "Placeholder identifier can not be null!"); return PlaceholderAPI.registerExpansion(this); }
public ConfigurationSection getConfigSection(String path) { return getPlaceholderAPI().getConfig() .getConfigurationSection("expansions." + getIdentifier() + "." + path); }
public int getInt(String path, int def) { return getPlaceholderAPI().getConfig() .getInt("expansions." + getIdentifier() + "." + path, def); }
public String getString(String path, String def) { return getPlaceholderAPI().getConfig() .getString("expansions." + getIdentifier() + "." + path, def); }
public long getLong(String path, long def) { return getPlaceholderAPI().getConfig() .getLong("expansions." + getIdentifier() + "." + path, def); }
public Object get(String path, Object def) { return getPlaceholderAPI().getConfig().get("expansions." + getIdentifier() + "." + path, def); }
public double getDouble(String path, double def) { return getPlaceholderAPI().getConfig() .getDouble("expansions." + getIdentifier() + "." + path, def); }
public List<String> getStringList(String path) { return getPlaceholderAPI().getConfig() .getStringList("expansions." + getIdentifier() + "." + path); }
public boolean configurationContains(String path) { return getPlaceholderAPI().getConfig().contains("expansions." + getIdentifier() + "." + path); }
public ConfigurationSection getConfigSection() { return getPlaceholderAPI().getConfig().getConfigurationSection("expansions." + getIdentifier()); }
@Override public void register() { Set<String> variables = Sets.newHashSet(); Collection<PlaceholderHook> hooks = PlaceholderAPI.getPlaceholders().values(); for (PlaceholderHook hook : hooks) { String variablePrefix = null; if (hook instanceof EZPlaceholderHook) { variablePrefix = ((EZPlaceholderHook) hook).getPlaceholderName(); } else if (hook instanceof PlaceholderExpansion) { variablePrefix = ((PlaceholderExpansion) hook).getIdentifier(); } if (variablePrefix != null) { variables.add(variablePrefix + "_*"); } } for (String variable : variables) { register(variable).supply(player -> PlaceholderAPI.setPlaceholders(player, '%' + variable + '%')); } } }
public static boolean unregisterExpansion(PlaceholderExpansion ex) { if (unregisterPlaceholderHook(ex.getIdentifier())) { Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(ex)); return true; } return false; }
public static boolean registerExpansion(PlaceholderExpansion ex) { if (registerPlaceholderHook(ex.getIdentifier(), ex)) { Bukkit.getPluginManager().callEvent(new ExpansionRegisterEvent(ex)); return true; } return false; }
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; })); }
public boolean registerExpansion(PlaceholderExpansion expansion) { if (expansion == null || expansion.getIdentifier() == null) { return false; String pre = "expansions." + expansion.getIdentifier() + "."; FileConfiguration cfg = plugin.getConfig(); boolean save = false; plugin.getLogger() .info( "Your server version is not compatible with expansion: " + expansion.getIdentifier() + " version: " + expansion.getVersion()); return false; Bukkit.getPluginManager().registerEvents(l, plugin); plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier()); if (expansion instanceof Taskable) { ((Taskable) expansion).start(); CloudExpansion ce = plugin.getExpansionCloud().getCloudExpansion(expansion.getIdentifier()); if (ce != null) { ce.setHasExpansion(true);
plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier());
PlaceholderAPI.unregisterPlaceholderHook(loaded.getIdentifier());