1 package com.irtimaled.bbor.client.commands;
3 import com.mojang.brigadier.context.CommandContext;
4 import com.mojang.brigadier.tree.CommandNode;
5 import com.mojang.brigadier.tree.LiteralCommandNode;
6 import net.minecraft.command.CommandSource;
7 import net.minecraft.util.text.TextComponentTranslation;
10 static void feedback(CommandContext<CommandSource> context, String format, Object... values) {
11 context.getSource().sendFeedback(new TextComponentTranslation(format, values), false);
14 static boolean lastNodeIsLiteral(CommandContext<CommandSource> context, String literal) {
15 CommandNode lastNode = getLastNode(context);
16 if (lastNode instanceof LiteralCommandNode) {
17 LiteralCommandNode literalCommandNode = (LiteralCommandNode) lastNode;
18 return literalCommandNode.getLiteral().equals(literal);
23 private static CommandNode getLastNode(CommandContext<CommandSource> context) {
24 CommandNode[] nodes = context.getNodes().keySet().toArray(new CommandNode[0]);
25 return nodes[nodes.length-1];