mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI.git
synced 2024-12-30 21:07:42 +01:00
Added getRequiredPlugin method.
Deprecated getPlugin(), getLink(), and getDescription(). fix javadoc for PlaceholderExpansion class... closes #22, closes #23
This commit is contained in:
parent
e1ba07b7bd
commit
659af4833e
@ -149,8 +149,8 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
|
|||||||
for (PlaceholderHook hook : p.values()) {
|
for (PlaceholderHook hook : p.values()) {
|
||||||
if (hook instanceof PlaceholderExpansion) {
|
if (hook instanceof PlaceholderExpansion) {
|
||||||
PlaceholderExpansion ex = (PlaceholderExpansion) hook;
|
PlaceholderExpansion ex = (PlaceholderExpansion) hook;
|
||||||
map.put(ex.getPlugin() == null ? ex.getIdentifier()
|
map.put(ex.getRequiredPlugin() == null ? ex.getIdentifier()
|
||||||
: ex.getPlugin(), 1);
|
: ex.getRequiredPlugin(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class PlaceholderListener implements Listener {
|
|||||||
PlaceholderExpansion e = m.getCachedExpansion(event.getPlugin().getName().toLowerCase());
|
PlaceholderExpansion e = m.getCachedExpansion(event.getPlugin().getName().toLowerCase());
|
||||||
if (e != null && e.canRegister()) {
|
if (e != null && e.canRegister()) {
|
||||||
if (e.isRegistered() || m.registerExpansion(e)) {
|
if (e.isRegistered() || m.registerExpansion(e)) {
|
||||||
m.removeCachedExpansion(e.getPlugin());
|
m.removeCachedExpansion(e.getRequiredPlugin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,11 +122,11 @@ public class PlaceholderListener implements Listener {
|
|||||||
|
|
||||||
PlaceholderExpansion ex = (PlaceholderExpansion) i;
|
PlaceholderExpansion ex = (PlaceholderExpansion) i;
|
||||||
|
|
||||||
if (ex.getPlugin() == null) {
|
if (ex.getRequiredPlugin() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ex.getPlugin().equalsIgnoreCase(n)) {
|
if (ex.getRequiredPlugin().equalsIgnoreCase(n)) {
|
||||||
if (PlaceholderAPI.unregisterExpansion(ex)) {
|
if (PlaceholderAPI.unregisterExpansion(ex)) {
|
||||||
plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier());
|
plugin.getLogger().info("Unregistered placeholder expansion: " + ex.getIdentifier());
|
||||||
}
|
}
|
||||||
|
@ -155,16 +155,8 @@ public class PlaceholderAPICommands implements CommandExecutor {
|
|||||||
Msg.msg(s, "&7Version: &f" + ex.getVersion());
|
Msg.msg(s, "&7Version: &f" + ex.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ex.getDescription() != null) {
|
if (ex.getRequiredPlugin() != null) {
|
||||||
Msg.msg(s, ex.getDescription());
|
Msg.msg(s, "&7Requires plugin: &f" + ex.getRequiredPlugin());
|
||||||
}
|
|
||||||
|
|
||||||
if (ex.getLink() != null) {
|
|
||||||
Msg.msg(s, "&7Link: &f" + ex.getLink());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ex.getPlugin() != null) {
|
|
||||||
Msg.msg(s, "&7Requires plugin: &f" + ex.getPlugin());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ex.getPlaceholders() != null) {
|
if (ex.getPlaceholders() != null) {
|
||||||
|
@ -116,16 +116,13 @@ public final class ExpansionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!c.canRegister()) {
|
if (!c.canRegister()) {
|
||||||
if (c.getPlugin() != null) {
|
if (c.getRequiredPlugin() != null) {
|
||||||
cache.put(c.getPlugin().toLowerCase(), c);
|
cache.put(c.getRequiredPlugin().toLowerCase(), c);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c.register()) {
|
if (!c.register()) {
|
||||||
if (c.getPlugin() != null) {
|
|
||||||
cache.put(c.getPlugin().toLowerCase(), c);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,44 +33,43 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this expansion
|
* The name of this expansion
|
||||||
* @return identifier used for expansion if no name present
|
* @return {@link #getIdentifier()} by default, name of this expansion if specified
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getIdentifier();
|
return getIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the identifier that this placeholder expansion uses to be passed placeholder requests
|
* The placeholder identifier of this expanion
|
||||||
* @return placeholder identifier that is associated with this class
|
* @return placeholder identifier that is associated with this expansion
|
||||||
*/
|
*/
|
||||||
public abstract String getIdentifier();
|
public abstract String getIdentifier();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plugin that this expansion hooks into.
|
* The author of this expansion
|
||||||
* This will ensure the expansion is added to a cache if canRegister() returns false
|
|
||||||
* get.
|
|
||||||
* The expansion will be removed from the cache
|
|
||||||
* once a plugin loads with the name that is here and the expansion is registered
|
|
||||||
* @return placeholder identifier that is associated with this class
|
|
||||||
*/
|
|
||||||
public abstract String getPlugin();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the author of this PlaceholderExpansion
|
|
||||||
* @return name of the author for this expansion
|
* @return name of the author for this expansion
|
||||||
*/
|
*/
|
||||||
public abstract String getAuthor();
|
public abstract String getAuthor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of this PlaceholderExpansion
|
* The version of this expansion
|
||||||
* @return current version of this expansion
|
* @return current version of this expansion
|
||||||
*/
|
*/
|
||||||
public abstract String getVersion();
|
public abstract String getVersion();
|
||||||
|
|
||||||
public String getDescription() { return null; }
|
/**
|
||||||
|
* The name plugin that this expansion hooks into.
|
||||||
public String getLink() { return null; }
|
* by default will return the deprecated {@link #getPlugin()} method
|
||||||
|
* @return plugin name that this expansion requires to function
|
||||||
|
*/
|
||||||
|
public String getRequiredPlugin() {
|
||||||
|
return getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The placeholders for this expansion
|
||||||
|
* @return placeholders that this expansion provides
|
||||||
|
*/
|
||||||
public List<String> getPlaceholders() {
|
public List<String> getPlaceholders() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -78,7 +77,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
/**
|
/**
|
||||||
* Expansions that do not use the ecloud and instead register from the dependency should set this to true
|
* Expansions that do not use the ecloud and instead register from the dependency should set this to true
|
||||||
* to ensure that your placeholder expansion is not unregistered when the papi reload command is used
|
* to ensure that your placeholder expansion is not unregistered when the papi reload command is used
|
||||||
* @return if the expansion should persist through reloads
|
* @return if the expansion should persist through placeholder reloads
|
||||||
*/
|
*/
|
||||||
public boolean persist() {
|
public boolean persist() {
|
||||||
return false;
|
return false;
|
||||||
@ -98,7 +97,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
* @return true if this hook meets all the requirements to register
|
* @return true if this hook meets all the requirements to register
|
||||||
*/
|
*/
|
||||||
public boolean canRegister() {
|
public boolean canRegister() {
|
||||||
return getPlugin() == null || Bukkit.getPluginManager().getPlugin(getPlugin()) != null;
|
return getRequiredPlugin() == null || Bukkit.getPluginManager().getPlugin(getRequiredPlugin()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,4 +152,25 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
public boolean configurationContains(String path) {
|
public boolean configurationContains(String path) {
|
||||||
return getPlaceholderAPI().getConfig().contains("expansions." + getIdentifier() + "." + path);
|
return getPlaceholderAPI().getConfig().contains("expansions." + getIdentifier() + "." + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated As of versions greater than 2.8.7, use {@link #getRequiredPlugin()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String getPlugin() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to show a description
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String getDescription() { return null; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to display a link
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String getLink() { return null; }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user