Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<Command> getCommandsByType(List<Command> commands, CommandObject commandObject, SAILType type, boolean testPerms) {
- List<Command> toReturn = new ArrayList<>();
- //return empty if not creator.
- if (type == SAILType.CREATOR && !commandObject.user.checkIsCreator()) return toReturn;
- //get command list
- switch (type) {
- case DM:
- toReturn.addAll(commands.stream()
- .filter(c -> c.channel == ChannelSetting.FROM_DM)
- .filter(c -> {
- //only show creator commands if the user the creator.
- if (c.type == SAILType.CREATOR && commandObject.user.checkIsCreator())
- return true;
- if (c.type != SAILType.CREATOR) {
- return true;
- }
- return false;
- })
- .collect(Collectors.toList()));
- return toReturn;
- default:
- toReturn.addAll(commands.stream()
- .filter(c -> c.type == type).collect(Collectors.toList()));
- break;
- }
- toReturn.addAll(commands.stream().filter(c -> c.subCommands.size() != 0)
- .filter(c -> c.hasSubCommands(type))
- .collect(Collectors.toList()));
- if (testPerms) {
- toReturn = toReturn.stream()
- .filter(c -> c.isVisibleInType(commandObject, type))
- .collect(Collectors.toList());
- }
- if (type != SAILType.DM) {
- toReturn = toReturn.stream().filter(c -> c.channel != ChannelSetting.FROM_DM).collect(Collectors.toList());
- }
- toReturn.sort(Comparator.comparing(o -> o.names[0]));
- return toReturn;
- }
Advertisement
Add Comment
Please, Sign In to add comment