Skip to content

Commit

Permalink
Add more location suggestion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed May 13, 2024
1 parent b023548 commit 6b73a22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ public final class LocationParser<C> implements ArgumentParser<C, Location>, Blo
} else if (bukkitSender instanceof Entity) {
originalLocation = ((Entity) bukkitSender).getLocation();
} else {
originalLocation = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
if (Bukkit.getWorlds().isEmpty()) {
// For testing
originalLocation = new Location(null, 0, 0, 0);
} else {
originalLocation = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
}
}

if (((coordinates[0].type() == LocationCoordinateType.LOCAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.bukkit.util.Vector;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.bukkit.BukkitCommandContextKeys;
import org.incendo.cloud.bukkit.parser.location.LocationParser;
import org.incendo.cloud.bukkit.util.ServerTest;
import org.incendo.cloud.context.CommandInput;
Expand Down Expand Up @@ -87,6 +88,7 @@ public boolean hasPermission(@NonNull CommandSender sender, @NonNull String perm
return true;
}
};
manager.registerCommandPreProcessor(ctx -> ctx.commandContext().store(BukkitCommandContextKeys.BUKKIT_COMMAND_SENDER, ctx.commandContext().sender()));
manager.command(
manager.commandBuilder("flag")
.flag(CommandFlag.builder("loc").withComponent(LocationParser.locationParser()).build())
Expand All @@ -103,7 +105,9 @@ static Stream<Arguments> suggestions() {
return Stream.of(
arguments("", Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")),
arguments("1 ", Arrays.asList("1 0", "1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "1 7", "1 8", "1 9")),
arguments("1 1 ", Arrays.asList("1 1 0", "1 1 1", "1 1 2", "1 1 3", "1 1 4", "1 1 5", "1 1 6", "1 1 7", "1 1 8", "1 1 9"))
arguments("1 1", Arrays.asList("1 10", "1 11", "1 12", "1 13", "1 14", "1 15", "1 16", "1 17", "1 18", "1 19")),
arguments("1 1 ", Arrays.asList("1 1 0", "1 1 1", "1 1 2", "1 1 3", "1 1 4", "1 1 5", "1 1 6", "1 1 7", "1 1 8", "1 1 9")),
arguments("1 1 1", Arrays.asList("1 1 1", "1 1 10", "1 1 11", "1 1 12", "1 1 13", "1 1 14", "1 1 15", "1 1 16", "1 1 17", "1 1 18", "1 1 19"))
);
}

Expand Down

0 comments on commit 6b73a22

Please sign in to comment.