Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Audiences to be modified after creation to filter them by either a predicate or another audience. #154

Closed
Narimm opened this issue Sep 14, 2020 · 1 comment

Comments

@Narimm
Copy link

Narimm commented Sep 14, 2020

The concept here is to minimize the need to for loop through targets to send a message to a subset of the server audience, where that subset is not provided by the existing methods in audienceProvider eg. all(), world(),server(),permission(String) etc

It would be ideal to take the provided audience and filter it either by a predicate, which as discussed might need to be platform-specific, or by another audience set.
audienceProvider.permission("some.permission", somePredicate)

or in the case of another audience set.

AudienceProvide.all().exclude(AudienceProvider.world("someworld").sendmessage()

Consideration would need to made, as to whether the implementation is better optimized than example like the for loop below.

This would avoid code like

//from a bukkit plugin 
for(Permissible perm : targets)
        {
            if(perm == except)
                continue;
            
            if(perm instanceof CommandSender && (permission == null || perm.hasPermission(permission)) && (checker == null || checker.isValid((CommandSender)perm)))
                audienceProvider.audience((CommandSender) perm).sendMessage(message);
        }
@kezz
Copy link
Member

kezz commented Sep 5, 2021

Closing this based on the merge of #365.

@kezz kezz closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants