mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-04 18:02:24 +01:00
Directly implement RegisteredPlaceholder
This commit is contained in:
parent
8a80c063b7
commit
2b062f35bf
@ -5,8 +5,10 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.api.placeholder;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface RegisteredPlaceholder {
|
||||
|
||||
String getIdentifier();
|
||||
@NotNull String getIdentifier();
|
||||
|
||||
}
|
||||
|
@ -11,30 +11,30 @@ import me.filoghost.holographicdisplays.plugin.placeholder.StandardPlaceholder;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.parsing.PlaceholderIdentifier;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.parsing.PluginName;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class PlaceholderExpansion {
|
||||
public abstract class PlaceholderExpansion implements RegisteredPlaceholder {
|
||||
|
||||
private final PluginName pluginName;
|
||||
private final PlaceholderIdentifier identifier;
|
||||
private final RegisteredPlaceholder registeredPlaceholder;
|
||||
|
||||
public PlaceholderExpansion(Plugin plugin, String identifier) {
|
||||
this.pluginName = new PluginName(plugin);
|
||||
this.identifier = new PlaceholderIdentifier(identifier);
|
||||
this.registeredPlaceholder = identifier::toString;
|
||||
}
|
||||
|
||||
public PluginName getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public PlaceholderIdentifier getIdentifier() {
|
||||
public PlaceholderIdentifier getCaseInsensitiveIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public RegisteredPlaceholder asRegisteredPlaceholder() {
|
||||
return registeredPlaceholder;
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return identifier.toString();
|
||||
}
|
||||
|
||||
public abstract boolean isIndividual();
|
||||
|
@ -68,7 +68,7 @@ public class PlaceholderRegistry {
|
||||
}
|
||||
|
||||
private void registerExpansion(PlaceholderExpansion expansion) {
|
||||
placeholderExpansions.put(expansion.getIdentifier(), expansion.getPluginName(), expansion);
|
||||
placeholderExpansions.put(expansion.getCaseInsensitiveIdentifier(), expansion.getPluginName(), expansion);
|
||||
|
||||
version.incrementAndGet();
|
||||
}
|
||||
@ -101,13 +101,8 @@ public class PlaceholderRegistry {
|
||||
|
||||
public List<RegisteredPlaceholder> getRegisteredPlaceholders(Plugin plugin) {
|
||||
PluginName pluginName = new PluginName(plugin);
|
||||
List<RegisteredPlaceholder> identifiers = new ArrayList<>();
|
||||
|
||||
for (PlaceholderExpansion expansion : placeholderExpansions.column(pluginName).values()) {
|
||||
identifiers.add(expansion.asRegisteredPlaceholder());
|
||||
}
|
||||
|
||||
return identifiers;
|
||||
return new ArrayList<>(placeholderExpansions.column(pluginName).values());
|
||||
}
|
||||
|
||||
public boolean isRegisteredIdentifier(Plugin plugin, String identifier) {
|
||||
|
Loading…
Reference in New Issue
Block a user