Skip to content

Commit

Permalink
flag command ex tab completion for player and npc flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 15, 2021
1 parent acaf7d0 commit 034894d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Expand Up @@ -106,7 +106,7 @@ public void sit() {
private void standInternal() {
forceUnsit(npc.getEntity());
safetyCleanup(chairLocation.clone());
npc.teleport(chairLocation.clone().add(0, 0.5, 0), PlayerTeleportEvent.TeleportCause.PLUGIN);
npc.teleport(chairLocation.clone().add(0, 0.3, 0), PlayerTeleportEvent.TeleportCause.PLUGIN);
sitting = false;
}

Expand Down
Expand Up @@ -74,13 +74,8 @@ public static InteractScriptContainer getInteractScript(NPCTag npc, PlayerTag pl
return null;
}
}
if (Debug.shouldDebug(interactScript) && showDebug) {
Debug.log(DebugElement.Spacer, null);
}
if (Debug.shouldDebug(interactScript) && showDebug) {
Debug.log("Interact script is " + interactScript.getName() + ". Current step for this script is: " + getCurrentStep(player, interactScript.getName()));
}
if (Debug.shouldDebug(interactScript) && showDebug) {
Debug.log(DebugElement.Footer, "");
}
return interactScript;
Expand Down
Expand Up @@ -15,6 +15,7 @@
import com.denizenscript.denizencore.scripts.ScriptBuilder;
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.scripts.commands.AbstractCommand;
import com.denizenscript.denizencore.scripts.commands.core.FlagCommand;
import com.denizenscript.denizencore.scripts.queues.core.InstantQueue;
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.denizencore.utilities.CoreUtilities;
Expand All @@ -25,6 +26,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.function.Consumer;

public class ExCommandHandler implements CommandExecutor, TabCompleter {

Expand Down Expand Up @@ -211,11 +213,28 @@ public List<String> onTabComplete(CommandSender sender, Command cmd, String cmdN
output.add(prefix + ":");
}
}
dcmd.addCustomTabCompletions(lowArg, (s) -> {
Consumer<String> addOne = (s) -> {
if (CoreUtilities.toLowerCase(s).startsWith(lowArg)) {
output.add(s);
}
});
};
dcmd.addCustomTabCompletions(lowArg, addOne);
if (dcmd instanceof FlagCommand) {
if (sender instanceof Player) {
for (String flagName : new PlayerTag((Player) sender).getFlagTracker().listAllFlags()) {
if (!flagName.startsWith("__")) {
addOne.accept(flagName);
}
}
}
if (Depends.citizens != null && Depends.citizens.getNPCSelector().getSelected(sender) != null) {
for (String flagName : new NPCTag(Depends.citizens.getNPCSelector().getSelected(sender)).getFlagTracker().listAllFlags()) {
if (!flagName.startsWith("__")) {
addOne.accept(flagName);
}
}
}
}
return output;
}
}

0 comments on commit 034894d

Please sign in to comment.