Java Code Examples for net.dv8tion.jda.api.entities.Member#getEffectiveName()
The following examples show how to use
net.dv8tion.jda.api.entities.Member#getEffectiveName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MafiaPlayer.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
public String getName() { Member member = getMember(); if (member != null) { return member.getEffectiveName(); } User user = jda.getUserById(memberId); return user != null ? user.getName() : String.valueOf(memberId); }
Example 2
Source File: PrettyUtil.java From DiscordSRV with GNU General Public License v3.0 | 5 votes |
public static String beautify(User user) { if (user == null) return "<Unknown>"; Member member = DiscordSRV.getPlugin().getMainGuild().getMember(user); return member != null ? member.getEffectiveName() + " (#" + user.getId() + ")" : user.getName() + " (#" + user.getId() + ")"; }
Example 3
Source File: AuditActionBuilder.java From JuniperBot with GNU General Public License v3.0 | 4 votes |
private NamedReference getReference(Member member) { return member != null ? new NamedReference(member.getUser().getId(), member.getEffectiveName()) : null; }
Example 4
Source File: RequireLinkModule.java From DiscordSRV with GNU General Public License v3.0 | 4 votes |
private void check(String eventType, EventPriority priority, String playerName, UUID playerUuid, String ip, BiConsumer<String, String> disallow) { if (!isEnabled()) return; if (!eventType.equals(DiscordSRV.config().getString("Require linked account to play.Listener event"))) return; String requestedPriority = DiscordSRV.config().getString("Require linked account to play.Listener priority"); EventPriority targetPriority = Arrays.stream(EventPriority.values()) .filter(p -> p.name().equalsIgnoreCase(requestedPriority)) .findFirst().orElse(EventPriority.LOWEST); if (priority != targetPriority) return; try { if (getBypassNames().contains(playerName)) { DiscordSRV.debug("Player " + playerName + " is on the bypass list, bypassing linking checks"); return; } if (checkWhitelist()) { boolean whitelisted = Bukkit.getServer().getWhitelistedPlayers().stream().map(OfflinePlayer::getUniqueId).anyMatch(u -> u.equals(playerUuid)); if (whitelisted) { DiscordSRV.debug("Player " + playerName + " is bypassing link requirement, player is whitelisted"); return; } } if (Bukkit.getServer().getBannedPlayers().stream().anyMatch(p -> p.getUniqueId().equals(playerUuid))) { DiscordSRV.debug("Player " + playerName + " is banned, skipping linked check"); return; } if (Bukkit.getServer().getIPBans().stream().anyMatch(ip::equals)) { DiscordSRV.debug("Player " + playerName + " connecting with banned IP " + ip + ", skipping linked check"); return; } if (!DiscordSRV.isReady) { DiscordSRV.debug("Player " + playerName + " connecting before DiscordSRV is ready, denying login"); disallow.accept(AsyncPlayerPreLoginEvent.Result.KICK_OTHER.name(), ChatColor.translateAlternateColorCodes('&', getDiscordSRVStillStartingKickMessage())); return; } String discordId = DiscordSRV.getPlugin().getAccountLinkManager().getDiscordId(playerUuid); if (discordId == null) { Member botMember = DiscordSRV.getPlugin().getMainGuild().getSelfMember(); String botName = botMember.getEffectiveName() + "#" + botMember.getUser().getDiscriminator(); String code = DiscordSRV.getPlugin().getAccountLinkManager().generateCode(playerUuid); String inviteLink = DiscordSRV.config().getString("DiscordInviteLink"); DiscordSRV.debug("Player " + playerName + " is NOT linked to a Discord account, denying login"); disallow.accept( AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST.name(), ChatColor.translateAlternateColorCodes('&', DiscordSRV.config().getString("Require linked account to play.Not linked message")) .replace("{BOT}", botName) .replace("{CODE}", code) .replace("{INVITE}", inviteLink) ); return; } List<String> subRoleIds = DiscordSRV.config().getStringList("Require linked account to play.Subscriber role.Subscriber roles"); if (isSubRoleRequired() && !subRoleIds.isEmpty()) { int failedRoleIds = 0; int matches = 0; for (String subRoleId : subRoleIds) { if (StringUtils.isBlank(subRoleId)) { failedRoleIds++; continue; } Role role = DiscordUtil.getJda().getRoleById(subRoleId); if (role == null) { failedRoleIds++; continue; } Member member = role.getGuild().getMemberById(discordId); if (member != null && member.getRoles().contains(role)) { matches++; } } if (failedRoleIds == subRoleIds.size()) { DiscordSRV.error("Tried to authenticate " + playerName + " but no valid subscriber role IDs are found and that's a requirement; login will be denied until this is fixed."); disallow.accept(AsyncPlayerPreLoginEvent.Result.KICK_OTHER.name(), ChatColor.translateAlternateColorCodes('&', getFailedToFindRoleKickMessage())); return; } if (getAllSubRolesRequired() ? matches < subRoleIds.size() : matches == 0) { DiscordSRV.debug("Player " + playerName + " does NOT match subscriber role requirements, denying login"); disallow.accept(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST.name(), ChatColor.translateAlternateColorCodes('&', getSubscriberRoleKickMessage())); } } } catch (Exception exception) { DiscordSRV.error("Failed to check player: " + playerName); exception.printStackTrace(); disallow.accept(AsyncPlayerPreLoginEvent.Result.KICK_OTHER.name(), ChatColor.translateAlternateColorCodes('&', getUnknownFailureKickMessage())); } }