use of com.denizenscript.denizencore.utilities.SimpleDefinitionProvider in project Denizen-For-Bukkit by DenizenScript.
the class FormatScriptContainer method getFormattedText.
public String getFormattedText(String textToReplace, NPCTag npc, PlayerTag player) {
String name = npc != null ? npc.getName() : (player != null ? player.getName() : "");
String text = getFormat();
if (text.contains("<text") || text.contains("<name")) {
Deprecations.pseudoTagBases.warn(this);
text = text.replace("<text", "<element[" + EscapeTagBase.escape(textToReplace) + "].unescaped").replace("<name", "<element[" + EscapeTagBase.escape(name) + "].unescaped");
}
BukkitTagContext context = new BukkitTagContext(player, npc, new ScriptTag(this));
context.definitionProvider = new SimpleDefinitionProvider();
context.definitionProvider.addDefinition("text", new ElementTag(textToReplace));
context.definitionProvider.addDefinition("name", new ElementTag(name));
return TagManager.tag(text, context);
}
Aggregations