mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-29 12:17:36 +01:00
Rename PlaceholderReplacer to PlaceholderReplacementSupplier
This commit is contained in:
parent
dc9f0fe2b4
commit
769d3dacb2
@ -7,7 +7,7 @@ package me.filoghost.holographicdisplays.api;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacer;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -80,7 +80,7 @@ public interface HolographicDisplaysAPI {
|
||||
/**
|
||||
* @since 1
|
||||
*/
|
||||
void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacer replacer);
|
||||
void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacementSupplier replacementSupplier);
|
||||
|
||||
/**
|
||||
* @since 1
|
||||
|
@ -8,6 +8,6 @@ package me.filoghost.holographicdisplays.api.placeholder;
|
||||
/**
|
||||
* @since 1
|
||||
*/
|
||||
public interface GlobalPlaceholder extends GlobalPlaceholderReplacer, Placeholder {
|
||||
public interface GlobalPlaceholder extends GlobalPlaceholderReplacementSupplier, Placeholder {
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @since 1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface GlobalPlaceholderReplacer {
|
||||
public interface GlobalPlaceholderReplacementSupplier {
|
||||
|
||||
/**
|
||||
* Callback for providing a placeholder replacement, given the argument of the placeholder (if present).
|
@ -8,6 +8,6 @@ package me.filoghost.holographicdisplays.api.placeholder;
|
||||
/**
|
||||
* @since 1
|
||||
*/
|
||||
public interface IndividualPlaceholder extends IndividualPlaceholderReplacer, Placeholder {
|
||||
public interface IndividualPlaceholder extends IndividualPlaceholderReplacementSupplier, Placeholder {
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @since 1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IndividualPlaceholderReplacer {
|
||||
public interface IndividualPlaceholderReplacementSupplier {
|
||||
|
||||
/**
|
||||
* @since 1
|
@ -9,7 +9,7 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.Position;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacer;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
|
||||
@ -50,15 +50,15 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacer replacer) {
|
||||
public void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull GlobalPlaceholderReplacementSupplier replacementSupplier) {
|
||||
Preconditions.notEmpty(identifier, "identifier");
|
||||
for (char c : identifier.toCharArray()) {
|
||||
Preconditions.checkArgument(isValidIdentifierCharacter(c), "identifier contains invalid character '" + c + "'");
|
||||
}
|
||||
Preconditions.checkArgument(refreshIntervalTicks >= 0, "refreshIntervalTicks should be positive");
|
||||
Preconditions.notNull(replacer, "replacer");
|
||||
Preconditions.notNull(replacementSupplier, "replacementSupplier");
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, identifier, refreshIntervalTicks, replacer);
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, identifier, refreshIntervalTicks, replacementSupplier);
|
||||
}
|
||||
|
||||
private boolean isValidIdentifierCharacter(char c) {
|
||||
|
@ -68,7 +68,7 @@ public class V2HologramsAPIProvider extends HologramsAPIProvider {
|
||||
boolean alreadyRegistered = placeholderRegistry.isRegisteredIdentifier(plugin, textPlaceholder);
|
||||
|
||||
if (!alreadyRegistered) {
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(
|
||||
placeholderRegistry.registerGlobalPlaceholder(
|
||||
plugin,
|
||||
textPlaceholder,
|
||||
refreshIntervalTicks,
|
||||
|
@ -30,7 +30,7 @@ public class DefaultPlaceholders {
|
||||
BungeeServerTracker bungeeServerTracker) {
|
||||
placeholderRegistry.unregisterAll(plugin);
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "empty", Integer.MAX_VALUE, (argument) -> {
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, "empty", Integer.MAX_VALUE, (argument) -> {
|
||||
return "";
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ public class DefaultPlaceholders {
|
||||
ChatColor.LIGHT_PURPLE
|
||||
)));
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "time", 10, (argument) -> {
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, "time", 10, (argument) -> {
|
||||
return Settings.timeFormat.format(Instant.now());
|
||||
});
|
||||
|
||||
@ -53,7 +53,7 @@ public class DefaultPlaceholders {
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderFactory(plugin, "online", new OnlinePlayersPlaceholderFactory(bungeeServerTracker));
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "max_players", 20, (serverName) -> {
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, "max_players", 20, (serverName) -> {
|
||||
if (serverName == null) {
|
||||
// No argument specified, return max players of this server
|
||||
return String.valueOf(Bukkit.getMaxPlayers());
|
||||
@ -66,7 +66,7 @@ public class DefaultPlaceholders {
|
||||
return String.valueOf(bungeeServerTracker.getCurrentServerInfo(serverName).getMaxPlayers());
|
||||
});
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "status", 20, (serverName) -> {
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, "status", 20, (serverName) -> {
|
||||
if (serverName == null) {
|
||||
return NO_SERVER_SPECIFIED_ERROR;
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class DefaultPlaceholders {
|
||||
}
|
||||
});
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "motd", 20, (serverName) -> {
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, "motd", 20, (serverName) -> {
|
||||
if (serverName == null) {
|
||||
return NO_SERVER_SPECIFIED_ERROR;
|
||||
}
|
||||
@ -95,7 +95,7 @@ public class DefaultPlaceholders {
|
||||
return bungeeServerTracker.getCurrentServerInfo(serverName).getMotdLine1();
|
||||
});
|
||||
|
||||
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "motd2", 20, (serverName) -> {
|
||||
placeholderRegistry.registerGlobalPlaceholder(plugin, "motd2", 20, (serverName) -> {
|
||||
if (serverName == null) {
|
||||
return NO_SERVER_SPECIFIED_ERROR;
|
||||
}
|
||||
@ -107,11 +107,11 @@ public class DefaultPlaceholders {
|
||||
return bungeeServerTracker.getCurrentServerInfo(serverName).getMotdLine2();
|
||||
});
|
||||
|
||||
placeholderRegistry.registerIndividualPlaceholderReplacer(plugin, "player", Integer.MAX_VALUE, (player, argument) -> {
|
||||
placeholderRegistry.registerIndividualPlaceholder(plugin, "player", Integer.MAX_VALUE, (player, argument) -> {
|
||||
return player.getName();
|
||||
});
|
||||
|
||||
placeholderRegistry.registerIndividualPlaceholderReplacer(plugin, "displayName", 20, (player, argument) -> {
|
||||
placeholderRegistry.registerIndividualPlaceholder(plugin, "displayName", 20, (player, argument) -> {
|
||||
return player.getDisplayName();
|
||||
});
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Table;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholder;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderFactory;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacer;
|
||||
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.IndividualPlaceholderReplacer;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderReplacementSupplier;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.RegisteredPlaceholder;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.parsing.PlaceholderIdentifier;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.parsing.PlaceholderOccurrence;
|
||||
@ -39,9 +39,9 @@ public class PlaceholderRegistry {
|
||||
return version.get();
|
||||
}
|
||||
|
||||
public void registerIndividualPlaceholderReplacer(
|
||||
Plugin plugin, String identifier, int refreshIntervalTicks, IndividualPlaceholderReplacer placeholderReplacer) {
|
||||
registerIndividualPlaceholder(plugin, identifier, new SimpleIndividualPlaceholder(refreshIntervalTicks, placeholderReplacer));
|
||||
public void registerIndividualPlaceholder(
|
||||
Plugin plugin, String identifier, int refreshIntervalTicks, IndividualPlaceholderReplacementSupplier replacementSupplier) {
|
||||
registerIndividualPlaceholder(plugin, identifier, new SimpleIndividualPlaceholder(refreshIntervalTicks, replacementSupplier));
|
||||
}
|
||||
|
||||
public void registerIndividualPlaceholder(Plugin plugin, String identifier, IndividualPlaceholder placeholder) {
|
||||
@ -53,9 +53,9 @@ public class PlaceholderRegistry {
|
||||
registerExpansion(expansion);
|
||||
}
|
||||
|
||||
public void registerGlobalPlaceholderReplacer(
|
||||
Plugin plugin, String identifier, int refreshIntervalTicks, GlobalPlaceholderReplacer placeholderReplacer) {
|
||||
registerGlobalPlaceholder(plugin, identifier, new SimpleGlobalPlaceholder(refreshIntervalTicks, placeholderReplacer));
|
||||
public void registerGlobalPlaceholder(
|
||||
Plugin plugin, String identifier, int refreshIntervalTicks, GlobalPlaceholderReplacementSupplier replacementSupplier) {
|
||||
registerGlobalPlaceholder(plugin, identifier, new SimpleGlobalPlaceholder(refreshIntervalTicks, replacementSupplier));
|
||||
}
|
||||
|
||||
public void registerGlobalPlaceholder(Plugin plugin, String identifier, GlobalPlaceholder placeholder) {
|
||||
|
@ -6,16 +6,16 @@
|
||||
package me.filoghost.holographicdisplays.plugin.placeholder.registry;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholder;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacer;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholderReplacementSupplier;
|
||||
|
||||
class SimpleGlobalPlaceholder implements GlobalPlaceholder {
|
||||
|
||||
private final int refreshIntervalTicks;
|
||||
private final GlobalPlaceholderReplacer placeholderReplacer;
|
||||
private final GlobalPlaceholderReplacementSupplier replacementSupplier;
|
||||
|
||||
SimpleGlobalPlaceholder(int refreshIntervalTicks, GlobalPlaceholderReplacer placeholderReplacer) {
|
||||
SimpleGlobalPlaceholder(int refreshIntervalTicks, GlobalPlaceholderReplacementSupplier replacementSupplier) {
|
||||
this.refreshIntervalTicks = refreshIntervalTicks;
|
||||
this.placeholderReplacer = placeholderReplacer;
|
||||
this.replacementSupplier = replacementSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -25,7 +25,7 @@ class SimpleGlobalPlaceholder implements GlobalPlaceholder {
|
||||
|
||||
@Override
|
||||
public String getReplacement(String argument) {
|
||||
return placeholderReplacer.getReplacement(argument);
|
||||
return replacementSupplier.getReplacement(argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
package me.filoghost.holographicdisplays.plugin.placeholder.registry;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholder;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderReplacer;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderReplacementSupplier;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -14,11 +14,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
class SimpleIndividualPlaceholder implements IndividualPlaceholder {
|
||||
|
||||
private final int refreshIntervalTicks;
|
||||
private final IndividualPlaceholderReplacer placeholderReplacer;
|
||||
private final IndividualPlaceholderReplacementSupplier replacementSupplier;
|
||||
|
||||
SimpleIndividualPlaceholder(int refreshIntervalTicks, IndividualPlaceholderReplacer placeholderReplacer) {
|
||||
SimpleIndividualPlaceholder(int refreshIntervalTicks, IndividualPlaceholderReplacementSupplier replacementSupplier) {
|
||||
this.refreshIntervalTicks = refreshIntervalTicks;
|
||||
this.placeholderReplacer = placeholderReplacer;
|
||||
this.replacementSupplier = replacementSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -28,7 +28,7 @@ class SimpleIndividualPlaceholder implements IndividualPlaceholder {
|
||||
|
||||
@Override
|
||||
public String getReplacement(@NotNull Player player, @Nullable String argument) {
|
||||
return placeholderReplacer.getReplacement(player, argument);
|
||||
return replacementSupplier.getReplacement(player, argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user