mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 09:57:45 +01:00
Added boolean for node redirection
This commit is contained in:
parent
2547972459
commit
12c0b604db
@ -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;
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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 -> {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 -> {
|
||||
|
@ -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 -> {
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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 -> {
|
||||
|
@ -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 -> {
|
||||
|
@ -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 -> {
|
||||
|
@ -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?
|
||||
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user