/** * The name of this expansion * * @return {@link #getIdentifier()} by default, name of this expansion if specified */ public String getName() { return getIdentifier(); }
/** * The name of the plugin that this expansion hooks into. by default will return the deprecated * {@link #getPlugin()} method * * @return plugin name that this expansion requires to function */ public String getRequiredPlugin() { return getPlugin(); }
public static NMSVersion getVersion(String version) { for (NMSVersion v : values()) { if (v.getVersion().equalsIgnoreCase(version)) { return v; } } return NMSVersion.UNKNOWN; }
public ConfigurationSection getConfigSection(String path) { return getPlaceholderAPI().getConfig() .getConfigurationSection("expansions." + getIdentifier() + "." + path); }
@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()); } } }
public PlaceholderExpansion registerExpansion(String fileName) { List<Class<?>> subs = FileUtil.getClasses("expansions", fileName, PlaceholderExpansion.class); if (subs == null || subs.isEmpty()) { return null; } // only register the first instance found as an expansion jar should only have 1 class // extending PlaceholderExpansion PlaceholderExpansion ex = createInstance(subs.get(0)); if (registerExpansion(ex)) { return ex; } return null; }
public boolean compareTo(String version) { return getVersion().equalsIgnoreCase(version); }
/** * If any requirements need to be checked before this expansion should register, you can check * them here * * @return true if this hook meets all the requirements to register */ public boolean canRegister() { return getRequiredPlugin() == null || Bukkit.getPluginManager().getPlugin(getRequiredPlugin()) != null; }
/** * unregister all expansions provided by PlaceholderAPI */ public static void unregisterAllProvidedExpansions() { if (placeholders.isEmpty()) { return; } getPlaceholders().forEach((key, value) -> { if (value instanceof PlaceholderExpansion) { PlaceholderExpansion ex = (PlaceholderExpansion) value; if (!ex.persist()) { unregisterExpansion(ex); } } }); }
@Override public void onLoad() { startTime = System.currentTimeMillis(); instance = this; serverVersion = getVersion(); config = new PlaceholderAPIConfig(this); expansionManager = new ExpansionManager(this); }
public String getString(String path, String def) { return getPlaceholderAPI().getConfig() .getString("expansions." + getIdentifier() + "." + path, def); }
/** * 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 void registerAllExpansions() { if (plugin == null) { return; } List<Class<?>> subs = FileUtil.getClasses("expansions", null, PlaceholderExpansion.class); if (subs == null || subs.isEmpty()) { return; } for (Class<?> klass : subs) { PlaceholderExpansion ex = createInstance(klass); if (ex != null) { registerExpansion(ex); } } }
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 int getInt(String path, int def) { return getPlaceholderAPI().getConfig() .getInt("expansions." + getIdentifier() + "." + path, def); }
public ConfigurationSection getConfigSection() { return getPlaceholderAPI().getConfig().getConfigurationSection("expansions." + getIdentifier()); }
public boolean configurationContains(String path) { return getPlaceholderAPI().getConfig().contains("expansions." + getIdentifier() + "." + path); }