diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ActionBarCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ActionBarCommand.java index 6683d5a737..e1b9b9484b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ActionBarCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ActionBarCommand.java @@ -105,7 +105,7 @@ public void execute(ScriptEntry scriptEntry) { } if (format != null) { - text = new ElementTag(format.getFormattedText(scriptEntry)); + text = new ElementTag(format.getFormattedText(text.asString(), scriptEntry)); } for (PlayerTag player : targets) { diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/NarrateCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/NarrateCommand.java index a1fb47c439..c20b9ee7ae 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/NarrateCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/NarrateCommand.java @@ -110,7 +110,7 @@ public void execute(ScriptEntry scriptEntry) { boolean perPlayer = perPlayerObj != null && perPlayerObj.asBoolean(); BukkitTagContext context = new BukkitTagContext(scriptEntry, false); - if (!perPlayer) { + if (!perPlayer || targets == null) { text = TagManager.tag(text, context); } @@ -124,7 +124,7 @@ public void execute(ScriptEntry scriptEntry) { FormatScriptContainer format = formatObj == null ? null : (FormatScriptContainer) formatObj.getContainer(); if (targets == null) { - Bukkit.getServer().getConsoleSender().sendMessage(format != null ? format.getFormattedText(scriptEntry) : text); + Bukkit.getServer().getConsoleSender().sendMessage(format != null ? format.getFormattedText(text, scriptEntry) : text); return; } @@ -134,7 +134,7 @@ public void execute(ScriptEntry scriptEntry) { if (perPlayer) { personalText = TagManager.tag(personalText, context); } - player.getPlayerEntity().spigot().sendMessage(FormattedTextHelper.parse(format != null ? format.getFormattedText(scriptEntry) : personalText)); + player.getPlayerEntity().spigot().sendMessage(FormattedTextHelper.parse(format != null ? format.getFormattedText(personalText, scriptEntry) : personalText)); } else { Debug.echoError("Narrated to non-existent or offline player!"); diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/server/AnnounceCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/server/AnnounceCommand.java index 632ac4508d..45b0508dcc 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/server/AnnounceCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/server/AnnounceCommand.java @@ -125,7 +125,7 @@ public void execute(ScriptEntry scriptEntry) { + (flag != null ? ArgumentHelper.debugObj("Flag_Name", flag) : "")); } - String message = format != null ? format.getFormattedText(scriptEntry) : text.asString(); + String message = format != null ? format.getFormattedText(text.asString(), scriptEntry) : text.asString(); // Use Bukkit to broadcast the message to everybody in the server. if (type == AnnounceType.ALL) { diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/containers/core/FormatScriptContainer.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/containers/core/FormatScriptContainer.java index 6e6b8c6354..ee5d973740 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/containers/core/FormatScriptContainer.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/containers/core/FormatScriptContainer.java @@ -1,6 +1,6 @@ package com.denizenscript.denizen.scripts.containers.core; -import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; +import com.denizenscript.denizen.utilities.Utilities; import com.denizenscript.denizen.objects.NPCTag; import com.denizenscript.denizen.objects.PlayerTag; import com.denizenscript.denizen.tags.BukkitTagContext; @@ -39,10 +39,8 @@ public String getFormat() { return getString("format", ""); } - public String getFormattedText(ScriptEntry entry) { - return getFormattedText(entry.getElement("text").asString(), - ((BukkitScriptEntryData) entry.entryData).getNPC(), - ((BukkitScriptEntryData) entry.entryData).getPlayer()); + public String getFormattedText(String text, ScriptEntry entry) { + return getFormattedText(text, Utilities.getEntryNPC(entry), Utilities.getEntryPlayer(entry)); } public String getFormattedText(String textToReplace, NPCTag npc, PlayerTag player) {