Convert {empty} to an actual placeholder

This commit is contained in:
filoghost 2021-07-03 17:15:41 +02:00
parent 4399fd90a7
commit fca1de85e0
3 changed files with 5 additions and 10 deletions

View File

@ -59,8 +59,6 @@ public class CreateCommand extends HologramSubCommand {
if (args.length > 1) {
String text = Strings.joinFrom(" ", args, 1);
CommandValidate.check(!text.equalsIgnoreCase("{empty}"), "The first line should not be empty.");
line = hologramEditor.parseHologramLine(hologram, text);
player.sendMessage(ColorScheme.SECONDARY_DARKER + "(Change the lines with /" + context.getRootLabel()
+ " edit " + hologram.getName() + ")");

View File

@ -19,7 +19,6 @@ import org.bukkit.inventory.ItemStack;
public class HologramLineParser {
private static final String ICON_PREFIX = "icon:";
private static final String EMPTY_LINE_PLACEHOLDER = "{empty}";
public static InternalHologramLine parseLine(InternalHologram hologram, String serializedLine) throws HologramLoadException {
InternalHologramLine hologramLine;
@ -30,13 +29,7 @@ public class HologramLineParser {
hologramLine = hologram.createItemLine(icon, serializedLine);
} else {
String displayText;
if (serializedLine.trim().equalsIgnoreCase(EMPTY_LINE_PLACEHOLDER)) {
displayText = "";
} else {
displayText = DisplayFormat.apply(serializedLine);
}
String displayText = DisplayFormat.apply(serializedLine);
hologramLine = hologram.createTextLine(displayText, serializedLine);
}

View File

@ -30,6 +30,10 @@ public class DefaultPlaceholders {
HolographicDisplays plugin = HolographicDisplays.getInstance();
placeholderRegistry.unregisterAll(plugin);
placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, "empty", Integer.MAX_VALUE, (argument) -> {
return "";
});
placeholderRegistry.registerGlobalPlaceholder(plugin, "rainbow", new AnimationPlaceholder(4, toStringList(
ChatColor.RED,
ChatColor.GOLD,