Expand API
This commit is contained in:
parent
e8b2239c47
commit
6f6a214ecd
|
@ -7,7 +7,12 @@ package me.filoghost.holographicdisplays.api;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||||
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholder;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderFactory;
|
||||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholder;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderFactory;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderReplacementSupplier;
|
||||||
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -80,7 +85,32 @@ public interface HolographicDisplaysAPI {
|
||||||
/**
|
/**
|
||||||
* @since 1
|
* @since 1
|
||||||
*/
|
*/
|
||||||
void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacementSupplier replacementSupplier);
|
void registerGlobalPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacementSupplier replacementSupplier);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
void registerGlobalPlaceholder(@NotNull String identifier, @NotNull GlobalPlaceholder placeholder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
void registerGlobalPlaceholderFactory(@NotNull String identifier, @NotNull GlobalPlaceholderFactory placeholderFactory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
void registerIndividualPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull IndividualPlaceholderReplacementSupplier replacementSupplier);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
void registerIndividualPlaceholder(@NotNull String identifier, @NotNull IndividualPlaceholder placeholder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1
|
||||||
|
*/
|
||||||
|
void registerIndividualPlaceholderFactory(@NotNull String identifier, @NotNull IndividualPlaceholderFactory placeholderFactory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1
|
* @since 1
|
||||||
|
|
|
@ -9,7 +9,12 @@ import me.filoghost.fcommons.Preconditions;
|
||||||
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||||
import me.filoghost.holographicdisplays.api.Position;
|
import me.filoghost.holographicdisplays.api.Position;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholder;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderFactory;
|
||||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholder;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderFactory;
|
||||||
|
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderReplacementSupplier;
|
||||||
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.base.ImmutablePosition;
|
import me.filoghost.holographicdisplays.plugin.hologram.base.ImmutablePosition;
|
||||||
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
|
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
|
||||||
|
@ -50,17 +55,62 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacementSupplier replacementSupplier) {
|
public void registerGlobalPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacementSupplier replacementSupplier) {
|
||||||
Preconditions.notEmpty(identifier, "identifier");
|
checkIdentifier(identifier);
|
||||||
for (char c : identifier.toCharArray()) {
|
|
||||||
Preconditions.checkArgument(isValidIdentifierCharacter(c), "identifier contains invalid character '" + c + "'");
|
|
||||||
}
|
|
||||||
Preconditions.checkArgument(refreshIntervalTicks >= 0, "refreshIntervalTicks should be positive");
|
Preconditions.checkArgument(refreshIntervalTicks >= 0, "refreshIntervalTicks should be positive");
|
||||||
Preconditions.notNull(replacementSupplier, "replacementSupplier");
|
Preconditions.notNull(replacementSupplier, "replacementSupplier");
|
||||||
|
|
||||||
placeholderRegistry.registerGlobalPlaceholder(plugin, identifier, refreshIntervalTicks, replacementSupplier);
|
placeholderRegistry.registerGlobalPlaceholder(plugin, identifier, refreshIntervalTicks, replacementSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerGlobalPlaceholder(@NotNull String identifier, @NotNull GlobalPlaceholder placeholder) {
|
||||||
|
checkIdentifier(identifier);
|
||||||
|
Preconditions.notNull(placeholder, "placeholder");
|
||||||
|
|
||||||
|
placeholderRegistry.registerGlobalPlaceholder(plugin, identifier, placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerGlobalPlaceholderFactory(@NotNull String identifier, @NotNull GlobalPlaceholderFactory placeholderFactory) {
|
||||||
|
checkIdentifier(identifier);
|
||||||
|
Preconditions.notNull(placeholderFactory, "placeholderFactory");
|
||||||
|
|
||||||
|
placeholderRegistry.registerGlobalPlaceholderFactory(plugin, identifier, placeholderFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIndividualPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull IndividualPlaceholderReplacementSupplier replacementSupplier) {
|
||||||
|
checkIdentifier(identifier);
|
||||||
|
Preconditions.checkArgument(refreshIntervalTicks >= 0, "refreshIntervalTicks should be positive");
|
||||||
|
Preconditions.notNull(replacementSupplier, "replacementSupplier");
|
||||||
|
|
||||||
|
placeholderRegistry.registerIndividualPlaceholder(plugin, identifier, refreshIntervalTicks, replacementSupplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIndividualPlaceholder(@NotNull String identifier, @NotNull IndividualPlaceholder placeholder) {
|
||||||
|
checkIdentifier(identifier);
|
||||||
|
Preconditions.notNull(placeholder, "placeholder");
|
||||||
|
|
||||||
|
placeholderRegistry.registerIndividualPlaceholder(plugin, identifier, placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIndividualPlaceholderFactory(@NotNull String identifier, @NotNull IndividualPlaceholderFactory placeholderFactory) {
|
||||||
|
checkIdentifier(identifier);
|
||||||
|
Preconditions.notNull(placeholderFactory, "placeholderFactory");
|
||||||
|
|
||||||
|
placeholderRegistry.registerIndividualPlaceholderFactory(plugin, identifier, placeholderFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkIdentifier(String identifier) {
|
||||||
|
Preconditions.notEmpty(identifier, "identifier");
|
||||||
|
for (char c : identifier.toCharArray()) {
|
||||||
|
Preconditions.checkArgument(isValidIdentifierCharacter(c), "identifier contains invalid character '" + c + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isValidIdentifierCharacter(char c) {
|
private boolean isValidIdentifierCharacter(char c) {
|
||||||
return ('a' <= c && c <= 'z')
|
return ('a' <= c && c <= 'z')
|
||||||
|| ('A' <= c && c <= 'Z')
|
|| ('A' <= c && c <= 'Z')
|
||||||
|
|
Loading…
Reference in New Issue