use of com.denizenscript.denizencore.objects.core.ScriptTag in project Denizen-For-Bukkit by DenizenScript.
the class BookScriptContainer method writeBookTo.
public ItemTag writeBookTo(ItemTag book, TagContext context) {
if (context == null) {
context = new BukkitTagContext(null, null, new ScriptTag(this));
}
// Get current ItemMeta from the book
BookMeta bookInfo = (BookMeta) book.getItemMeta();
if (contains("title", String.class)) {
String title = getString("title");
title = TagManager.tag(title, context);
bookInfo.setTitle(title);
}
if (contains("signed", String.class)) {
if (getString("signed").equalsIgnoreCase("false")) {
book.getItemStack().setType(Material.WRITABLE_BOOK);
}
}
if (contains("author", String.class)) {
String author = getString("author");
author = TagManager.tag(author, context);
bookInfo.setAuthor(author);
}
if (contains("text", List.class)) {
List<String> pages = getStringList("text");
for (String page : pages) {
page = TagManager.tag(page, context);
bookInfo.spigot().addPage(FormattedTextHelper.parse(page, ChatColor.BLACK));
}
}
book.setItemMeta(bookInfo);
return book;
}
use of com.denizenscript.denizencore.objects.core.ScriptTag in project Denizen-For-Bukkit by DenizenScript.
the class CommandScriptContainer method runTabCompleteProcedure.
public List<String> runTabCompleteProcedure(PlayerTag player, NPCTag npc, Map<String, ObjectTag> context, String[] originalArguments) {
BukkitTagContext tagContext = new BukkitTagContext(player, npc, new ScriptTag(this));
ContextSource contextSrc = null;
if (context != null) {
ContextSource.SimpleMap src = new ContextSource.SimpleMap();
src.contexts = context;
tagContext.contextSource = src;
contextSrc = src;
}
List<String> list = new ArrayList<>();
if (tabCompletionTaggables != null) {
int argCount = Math.max(originalArguments.length, 1);
String taggable = tabCompletionTaggables.get(argCount);
if (taggable == null) {
taggable = tabCompletionTaggables.get(-1);
}
if (taggable != null) {
String argLow = originalArguments.length == 0 ? "" : CoreUtilities.toLowerCase(originalArguments[originalArguments.length - 1]);
for (String value : ListTag.getListFor(TagManager.tagObject(taggable, tagContext), tagContext)) {
if (CoreUtilities.toLowerCase(value).startsWith(argLow)) {
list.add(value);
}
}
}
}
if (hasProcStyleTabComplete) {
List<ScriptEntry> entries = getEntries(new BukkitScriptEntryData(player, npc), "tab complete");
ScriptQueue queue = new InstantQueue(getName());
queue.addEntries(entries);
if (contextSrc != null) {
queue.setContextSource(contextSrc);
}
queue.start();
if (queue.determinations != null && queue.determinations.size() > 0) {
list.addAll(ListTag.getListFor(queue.determinations.getObject(0), tagContext));
}
}
return list;
}
use of com.denizenscript.denizencore.objects.core.ScriptTag in project Denizen-For-Bukkit by DenizenScript.
the class EnchantmentScriptContainer method autoTag.
public String autoTag(String value, ContextSource src) {
if (value == null) {
return null;
}
validateThread();
TagContext context = new BukkitTagContext(null, new ScriptTag(this));
context.contextSource = src;
return TagManager.tag(value, context);
}
use of com.denizenscript.denizencore.objects.core.ScriptTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityScriptHelper method setEntityScript.
/**
* Marks the entity as having been created by a specified script.
*/
public static void setEntityScript(Entity ent, String script) {
if (ent == null || ent.getUniqueId() == null || script == null) {
return;
}
ScriptTag scriptObj = ScriptTag.valueOf(script, CoreUtilities.basicContext);
if (scriptObj == null) {
Debug.echoError("Can't set entity script to '" + script + "': not a valid script!");
}
DataPersistenceHelper.setDenizenKey(ent, "entity_script", scriptObj);
return;
}
use of com.denizenscript.denizencore.objects.core.ScriptTag in project Denizen-For-Bukkit by DenizenScript.
the class FormatScriptContainer method getFormatText.
public String getFormatText(NPCTag npc, PlayerTag player) {
String text = getFormat();
if (text.contains("<text") || text.contains("<name")) {
Deprecations.pseudoTagBases.warn(this);
text = text.replace("<text>", String.valueOf((char) 0x00)).replace("<name>", String.valueOf((char) 0x04));
}
text = text.replace("<[text]>", String.valueOf((char) 0x00)).replace("<[name]>", String.valueOf((char) 0x04));
return TagManager.tag(text, new BukkitTagContext(player, npc, new ScriptTag(this))).replace("%", "%%").replace(String.valueOf((char) 0x00), "%2$s").replace(String.valueOf((char) 0x04), "%1$s");
}
Aggregations