mirror of
https://github.com/filoghost/ChestCommands.git
synced 2025-02-16 11:31:23 +01:00
Rename variables and methods
This commit is contained in:
parent
ba83229ca4
commit
612c9bb329
@ -21,24 +21,24 @@ import java.util.List;
|
||||
public class PlaceholderManager {
|
||||
|
||||
private static final List<StaticPlaceholder> staticPlaceholders = new ArrayList<>();
|
||||
private static final PlaceholderRegistry relativePlaceholderRegistry = new PlaceholderRegistry();
|
||||
private static final PlaceholderRegistry dynamicPlaceholderRegistry = new PlaceholderRegistry();
|
||||
private static final PlaceholderCache placeholderCache = new PlaceholderCache();
|
||||
static {
|
||||
for (DefaultPlaceholder placeholder : DefaultPlaceholder.values()) {
|
||||
relativePlaceholderRegistry.registerInternalPlaceholder(placeholder.getIdentifier(), placeholder.getReplacer());
|
||||
dynamicPlaceholderRegistry.registerInternalPlaceholder(placeholder.getIdentifier(), placeholder.getReplacer());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasRelativePlaceholders(List<String> list) {
|
||||
public static boolean hasDynamicPlaceholders(List<String> list) {
|
||||
for (String element : list) {
|
||||
if (hasRelativePlaceholders(element)) {
|
||||
if (hasDynamicPlaceholders(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasRelativePlaceholders(String text) {
|
||||
public static boolean hasDynamicPlaceholders(String text) {
|
||||
if (new PlaceholderScanner(text).anyMatch(PlaceholderManager::isValidPlaceholder)) {
|
||||
return true;
|
||||
}
|
||||
@ -50,7 +50,7 @@ public class PlaceholderManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String replaceRelativePlaceholders(String text, Player player) {
|
||||
public static String replaceDynamicPlaceholders(String text, Player player) {
|
||||
text = new PlaceholderScanner(text).replace(match -> getReplacement(match, player));
|
||||
|
||||
if (PlaceholderAPIHook.INSTANCE.isEnabled()) {
|
||||
@ -65,7 +65,7 @@ public class PlaceholderManager {
|
||||
}
|
||||
|
||||
private static @Nullable String getReplacement(PlaceholderMatch placeholderMatch, Player player) {
|
||||
Placeholder placeholder = relativePlaceholderRegistry.getPlaceholder(placeholderMatch);
|
||||
Placeholder placeholder = dynamicPlaceholderRegistry.getPlaceholder(placeholderMatch);
|
||||
|
||||
if (placeholder == null) {
|
||||
return null; // Placeholder not found
|
||||
@ -117,14 +117,14 @@ public class PlaceholderManager {
|
||||
checkIdentifierArgument(identifier);
|
||||
Preconditions.notNull(placeholderReplacer, "placeholderReplacer");
|
||||
|
||||
relativePlaceholderRegistry.registerExternalPlaceholder(plugin, identifier, placeholderReplacer);
|
||||
dynamicPlaceholderRegistry.registerExternalPlaceholder(plugin, identifier, placeholderReplacer);
|
||||
}
|
||||
|
||||
public static boolean unregisterPluginPlaceholder(Plugin plugin, String identifier) {
|
||||
Preconditions.notNull(plugin, "plugin");
|
||||
checkIdentifierArgument(identifier);
|
||||
|
||||
return relativePlaceholderRegistry.unregisterExternalPlaceholder(plugin, identifier);
|
||||
return dynamicPlaceholderRegistry.unregisterExternalPlaceholder(plugin, identifier);
|
||||
}
|
||||
|
||||
private static void checkIdentifierArgument(String identifier) {
|
||||
|
@ -25,12 +25,12 @@ public class PlaceholderString {
|
||||
private PlaceholderString(String originalString) {
|
||||
this.originalString = originalString;
|
||||
this.stringWithStaticPlaceholders = PlaceholderManager.replaceStaticPlaceholders(originalString);
|
||||
this.hasDynamicPlaceholders = PlaceholderManager.hasRelativePlaceholders(stringWithStaticPlaceholders);
|
||||
this.hasDynamicPlaceholders = PlaceholderManager.hasDynamicPlaceholders(stringWithStaticPlaceholders);
|
||||
}
|
||||
|
||||
public String getValue(Player player) {
|
||||
if (hasDynamicPlaceholders) {
|
||||
return PlaceholderManager.replaceRelativePlaceholders(stringWithStaticPlaceholders, player);
|
||||
return PlaceholderManager.replaceDynamicPlaceholders(stringWithStaticPlaceholders, player);
|
||||
} else {
|
||||
return stringWithStaticPlaceholders;
|
||||
}
|
||||
|
@ -6,11 +6,12 @@
|
||||
package me.filoghost.chestcommands.placeholder;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.collection.CollectionUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlaceholderStringList {
|
||||
|
||||
private final ImmutableList<String> originalList;
|
||||
@ -29,7 +30,7 @@ public class PlaceholderStringList {
|
||||
this.listWithStaticPlaceholders = originalList;
|
||||
}
|
||||
|
||||
this.hasDynamicPlaceholders = PlaceholderManager.hasRelativePlaceholders(listWithStaticPlaceholders);
|
||||
this.hasDynamicPlaceholders = PlaceholderManager.hasDynamicPlaceholders(listWithStaticPlaceholders);
|
||||
if (hasDynamicPlaceholders) {
|
||||
this.placeholderStringList = CollectionUtils.transformImmutable(listWithStaticPlaceholders, PlaceholderString::of);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user