Skip to content

Commit

Permalink
add loaderType argument to /bcl list all
Browse files Browse the repository at this point in the history
  • Loading branch information
leelawd committed Mar 6, 2018
1 parent b0cbee1 commit 5afbaa1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ public void register() {
.permission(Permissions.COMMAND_CHUNKS + ".base")
.build();

// /bcl list all
// /bcl list all [type]
CommandSpec cmdListAll = CommandSpec.builder()
.executor(new ListAll(this.plugin))
.arguments(GenericArguments.optional(GenericArguments.choices(Text.of("type"), loaderType)))
.permission(Permissions.COMMAND_LIST + ".all")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public ListAll(BetterChunkLoader plugin) {

@Override
public CommandResult execute(CommandSource sender, CommandContext commandContext) throws CommandException {
Optional<String> loaderTypeOp = commandContext.<String>getOne("type");

List<ChunkLoader> chunkLoaders = new ArrayList<>();

for (World world : Sponge.getServer().getWorlds()) {
Expand All @@ -42,7 +44,16 @@ public CommandResult execute(CommandSource sender, CommandContext commandContext

List<Text> readableCLs = new ArrayList<>();
for(ChunkLoader chunkLoader : chunkLoaders) {
readableCLs.add(getReadableChunkLoader(chunkLoader, sender));
if (loaderTypeOp.isPresent()) {
String loaderType = loaderTypeOp.get();
if (loaderType.equalsIgnoreCase("alwayson") && chunkLoader.isAlwaysOn()) {
readableCLs.add(getReadableChunkLoader(chunkLoader, sender));
} else if (loaderType.equalsIgnoreCase("online") && !chunkLoader.isAlwaysOn()) {
readableCLs.add(getReadableChunkLoader(chunkLoader, sender));
}
} else {
readableCLs.add(getReadableChunkLoader(chunkLoader, sender));
}
}
if (readableCLs.isEmpty()) {
readableCLs.add(Utilities.parseMessage(plugin.getConfig().getMessages().commands.list.noChunkLoadersFound));
Expand Down

0 comments on commit 5afbaa1

Please sign in to comment.