Hackily solve issue where Bukkit doesn't create a new Brigadier command per alias, so that command aliases get the full Brigadier treatment
This commit is contained in:
parent
1fede2b4c0
commit
d83690cdcf
14 changed files with 213 additions and 82 deletions
|
|
@ -531,8 +531,17 @@ public final class CommandTree<C> {
|
|||
*/
|
||||
@Nullable
|
||||
public Node<CommandArgument<C, ?>> getNamedNode(@Nullable final String name) {
|
||||
return this.getRootNodes().stream().filter(node -> node.getValue() != null
|
||||
&& node.getValue().getName().equalsIgnoreCase(name)).findAny().orElse(null);
|
||||
for (final Node<CommandArgument<C, ?>> node : this.getRootNodes()) {
|
||||
if (node.getValue() != null && node.getValue() instanceof StaticArgument) {
|
||||
final StaticArgument<C> staticArgument = (StaticArgument<C>) node.getValue();
|
||||
for (final String alias : staticArgument.getAliases()) {
|
||||
if (alias.equalsIgnoreCase(name)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>
|
|||
@Nonnull
|
||||
@Override
|
||||
public final String toString() {
|
||||
return String.format("CommandArgument{name=%s}", this.name);
|
||||
return String.format("%s{name=%s}", this.getClass().getSimpleName(), this.name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -214,6 +214,24 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
|
|||
return IntegerArgument.IntegerParser.getSuggestions(this.min, this.max, input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value
|
||||
*
|
||||
* @return Max value
|
||||
*/
|
||||
public byte getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the min value
|
||||
*
|
||||
* @return Min value
|
||||
*/
|
||||
public byte getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -204,6 +204,24 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value
|
||||
*
|
||||
* @return Max value
|
||||
*/
|
||||
public double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the min value
|
||||
*
|
||||
* @return Min value
|
||||
*/
|
||||
public double getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,25 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
|||
public boolean isContextFree() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value
|
||||
*
|
||||
* @return Max value
|
||||
*/
|
||||
public float getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the min value
|
||||
*
|
||||
* @return Min value
|
||||
*/
|
||||
public float getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -212,6 +212,24 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
|
|||
return IntegerArgument.IntegerParser.getSuggestions(this.min, this.max, input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value
|
||||
*
|
||||
* @return Max value
|
||||
*/
|
||||
public short getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the min value
|
||||
*
|
||||
* @return Min value
|
||||
*/
|
||||
public short getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -268,6 +268,16 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
|
|||
public boolean isContextFree() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string mode
|
||||
*
|
||||
* @return String mode
|
||||
*/
|
||||
@Nonnull
|
||||
public StringMode getStringMode() {
|
||||
return this.stringMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue