Added boolean for node redirection

This commit is contained in:
themode 2021-02-10 23:09:38 +01:00
parent 2547972459
commit 12c0b604db
27 changed files with 28 additions and 29 deletions

View File

@ -92,10 +92,10 @@ public abstract class Argument<T> {
*/
@NotNull
protected static DeclareCommandsPacket.Node simpleArgumentNode(@NotNull Argument<?> argument,
boolean executable, boolean suggestion) {
boolean executable, boolean redirect, boolean suggestion) {
DeclareCommandsPacket.Node argumentNode = new DeclareCommandsPacket.Node();
argumentNode.flags = COMMAND_MANAGER.getFlag(CommandManager.NodeType.ARGUMENT, executable, false, suggestion);
argumentNode.flags = COMMAND_MANAGER.getFlag(CommandManager.NodeType.ARGUMENT, executable, redirect, suggestion);
argumentNode.name = argument.getId();
return argumentNode;

View File

@ -31,7 +31,7 @@ public class ArgumentBoolean extends Argument<Boolean> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "brigadier:bool";

View File

@ -40,7 +40,7 @@ public class ArgumentDynamicStringArray extends Argument<String[]> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, true);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, true);
argumentNode.parser = "brigadier:string";
argumentNode.properties = packetWriter -> {

View File

@ -47,7 +47,7 @@ public class ArgumentDynamicWord extends Argument<String> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, true);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, true);
final SuggestionType suggestionType = this.getSuggestionType();

View File

@ -27,7 +27,7 @@ public class ArgumentString extends Argument<String> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "brigadier:string";
argumentNode.properties = packetWriter -> {

View File

@ -1,6 +1,5 @@
package net.minestom.server.command.builder.arguments;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@ -27,7 +26,7 @@ public class ArgumentStringArray extends Argument<String[]> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "brigadier:string";
argumentNode.properties = packetWriter -> {

View File

@ -102,7 +102,7 @@ public class ArgumentWord extends Argument<String> {
return nodes;
} else {
// Can be any word, add only one argument node
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
wordConsumer.accept(argumentNode);
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -32,7 +32,7 @@ public class ArgumentColor extends Argument<ChatColor> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:color";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -71,7 +71,7 @@ public class ArgumentEntity extends Argument<EntityFinder> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:entity";
argumentNode.properties = packetWriter -> {
byte mask = 0;

View File

@ -57,7 +57,7 @@ public class ArgumentFloatRange extends ArgumentRange<FloatRange> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:float_range";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -62,7 +62,7 @@ public class ArgumentIntRange extends ArgumentRange<IntRange> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:int_range";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -66,7 +66,7 @@ public class ArgumentItemStack extends Argument<ItemStack> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:item_stack";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -42,7 +42,7 @@ public class ArgumentNbtCompoundTag extends Argument<NBTCompound> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:nbt_compound_tag";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -38,7 +38,7 @@ public class ArgumentNbtTag extends Argument<NBT> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:nbt_tag";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -61,7 +61,7 @@ public class ArgumentTime extends Argument<UpdateOption> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:time";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -19,7 +19,7 @@ public class ArgumentBlockState extends ArgumentRegistry<Block> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:block_state";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -22,7 +22,7 @@ public class ArgumentEnchantment extends ArgumentRegistry<Enchantment> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:item_enchantment";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -22,7 +22,7 @@ public class ArgumentEntityType extends ArgumentRegistry<EntityType> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:entity_summon";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -22,7 +22,7 @@ public class ArgumentParticle extends ArgumentRegistry<Particle> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:particle";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -22,7 +22,7 @@ public class ArgumentPotionEffect extends ArgumentRegistry<PotionEffect> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:mob_effect";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -44,7 +44,7 @@ public class ArgumentDouble extends ArgumentNumber<Double> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "brigadier:double";
argumentNode.properties = packetWriter -> {

View File

@ -44,7 +44,7 @@ public class ArgumentFloat extends ArgumentNumber<Float> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "brigadier:float";
argumentNode.properties = packetWriter -> {

View File

@ -35,7 +35,7 @@ public class ArgumentInteger extends ArgumentNumber<Integer> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "brigadier:integer";
argumentNode.properties = packetWriter -> {

View File

@ -35,7 +35,7 @@ public class ArgumentLong extends ArgumentNumber<Long> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
// TODO maybe use ArgumentLiteral/ArgumentWord and impose long restriction server side?

View File

@ -83,7 +83,7 @@ public class ArgumentRelativeBlockPosition extends ArgumentRelative<RelativeBloc
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:block_pos";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -71,7 +71,7 @@ public class ArgumentRelativeVec2 extends ArgumentRelative<RelativeVec> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:vec2";
return new DeclareCommandsPacket.Node[]{argumentNode};
}

View File

@ -78,7 +78,7 @@ public class ArgumentRelativeVec3 extends ArgumentRelative<RelativeVec> {
@NotNull
@Override
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false);
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
argumentNode.parser = "minecraft:vec3";
return new DeclareCommandsPacket.Node[]{argumentNode};
}