use of com.denizenscript.denizencore.scripts.queues.ContextSource 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;
}
Aggregations