command completion

This commit is contained in:
Sen 2025-03-26 13:27:17 +01:00
parent 4a3828e310
commit e88958e2f4
16 changed files with 66 additions and 51 deletions

View file

@ -1,5 +1,8 @@
package game.command;
import java.util.Collection;
import game.collect.Lists;
import game.world.BlockPos;
import game.world.Position;
@ -75,15 +78,15 @@ public class DoubleParser extends DefaultingParser {
return this.hasDefault() ? double.class : Double.class;
}
public String[] getCompletions(CommandEnvironment env) {
public Collection<String> getCompletions(CommandEnvironment env) {
BlockPos pos = this.defType == null ? null : env.getExecutor().getPointedPosition();
switch(this.defType) {
case X:
return pos == null ? null : new String[] {"" + pos.getX()};
return pos == null ? null : Lists.newArrayList("" + pos.getX());
case Y:
return pos == null ? null : new String[] {"" + pos.getY()};
return pos == null ? null : Lists.newArrayList("" + pos.getY());
case Z:
return pos == null ? null : new String[] {"" + pos.getZ()};
return pos == null ? null : Lists.newArrayList("" + pos.getZ());
}
return super.getCompletions(env);
}