mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Prevent role snowflakes from resolving roles with ids as names (#4983)
Fixes #4981.
This commit is contained in:
parent
2bba577567
commit
4a53cfe7ac
@ -120,6 +120,15 @@ public final class NumberUtil {
|
||||
return Integer.parseInt(sInt) > 0;
|
||||
}
|
||||
|
||||
public static boolean isNumeric(final String sNum) {
|
||||
for (final char sChar : sNum.toCharArray()) {
|
||||
if (!Character.isDigit(sChar)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport from Guava.
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import club.minnced.discord.webhook.WebhookClientBuilder;
|
||||
import club.minnced.discord.webhook.send.AllowedMentions;
|
||||
import com.earth2me.essentials.utils.DownsampleUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
@ -181,13 +182,14 @@ public final class DiscordUtil {
|
||||
final List<Role> roles = member.getRoles();
|
||||
for (String roleDefinition : roleDefinitions) {
|
||||
roleDefinition = roleDefinition.trim();
|
||||
final boolean id = NumberUtil.isNumeric(roleDefinition);
|
||||
|
||||
if (roleDefinition.equals("*") || member.getId().equals(roleDefinition)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (final Role role : roles) {
|
||||
if (role.getId().equals(roleDefinition) || role.getName().equalsIgnoreCase(roleDefinition)) {
|
||||
if (role.getId().equals(roleDefinition) || (!id && role.getName().equalsIgnoreCase(roleDefinition))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user