-
-
Notifications
You must be signed in to change notification settings - Fork 472
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
Placeholders for all roles #1511
base: develop
Are you sure you want to change the base?
Conversation
@Vankka can you re-run the build? I updated from dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR and sorry about the late response
I would prefer if the roleId logic was shared for these placeholders, the regular expression could also use groups to catch the role id and "sub placeholder". Example of what I mean:
private static final Pattern SPECIFIC_ROLE_PATTERN = Pattern.compile("role_(\\d+)_(\\w+)");
Matcher rolePlaceholderMatcher = SPECIFIC_ROLE_PATTERN.matcher(identifier);
if (rolePlaceholderMatcher.matches()) {
String roleId = rolePlaceholderMatcher.group(1);
Role role = DiscordUtil.getRole(roleId);
String subPlaceholder = rolePlaceholderMatcher.group(2);
if (subPlaceholder.equals("name")) {
...
}
}
(The above is untested code)
@@ -113,6 +113,26 @@ public class PlaceholderAPIExpansion extends PlaceholderExpansion { | |||
return String.valueOf(accountLinkManager.getLinkedAccountCount()); | |||
} | |||
|
|||
if(identifier.startsWith("role_")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(identifier.startsWith("role_")) { | |
if (identifier.startsWith("role_")) { |
Styling nitpick
Adds placeholders for all roles based on #1494 placeholders would end up being: