use of gg.projecteden.nexus.models.discord.DiscordUser in project Nexus by ProjectEdenGG.
the class JoinQuit method quit.
public static void quit(Player player, QuitReason reason) {
// Denizen Discord: https://discord.com/channels/315163488085475337/315163488085475337/929117355223695360
if (!player.isOnline())
return;
if (isDuplicate(player, "quit"))
return;
String message = "&c[player] &5has left the server";
if (player.hasPermission("jq.custom") && quitMessages.size() > 0)
message = RandomUtils.randomElement(quitMessages);
final String finalMessage = message;
final String ingame = formatQuit(player, finalMessage);
final Component component = AdventureUtils.fromLegacyAmpersandText(ingame);
final Component staffComponent = AdventureUtils.fromLegacyAmpersandText(ingame + " (" + StringUtils.camelCase(reason.name()) + ")");
OnlinePlayers.getAll().forEach(_player -> {
if (!MuteMenuUser.hasMuted(_player, MuteMenuItem.JOIN_QUIT)) {
if (reason != QuitReason.DISCONNECTED && Rank.of(_player).isStaff())
_player.sendMessage(player, staffComponent, MessageType.CHAT);
else
_player.sendMessage(player, component, MessageType.CHAT);
}
});
Jingle.QUIT.playAll();
Tasks.async(() -> {
DiscordUser user = new DiscordUserService().get(player);
RoleManager.update(user);
final String discord = discordize(finalMessage).replaceAll("\\[player]", "**" + Nickname.discordOf(player) + "**");
Discord.send("<:red_arrow_left:331808021267218432> " + discord, TextChannel.BRIDGE);
});
}
use of gg.projecteden.nexus.models.discord.DiscordUser in project Nexus by ProjectEdenGG.
the class JoinQuit method join.
public static void join(Player player) {
if (isDuplicate(player, "join"))
return;
String message = "&a[player] &5has joined the server";
if (player.hasPermission("jq.custom") && joinMessages.size() > 0)
message = RandomUtils.randomElement(joinMessages);
final String finalMessage = message;
if (player.isOnline()) {
final String ingame = formatJoin(player, finalMessage);
final Component component = AdventureUtils.fromLegacyAmpersandText(ingame);
OnlinePlayers.getAll().forEach(_player -> {
if (!MuteMenuUser.hasMuted(_player, MuteMenuItem.JOIN_QUIT))
_player.sendMessage(player, component, MessageType.CHAT);
});
if (!player.hasPlayedBefore())
Jingle.FIRST_JOIN.playAll();
else
Jingle.JOIN.playAll();
Tasks.async(() -> {
DiscordUser user = new DiscordUserService().get(player);
RoleManager.update(user);
final String discord = discordize(finalMessage).replaceAll("\\[player]", "**" + Nickname.discordOf(player) + "**");
Discord.send("<:blue_arrow_right:883811353641517126> " + discord, TextChannel.BRIDGE);
});
}
}
use of gg.projecteden.nexus.models.discord.DiscordUser in project Nexus by ProjectEdenGG.
the class HandlePurchaseCommand method run.
@Path("<data...>")
void run(String data) {
Nexus.log("Purchase caught; processing... " + data);
String[] args = data.split("\\|");
Purchase purchase = Purchase.builder().id(UUID.randomUUID()).name(args[0]).uuid(UUID.fromString(uuidFormat(args[1]))).transactionId(args[2]).price(Double.parseDouble(args[3])).currency(args[4]).timestamp(LocalDateTime.parse(args[6] + " " + args[5], formatter)).email(args[7]).ip(args[8]).packageId(args[9]).packagePrice(Double.parseDouble(args[10])).packageExpiry(args[11]).packageName(args[12]).purchaserName(args[13]).purchaserUuid(UUID.fromString(uuidFormat(args[14]))).build();
String discordMessage = purchase.toDiscordString();
final ContributorService contributorService = new ContributorService();
final Contributor contributor = contributorService.get(purchase.getPurchaserUuid());
Package packageType = Package.getPackage(purchase.getPackageId());
if (packageType == null)
discordMessage += "\nPackage not recognized!";
else {
if (purchase.getPrice() > 0) {
send(purchase.getUuid(), PREFIX + "Thank you for buying &e" + purchase.getPackageName() + "&3! " + "Your contribution is &3&ogreatly &3appreciated and will be put to good use.");
if (contributor.isBroadcasts())
if (packageType == Package.CUSTOM_DONATION) {
Koda.say("Thank you for your custom donation, " + purchase.getNickname() + "! " + "We greatly appreciate your selfless contribution &4❤");
// this is not necessarily what they donated
// if they make a custom donation and purchase items at the same
// time, i have no way to break down the price from the payload
// but that is very rare, so its better than nothing i guess
contributor.giveCredit(purchase.getPrice());
} else
Koda.say("Thank you for your purchase, " + purchase.getNickname() + "! " + "Enjoy your " + purchase.getPackageName() + " perk!");
if (packageType.getCategory() == StoreCategory.BOOSTS)
send(purchase.getUuid(), PREFIX + "Make sure you activate your boost with &c/boost menu");
if (isV4Uuid(purchase.getPurchaserUuid())) {
new BadgeUserService().edit(purchase.getPurchaserUuid(), badgeUser -> badgeUser.give(Badge.SUPPORTER));
DiscordUser user = new DiscordUserService().get(purchase.getPurchaserUuid());
if (user.getUserId() != null)
Discord.addRole(user.getUserId(), Role.SUPPORTER);
else
discordMessage += "\nUser does not have a linked discord account";
}
} else {
send(purchase.getUuid(), PREFIX + "Your free " + purchase.getPackageName() + " has been successfully processed, enjoy!");
}
packageType.apply(purchase.getUuid());
discordMessage += "\nPurchase successfully processed.";
}
Discord.send(discordMessage, TextChannel.ADMIN_LOG);
contributor.add(purchase);
contributorService.save(contributor);
}
use of gg.projecteden.nexus.models.discord.DiscordUser in project Nexus by ProjectEdenGG.
the class TeamMechanic method getVoiceChannelMember.
@Nullable
public static Member getVoiceChannelMember(@NotNull OptionalPlayer hasPlayer) {
Player player = hasPlayer.getPlayer();
if (player == null)
return null;
Guild guild = Discord.getGuild();
if (guild == null)
return null;
DiscordUser discordUser = new DiscordUserService().get(player);
Member member = discordUser.getMember();
if (member == null) {
// user has no linked account, find a disc account with matching (nick)name
Optional<Member> optionalMember = guild.getMembers().stream().filter(fmember -> (fmember.getNickname() != null && fmember.getNickname().equalsIgnoreCase(Name.of(player))) || fmember.getUser().getName().equalsIgnoreCase(Name.of(player))).findAny();
if (optionalMember.isPresent())
member = optionalMember.get();
else
return null;
}
if (member.getVoiceState() == null || !member.getVoiceState().inAudioChannel())
return null;
return member;
}
use of gg.projecteden.nexus.models.discord.DiscordUser in project Nexus by ProjectEdenGG.
the class BridgeCommand method updateRoleColors.
@Async
@Path("updateRoleColors <rank>")
void updateRoleColors(Rank rank) {
int updated = 0;
for (DiscordUser user : service.getAll()) {
if (user.getRoleId() == null || user.getUuid() == null)
continue;
Rank playerRank = Rank.of(user);
if (playerRank != rank)
continue;
net.dv8tion.jda.api.entities.Role role = Discord.getGuild().getRoleById(user.getRoleId());
if (role == null)
continue;
role.getManager().setColor(rank.getDiscordColor()).queue();
++updated;
}
send("Updated " + updated + " roles");
}
Aggregations