added strict command matching
This commit is contained in:
1 parent
20b1470f1f
commit
5f9df1239a
3 files changed
+69
-6
No files matched your search
@@ -10,17 +10,20 @@ import net.minecraft.server.command.ServerCommandSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
|
||||
public class CommandToken
|
||||
public class CommandToken implements Comparable<CommandToken>
|
||||
{
|
||||
public String surface;
|
||||
public boolean isArgument;
|
||||
public CommandArgument type;
|
||||
|
||||
private CommandToken(String surface, CommandArgument type )
|
||||
{
|
||||
this.surface = surface;
|
||||
this.type = type;
|
||||
isArgument = type != null;
|
||||
}
|
||||
|
||||
@@ -65,4 +68,28 @@ public class CommandToken
|
||||
return literal(surface);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CommandToken that = (CommandToken) o;
|
||||
return surface.equals(that.surface) &&
|
||||
Objects.equals(type, that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(surface, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CommandToken o)
|
||||
{
|
||||
if (isArgument && !o.isArgument) return 1;
|
||||
if (!isArgument && o.isArgument) return -1;
|
||||
return surface.compareTo(o.surface);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user