mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-24 17:11:58 +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
|
@NotNull
|
||||||
protected static DeclareCommandsPacket.Node simpleArgumentNode(@NotNull Argument<?> argument,
|
protected static DeclareCommandsPacket.Node simpleArgumentNode(@NotNull Argument<?> argument,
|
||||||
boolean executable, boolean suggestion) {
|
boolean executable, boolean redirect, boolean suggestion) {
|
||||||
DeclareCommandsPacket.Node argumentNode = new DeclareCommandsPacket.Node();
|
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();
|
argumentNode.name = argument.getId();
|
||||||
|
|
||||||
return argumentNode;
|
return argumentNode;
|
||||||
|
@ -31,7 +31,7 @@ public class ArgumentBoolean extends Argument<Boolean> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "brigadier:bool";
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class ArgumentDynamicStringArray extends Argument<String[]> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "brigadier:string";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
|
@ -47,7 +47,7 @@ public class ArgumentDynamicWord extends Argument<String> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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();
|
final SuggestionType suggestionType = this.getSuggestionType();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class ArgumentString extends Argument<String> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "brigadier:string";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.minestom.server.command.builder.arguments;
|
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 net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -27,7 +26,7 @@ public class ArgumentStringArray extends Argument<String[]> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "brigadier:string";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
|
@ -102,7 +102,7 @@ public class ArgumentWord extends Argument<String> {
|
|||||||
return nodes;
|
return nodes;
|
||||||
} else {
|
} else {
|
||||||
// Can be any word, add only one argument node
|
// 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);
|
wordConsumer.accept(argumentNode);
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class ArgumentColor extends Argument<ChatColor> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:color";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class ArgumentEntity extends Argument<EntityFinder> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "minecraft:entity";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
byte mask = 0;
|
byte mask = 0;
|
||||||
|
@ -57,7 +57,7 @@ public class ArgumentFloatRange extends ArgumentRange<FloatRange> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:float_range";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class ArgumentIntRange extends ArgumentRange<IntRange> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:int_range";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class ArgumentItemStack extends Argument<ItemStack> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:item_stack";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class ArgumentNbtCompoundTag extends Argument<NBTCompound> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:nbt_compound_tag";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class ArgumentNbtTag extends Argument<NBT> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:nbt_tag";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class ArgumentTime extends Argument<UpdateOption> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:time";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class ArgumentBlockState extends ArgumentRegistry<Block> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:block_state";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ArgumentEnchantment extends ArgumentRegistry<Enchantment> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:item_enchantment";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ArgumentEntityType extends ArgumentRegistry<EntityType> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:entity_summon";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ArgumentParticle extends ArgumentRegistry<Particle> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:particle";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ArgumentPotionEffect extends ArgumentRegistry<PotionEffect> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:mob_effect";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class ArgumentDouble extends ArgumentNumber<Double> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "brigadier:double";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
|
@ -44,7 +44,7 @@ public class ArgumentFloat extends ArgumentNumber<Float> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "brigadier:float";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
|
@ -35,7 +35,7 @@ public class ArgumentInteger extends ArgumentNumber<Integer> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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.parser = "brigadier:integer";
|
||||||
argumentNode.properties = packetWriter -> {
|
argumentNode.properties = packetWriter -> {
|
||||||
|
@ -35,7 +35,7 @@ public class ArgumentLong extends ArgumentNumber<Long> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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?
|
// TODO maybe use ArgumentLiteral/ArgumentWord and impose long restriction server side?
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class ArgumentRelativeBlockPosition extends ArgumentRelative<RelativeBloc
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:block_pos";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class ArgumentRelativeVec2 extends ArgumentRelative<RelativeVec> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:vec2";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class ArgumentRelativeVec3 extends ArgumentRelative<RelativeVec> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclareCommandsPacket.Node[] toNodes(boolean executable) {
|
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";
|
argumentNode.parser = "minecraft:vec3";
|
||||||
return new DeclareCommandsPacket.Node[]{argumentNode};
|
return new DeclareCommandsPacket.Node[]{argumentNode};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user