Make relative placeholders follow global placeholders settings

This commit is contained in:
filoghost 2019-05-30 12:28:32 +02:00
parent 2a3314c95a
commit 0f0d709abe
3 changed files with 18 additions and 16 deletions

View File

@ -143,7 +143,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook {
return;
}
if (!hologramLine.hasRelativePlaceholders()) {
if (!hologramLine.getParent().isAllowPlaceholders() || !hologramLine.hasRelativePlaceholders()) {
return;
}
@ -182,7 +182,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook {
return;
}
if (!hologramLine.hasRelativePlaceholders()) {
if (!hologramLine.getParent().isAllowPlaceholders() || !hologramLine.hasRelativePlaceholders()) {
return;
}

View File

@ -35,6 +35,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention;
public class EditCommand extends HologramSubCommand {
@ -93,6 +94,19 @@ public class EditCommand extends HologramSubCommand {
HelpCommand.sendHoverTip((Player) sender);
}
}
public static void sendQuickEditCommands(Player player, String hologramName) {
player.spigot().sendMessage(new ComponentBuilder("[Quick Edit]").color(ChatColor.YELLOW).bold(true)
.append(" ", FormatRetention.NONE)
.append("[Add Line]").event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/"))
.append("hover").color(ChatColor.WHITE).italic(true).underlined(true)
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Hover on the commands to get info about them.")))
.append(" or ", FormatRetention.NONE).color(ChatColor.GRAY)
.append("click").color(ChatColor.WHITE).italic(true).underlined(true)
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Click on the commands to insert them in the chat.")))
.append(" on the commands!", FormatRetention.NONE).color(ChatColor.GRAY)
.create());
}
@Override
public List<String> getTutorial() {

View File

@ -234,21 +234,9 @@ public class CraftHologram implements Hologram, com.gmail.filoghost.holograms.ap
if (this.allowPlaceholders == allowPlaceholders) {
return;
}
for (CraftHologramLine line : lines) {
if (line instanceof CraftTextLine) {
CraftTextLine textLine = (CraftTextLine) line;
if (allowPlaceholders) {
// Now allowed, previously weren't
PlaceholdersManager.trackIfNecessary(textLine);
} else {
// Now not allowed
PlaceholdersManager.untrack(textLine);
}
}
}
this.allowPlaceholders = allowPlaceholders;
refreshAll();
}