updated to phase out PlaceholderHook

This commit is contained in:
Sxtanna
2020-07-26 18:03:31 -04:00
parent c3e0c1fb64
commit 86002f50e6
6 changed files with 48 additions and 175 deletions

View File

@@ -1,6 +1,6 @@
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.PlaceholderHook;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
@@ -20,8 +20,9 @@ public final class CharsReplacer implements Replacer
}
@NotNull
@Override
public @NotNull String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderHook> lookup)
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup)
{
final char[] chars = text.toCharArray();
final StringBuilder builder = new StringBuilder(text.length());
@@ -142,7 +143,7 @@ public final class CharsReplacer implements Replacer
continue;
}
final PlaceholderHook placeholder = lookup.apply(identifierString);
final PlaceholderExpansion placeholder = lookup.apply(identifierString);
if (placeholder == null)
{
builder.append(closure.head).append(identifierString);

View File

@@ -1,6 +1,6 @@
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.PlaceholderHook;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
@@ -22,8 +22,9 @@ public final class RegexReplacer implements Replacer
}
@NotNull
@Override
public @NotNull String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderHook> lookup)
public String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup)
{
final Matcher matcher = pattern.matcher(text);
if (!matcher.find())
@@ -38,13 +39,13 @@ public final class RegexReplacer implements Replacer
final String identifier = matcher.group("identifier");
final String parameters = matcher.group("parameters");
final PlaceholderHook hook = lookup.apply(identifier);
if (hook == null)
final PlaceholderExpansion expansion = lookup.apply(identifier);
if (expansion == null)
{
continue;
}
final String requested = hook.onRequest(player, parameters);
final String requested = expansion.onRequest(player, parameters);
matcher.appendReplacement(builder, requested != null ? requested : matcher.group(0));
}
while (matcher.find());

View File

@@ -1,6 +1,6 @@
package me.clip.placeholderapi.replacer;
import me.clip.placeholderapi.PlaceholderHook;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -11,7 +11,7 @@ public interface Replacer
{
@NotNull
String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderHook> lookup);
String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderExpansion> lookup);
enum Closure