Skip to content

Commit

Permalink
Update dependencies and JDA
Browse files Browse the repository at this point in the history
  • Loading branch information
mattboy9921 committed Jan 18, 2024
1 parent 6e27e88 commit fcdb4f6
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 58 deletions.
33 changes: 19 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>net.mattlabs.mauvelist</groupId>
<artifactId>MauveList</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>

<description>
Greylist plugin for deleting user data files/adding new members
Expand Down Expand Up @@ -76,20 +76,20 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- For ACF -->
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.5.1-SNAPSHOT</version>
</dependency>
<!-- For Vault -->
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
<!-- For Configurate -->
Expand All @@ -102,30 +102,30 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version>
<version>4.15.0</version>
</dependency>
<!-- For DiscordSRV -->
<dependency>
<groupId>com.discordsrv</groupId>
<artifactId>discordsrv</artifactId>
<version>1.25.0</version>
<version>1.27.0</version>
<scope>provided</scope>
</dependency>
<!-- For JDA -->
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.2</version>
<version>5.0.0-beta.19</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -163,10 +163,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
Expand All @@ -183,7 +183,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.5.0</version>

<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
Expand All @@ -197,6 +197,11 @@
<pattern>co.aikar.locales</pattern>
<shadedPattern>net.mattlabs.mauvelist.locales</shadedPattern>
</relocation>
<!-- Configurate -->
<relocation>
<pattern>org.spongepowered.configurate</pattern>
<shadedPattern>net.mattlabs.mauvelist.configurate</shadedPattern>
</relocation>
<!-- ConfigManager -->
<relocation>
<pattern>net.mattlabs.configmanager</pattern>
Expand Down Expand Up @@ -259,7 +264,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<version>3.1.0</version>
<executions>
<execution>
<id>copy</id>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/mattlabs/mauvelist/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public String getApplicationIntroduction() {
}

@Comment("\nThe application questions (\"What is your Minecraft username?\" is asked by default and does not need to be added here)")
private ArrayList<String> questions = new ArrayList(Arrays.asList("Question one?", "Question two?", "Question three?"));
private ArrayList<String> questions = new ArrayList<>(Arrays.asList("Question one?", "Question two?", "Question three?"));

public ArrayList<String> getQuestions() {
ArrayList<String> allQuestions = new ArrayList<>(questions);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/mattlabs/mauvelist/MauveList.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import javax.security.auth.login.LoginException;
import java.io.File;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -94,7 +93,7 @@ public void onEnable() {
// Set Up JDA
try {
jda = JDABuilder.createDefault(config.getBotToken()).setStatus(getOnlineStatusFromString(config.getBotStatus())).build();
} catch (LoginException e) {
} catch (Exception e) {
e.printStackTrace();
this.setEnabled(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.mattlabs.mauvelist.MauveList;
import net.mattlabs.mauvelist.util.PlayerManager;
import net.mattlabs.mauvelist.util.PlayerUtils;
Expand Down Expand Up @@ -46,12 +46,12 @@ public void onAdd(CommandSender commandSender, String name, String discordID) {
@Description("Sends the application message to the relavent channel.")
public void onApplyButton() {
if (mauveList.getConfigML().isEnableDiscord()) {
MessageBuilder builder = new MessageBuilder();
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle(mauveList.getConfigML().getApplyTitle())
.setDescription(mauveList.getConfigML().getApplyBody())
.setColor(2664261)
.build());
builder.setActionRows(ActionRow.of(Button.success("apply", "Apply")));
builder.setComponents(ActionRow.of(Button.success("apply", "Apply")));
mauveList.getJda().getTextChannelById(mauveList.getConfigML().getApplyChannel()).sendMessage(builder.build()).queue();
mauveList.getLogger().info("Apply message has been sent.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.mattlabs.mauvelist.listeners;


import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.events.interaction.ButtonClickEvent;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.mattlabs.mauvelist.MauveList;
Expand All @@ -13,7 +13,7 @@ public class JDAListener extends ListenerAdapter {
private ApplicationManager applicationManager = MauveList.getInstance().getApplicationManager();

@Override
public void onButtonClick(ButtonClickEvent event) {
public void onButtonInteraction(ButtonInteractionEvent event) {
if (event.getButton().getId().equals("apply")) {
event.deferEdit().queue();
applicationManager.create(event.getUser(), event.getInteraction());
Expand Down
62 changes: 31 additions & 31 deletions src/main/java/net/mattlabs/mauvelist/messaging/Messages.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.mattlabs.mauvelist.messaging;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
Expand Down Expand Up @@ -81,55 +81,55 @@ public Component reloaded() {

// Discord Messages

public Message applicationUserIntro() {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationUserIntro() {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle(mauveList.getConfigML().getApplyTitle())
.setDescription(mauveList.getConfigML().getApplicationIntroduction())
.setColor(2664261)
.build());
builder.setActionRows(ActionRow.of(Button.success("applicationStart", "Start Application"), Button.danger("cancel", "Cancel")));
builder.setComponents(ActionRow.of(Button.success("applicationStart", "Start Application"), Button.danger("cancel", "Cancel")));
return builder.build();
}

public Message applicationUserQuestion(String question) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationUserQuestion(String question) {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle(question)
.setColor(161240)
.build());
return builder.build();
}

public Message applicationUserSkin(String username) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationUserSkin(String username) {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle("Your Minecraft username is: `" + username + "`")
.setDescription("Is the skin below your Minecraft skin?")
.setImage("https://crafatar.com/renders/body/" + Bukkit.getOfflinePlayer(username).getUniqueId() + "?overlay")
.setFooter("Please choose an option below.")
.setColor(161240)
.build());
builder.setActionRows(ActionRow.of(Button.success("acceptSkin", "This is me"), Button.danger("rejectSkin", "This is not me")));
builder.setComponents(ActionRow.of(Button.success("acceptSkin", "This is me"), Button.danger("rejectSkin", "This is not me")));
return builder.build();
}

public Message applicationError(String message) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationError(String message) {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle("*" + message + "*")
.setColor(14242639)
.build());
return builder.build();
}

public Message applicationUserComplete() {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationUserComplete() {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle(mauveList.getConfigML().getApplyTitle())
.setDescription(mauveList.getConfigML().getApplicationCompletion())
.setColor(2664261)
.build());
return builder.build();
}

public Message application(User user, ArrayList<String> answers) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData application(User user, ArrayList<String> answers) {
MessageCreateBuilder builder = new MessageCreateBuilder();

long epoch = System.currentTimeMillis() / 1000;
String description = "**@here, " + user.getName() + " has applied for the server. Here is their application:**\n\n" +
Expand All @@ -150,13 +150,13 @@ public Message application(User user, ArrayList<String> answers) {
.setColor(161240)
.build());

builder.setActionRows(ActionRow.of(Button.primary("applicationAccept:" + user.getId(), "Accept"), Button.secondary("applicationReject:" + user.getId(), "Reject")));
builder.setComponents(ActionRow.of(Button.primary("applicationAccept:" + user.getId(), "Accept"), Button.secondary("applicationReject:" + user.getId(), "Reject")));
return builder.build();
}

public Message applicationAccepted(User user, String minecraftUsername, User acceptor) {
public MessageCreateData applicationAccepted(User user, String minecraftUsername, User acceptor) {
long epoch = System.currentTimeMillis() / 1000;
MessageBuilder builder = new MessageBuilder();
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setAuthor("Application accepted for " + user.getName() + " ✅", null, user.getAvatarUrl())
.setDescription("`" + minecraftUsername + "` is now a member.\n\n" +
"Accepted by " + acceptor.getAsMention() + " on <t:" + epoch + ":F> *(<t:" + epoch + ":R>)*.")
Expand All @@ -165,18 +165,18 @@ public Message applicationAccepted(User user, String minecraftUsername, User acc
return builder.build();
}

public Message applicationRejectReason(User user) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationRejectReason(User user) {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setAuthor("What is the reason for rejecting " + user.getName() + "?", null, user.getAvatarUrl())
.setColor(14242639)
.build());
builder.setActionRows(ActionRow.of(Button.secondary("rejectNoReason:" + user.getId(), "No Reason")));
builder.setComponents(ActionRow.of(Button.secondary("rejectNoReason:" + user.getId(), "No Reason")));
return builder.build();
}

public Message applicationRejected(User user, String minecraftUsername, User rejector, String reason) {
public MessageCreateData applicationRejected(User user, String minecraftUsername, User rejector, String reason) {
long epoch = System.currentTimeMillis() / 1000;
MessageBuilder builder = new MessageBuilder();
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setAuthor("Application rejected for " + user.getName() + " ⛔", null, user.getAvatarUrl())
.setDescription("`" + minecraftUsername + "` will not be added as a member, application discarded.\n\n" +
"Reason: " + reason + "\n\n" +
Expand All @@ -186,17 +186,17 @@ public Message applicationRejected(User user, String minecraftUsername, User rej
return builder.build();
}

public Message applicationUserAccepted() {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationUserAccepted() {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle(mauveList.getConfigML().getApplyTitle())
.setDescription(mauveList.getConfigML().getAccepted())
.setColor(2664261)
.build());
return builder.build();
}

public Message applicationUserRejected(String reason) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationUserRejected(String reason) {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle(mauveList.getConfigML().getApplyTitle())
.setDescription(mauveList.getConfigML().getRejected() +
"\n\nReason: " + reason)
Expand All @@ -205,8 +205,8 @@ public Message applicationUserRejected(String reason) {
return builder.build();
}

public Message applicationFailed(String reason) {
MessageBuilder builder = new MessageBuilder();
public MessageCreateData applicationFailed(String reason) {
MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setEmbeds(new EmbedBuilder().setTitle("Application failed")
.setDescription("Reason: " + reason)
.setColor(14242639)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.interactions.Interaction;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonInteraction;
import net.mattlabs.mauvelist.Config;
import net.mattlabs.mauvelist.MauveList;
import net.mattlabs.mauvelist.messaging.Messages;
Expand All @@ -34,7 +34,7 @@ public class ApplicationManager {
private final Map<User, Application> applications = new HashMap<>();

// Add a new Discord user to the applications map
public void create(User user, Interaction interaction) {
public void create(User user, ButtonInteraction interaction) {
// Check if user has application
if (!hasApplication(user)) {
// Check if user has linked MC account in members group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public <T> T load(String fileName) {
}
catch (IOException e) {
MauveList.getInstance().getLogger().severe("Failed to load \"" + fileName + "\" - using a default!");
e.printStackTrace();
}
return t;
}
Expand Down

0 comments on commit fcdb4f6

Please sign in to comment.