Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
Joe | ddbf910f87 | |
Joe | 53a66fc228 | |
Joe | d88513ee49 | |
Joe | fbddc45353 | |
Joe | f60ad91478 | |
Doc | deeb688146 | |
Doc | 7bd2effa24 | |
Joe | 1e041083e1 | |
Joe | ba36db0560 |
|
@ -15,9 +15,9 @@ A simple spigot plugin which allows whitelisting through a discord text channel.
|
|||
- Can be disabled in the config (enabled by default)
|
||||
|
||||
- Discord commands:
|
||||
- Use `!whitelist add "minecraftUsername"` in a valid channel to whitelist people on your minecraft server
|
||||
- Use `!whitelist remove "minecraftUsername"` in a valid channel to remove people from the whitelist on your minecraft server
|
||||
- Use `!whitelist` in a valid channel to get info about the bot and how to use it
|
||||
- Use `/whitelist add "minecraftUsername"` in a valid channel to whitelist people on your minecraft server
|
||||
- Use `/whitelist remove "minecraftUsername"` in a valid channel to remove people from the whitelist on your minecraft server
|
||||
- Use `/whitelist` in a valid channel to get info about the bot and how to use it
|
||||
|
||||
- Custom Message Support:
|
||||
- Allows editing of server response messages (file is located at `(server-root)/plugins/DiscordWhitelister/custom-messages.yml)`
|
||||
|
|
111
pom.xml
111
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>uk.co.angrybee.joe</groupId>
|
||||
<artifactId>discord-whitelister</artifactId>
|
||||
<version>1.4.9</version>
|
||||
<version>1.5.1</version>
|
||||
|
||||
<name>discord-whitelister</name>
|
||||
<url>https://github.com/JoeShimell/DiscordWhitelisterSpigot</url>
|
||||
|
@ -22,9 +22,6 @@
|
|||
</repository>
|
||||
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>dv8tion</id>
|
||||
<name>m2-dv8tion</name>
|
||||
<url>https://m2.dv8tion.net/releases</url>
|
||||
|
@ -36,10 +33,9 @@
|
|||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<!-- EssX-->
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>https://ci.ender.zone/plugin/repository/everything</url>
|
||||
<id>essentials-releases</id>
|
||||
<url>https://repo.essentialsx.net/releases/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
@ -49,14 +45,14 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.3.0_288</version>
|
||||
<version>5.0.0-beta.19</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>club.minnced</groupId>
|
||||
|
@ -65,28 +61,40 @@
|
|||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.googlecode.json-simple</groupId>-->
|
||||
<!-- <artifactId>json-simple</artifactId>-->
|
||||
<!-- <version>1.1.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>ch.qos.logback</groupId>-->
|
||||
<!-- <artifactId>logback-classic</artifactId>-->
|
||||
<!-- <version>1.4.14</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.slf4j</groupId>-->
|
||||
<!-- <artifactId>slf4j-api</artifactId>-->
|
||||
<!-- <version>2.0.10</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.26</version>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.5.1</version>
|
||||
<type>maven-plugin</type>
|
||||
</dependency>
|
||||
|
||||
|
@ -95,27 +103,38 @@
|
|||
<groupId>com.github.LeonMangler</groupId>
|
||||
<artifactId>SuperVanish</artifactId>
|
||||
<!-- POM is invalid with java compiler ver > 8 (maven-compiler-plugin source & target version is set to 8) -->
|
||||
<!-- TODO: get updated version if/when available for better support with compiler versions > 8 -->
|
||||
<version>6.2.6</version>
|
||||
<version>fbc303bbee6e129e56b3e89c5e83e98ee2127ff2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- EssX-->
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<groupId>net.essentialsx</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<version>2.20.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- VanishNoPacket -->
|
||||
<dependency>
|
||||
<groupId>com.github.mbax</groupId>
|
||||
<artifactId>VanishNoPacket</artifactId>
|
||||
<version>0cb428ff27ced0b97b9601a3088e9b93616c907c</version>
|
||||
<version>341a9a9710848d85813f7dfdab0b606d46ab264a</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -123,54 +142,54 @@
|
|||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.2</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.12.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.3.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>4.0.0-M13</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.5.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
|
@ -203,21 +222,16 @@
|
|||
<shadedPattern>uk.co.angrybee.joe.shaded.javax.annotation</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.org.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<!-- <relocation>-->
|
||||
<!-- <pattern>org.slf4j</pattern>-->
|
||||
<!-- <shadedPattern>uk.co.angrybee.joe.shaded.org.slf4j</shadedPattern>-->
|
||||
<!-- </relocation>-->
|
||||
|
||||
<relocation>
|
||||
<pattern>org.yaml.snakeyaml</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.org.yaml.snakeyaml</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>org.json.simple</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.org.json.simple</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>org.jetbrains.annotations</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.org.jetbrains.annotations</shadedPattern>
|
||||
|
@ -277,6 +291,11 @@
|
|||
<pattern>ch.qos.logback</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.ch.qos.logback</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>com.google.code.gson</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.com.google.code.gson</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -284,7 +303,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
|
@ -307,15 +326,15 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<source>19</source>
|
||||
<target>19</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.5.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package uk.co.angrybee.joe;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -14,7 +16,7 @@ public class AuthorPermissions
|
|||
private boolean userIsBanned = false;
|
||||
private boolean userCanUseClear = false;
|
||||
|
||||
public AuthorPermissions(SlashCommandEvent event) {
|
||||
public AuthorPermissions(SlashCommandInteractionEvent event) {
|
||||
for (Role role : event.getMember().getRoles())
|
||||
{
|
||||
if(!DiscordWhitelister.useIdForRoles)
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
package uk.co.angrybee.joe;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
|
@ -19,9 +26,6 @@ import net.dv8tion.jda.api.utils.ChunkingFilter;
|
|||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import uk.co.angrybee.joe.commands.discord.*;
|
||||
import uk.co.angrybee.joe.events.ShutdownEvents;
|
||||
import uk.co.angrybee.joe.stores.UserList;
|
||||
|
@ -31,8 +35,11 @@ import javax.annotation.Nonnull;
|
|||
import javax.security.auth.login.LoginException;
|
||||
import java.awt.Color;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.RecursiveTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.dv8tion.jda.api.interactions.commands.OptionType.*;
|
||||
|
@ -94,9 +101,9 @@ public class DiscordClient extends ListenerAdapter {
|
|||
javaDiscordAPI = JDABuilder.createDefault(clientToken)
|
||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||
.setBulkDeleteSplittingEnabled(false)
|
||||
.disableCache(CacheFlag.VOICE_STATE, CacheFlag.EMOTE)
|
||||
.disableCache(CacheFlag.VOICE_STATE)
|
||||
.setContextEnabled(true)
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.MESSAGE_CONTENT)
|
||||
.setChunkingFilter(ChunkingFilter.ALL)
|
||||
.addEventListeners(new DiscordClient())
|
||||
.addEventListeners(new ShutdownEvents())
|
||||
|
@ -108,30 +115,30 @@ public class DiscordClient extends ListenerAdapter {
|
|||
CommandListUpdateAction commands = javaDiscordAPI.updateCommands();
|
||||
|
||||
commands.addCommands(
|
||||
new CommandData("whitelist", "Edit the whitelist.")
|
||||
.addSubcommands(
|
||||
new SubcommandData("add", "Add a user to the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to add", true)
|
||||
.addOption(USER, "discord_user", "Discord user to bind to", false),
|
||||
new SubcommandData("remove", "Remove user from the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to remove", true),
|
||||
new SubcommandData("clear", "Clear whitelists assigned to your account"),
|
||||
new SubcommandData("whois", "Find the Discord name linked to a Minecraft name")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft name to search", false)
|
||||
.addOption(USER, "discord_user", "Minecraft name to search", false)),
|
||||
Commands.slash("whitelist", "Edit the whitelist.")
|
||||
.addSubcommands(
|
||||
new SubcommandData("add", "Add a user to the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to add", true)
|
||||
.addOption(USER, "discord_user", "Discord user to bind to", false),
|
||||
new SubcommandData("remove", "Remove user from the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to remove", true),
|
||||
new SubcommandData("clear", "Clear whitelists assigned to your account"),
|
||||
new SubcommandData("whois", "Find the Discord name linked to a Minecraft name")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft name to search", false)
|
||||
.addOption(USER, "discord_user", "Minecraft name to search", false)),
|
||||
|
||||
new CommandData("clearname", "Clear name from all lists")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to clear", true),
|
||||
new CommandData("clearban", "Clear ban from user")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to unban", true),
|
||||
new CommandData("help", "Show bot info"))
|
||||
Commands.slash("clearname", "Clear name from all lists")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to clear", true),
|
||||
Commands.slash("clearban", "Clear ban from user")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to unban", true),
|
||||
Commands.slash("help", "Show bot info"))
|
||||
.queue();
|
||||
|
||||
// Send the new set of commands to discord, this will override any existing global commands with the new set provided here
|
||||
|
||||
|
||||
return 0;
|
||||
} catch (LoginException | InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
} catch (IllegalStateException e) {
|
||||
|
@ -314,7 +321,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSlashCommand(SlashCommandEvent event) {
|
||||
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
|
||||
|
||||
// Todo: add help: CommandInfo.ExecuteCommand(messageReceivedEvent);
|
||||
// Todo: add remove message thing
|
||||
|
@ -328,6 +335,13 @@ public class DiscordClient extends ListenerAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Arrays.asList(targetTextChannels).contains(event.getChannelId())) {
|
||||
MessageEmbed messageEmbed = CreateEmbeddedMessage("Sorry!",
|
||||
("This bot can only used in the specified channel."), EmbedMessageType.FAILURE).build();
|
||||
ReplyAndRemoveAfterSeconds(event, messageEmbed);
|
||||
return;
|
||||
}
|
||||
|
||||
String subcommand = event.getSubcommandName();
|
||||
OptionMapping mc_name_op = event.getOption("minecraft_username");
|
||||
String mc_name = null;
|
||||
|
@ -415,11 +429,14 @@ public class DiscordClient extends ListenerAdapter {
|
|||
|
||||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent messageReceivedEvent) {
|
||||
if (!messageReceivedEvent.isFromType(ChannelType.TEXT)) {
|
||||
|
||||
if(!messageReceivedEvent.isFromType(ChannelType.TEXT))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if message should be handled
|
||||
if (!Arrays.asList(targetTextChannels).contains(messageReceivedEvent.getTextChannel().getId()))
|
||||
if (!Arrays.asList(targetTextChannels).contains(messageReceivedEvent.getChannel().getId()))
|
||||
return;
|
||||
|
||||
if (messageReceivedEvent.getAuthor().getIdLong() == javaDiscordAPI.getSelfUser().getIdLong())
|
||||
|
@ -431,7 +448,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
|
||||
// TODO remove, use in command classes when complete
|
||||
User author = messageReceivedEvent.getAuthor();
|
||||
TextChannel channel = messageReceivedEvent.getTextChannel();
|
||||
TextChannel channel = messageReceivedEvent.getChannel().asTextChannel();
|
||||
|
||||
// if no commands are executed, delete the message, if enabled
|
||||
if (DiscordWhitelister.removeUnnecessaryMessages) {
|
||||
|
@ -817,27 +834,28 @@ public class DiscordClient extends ListenerAdapter {
|
|||
}
|
||||
|
||||
|
||||
public static String minecraftUsernameToUUID(String minecraftUsername) {
|
||||
URL playerURL;
|
||||
String inputStream;
|
||||
BufferedReader bufferedReader;
|
||||
public static String minecraftUsernameToUUID(String minecraftUsername)
|
||||
{
|
||||
String playerId = null;
|
||||
|
||||
String playerUUID = null;
|
||||
try
|
||||
{
|
||||
URL pURL = new URL("https://api.mojang.com/users/profiles/minecraft/" + minecraftUsername);
|
||||
URLConnection req = pURL.openConnection();
|
||||
req.connect();
|
||||
|
||||
try {
|
||||
playerURL = new URL("https://api.mojang.com/users/profiles/minecraft/" + minecraftUsername);
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(playerURL.openStream()));
|
||||
inputStream = bufferedReader.readLine();
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
JsonElement root = (JsonElement) jsonParser.parse(new InputStreamReader((InputStream) req.getContent()));
|
||||
JsonObject rootObj = root.getAsJsonObject();
|
||||
playerId = rootObj.get("id").getAsString();
|
||||
|
||||
if (inputStream != null) {
|
||||
JSONObject inputStreamObject = (JSONObject) JSONValue.parseWithException(inputStream);
|
||||
playerUUID = inputStreamObject.get("id").toString();
|
||||
}
|
||||
} catch (IOException | ParseException e) {
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return playerUUID;
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public static void ExecuteServerCommand(String command) {
|
||||
|
@ -970,7 +988,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
}
|
||||
|
||||
|
||||
public static void ReplyAndRemoveAfterSeconds(SlashCommandEvent event, MessageEmbed messageEmbed) {
|
||||
public static void ReplyAndRemoveAfterSeconds(SlashCommandInteractionEvent event, MessageEmbed messageEmbed) {
|
||||
if (DiscordWhitelister.removeUnnecessaryMessages)
|
||||
event.replyEmbeds(messageEmbed).queue(message -> message.deleteOriginal().queueAfter(DiscordWhitelister.removeMessageWaitTime, TimeUnit.SECONDS));
|
||||
else
|
||||
|
|
|
@ -21,10 +21,7 @@ import uk.co.angrybee.joe.events.EssentialsVanishEvents;
|
|||
import uk.co.angrybee.joe.events.SuperVanishEvents;
|
||||
import uk.co.angrybee.joe.events.VanishNoPacketEvents;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -82,7 +79,7 @@ public class DiscordWhitelister extends JavaPlugin {
|
|||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
essentialsPlugin = (Essentials) pluginManager.getPlugin("Essentials");
|
||||
vanishNoPacketPlugin = (VanishPlugin) pluginManager.getPlugin("VanishNoPacket");
|
||||
hasSuperVanishOrPremiumVanish = pluginManager.getPlugin("SuperVanish") != null || pluginManager.getPlugin("PremiumVanish") != null;
|
||||
hasSuperVanishOrPremiumVanish = pluginManager.isPluginEnabled("SuperVanish") || pluginManager.isPluginEnabled("PremiumVanish");
|
||||
|
||||
int initSuccess = InitBot(true);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class Utils {
|
|||
}
|
||||
|
||||
// For SuperVanish / PremiumVanish
|
||||
if(VanishAPI.getPlugin() != null) {
|
||||
if(hasSuperVanishOrPremiumVanish) {
|
||||
//getPluginLogger().info("Checking via SV if " + player.getDisplayName() + " is vanished: " + VanishAPI.isInvisible(player));
|
||||
//getPluginLogger().info("Checking via SV for list of vanished players: " + VanishAPI.getAllInvisiblePlayers());
|
||||
if(VanishAPI.isInvisible(player)) return true;
|
||||
|
|
|
@ -10,5 +10,5 @@ public class VersionInfo
|
|||
return "v." + getVersion();
|
||||
}
|
||||
|
||||
private static String version = "1.4.8";
|
||||
private static String version = "1.5.1";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
|
@ -19,10 +21,10 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class CommandAdd {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_user, Member target) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_user, Member target) {
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
Member member = event.getMember();
|
||||
|
||||
int timesWhitelisted =0;
|
||||
|
@ -260,6 +262,7 @@ public class CommandAdd {
|
|||
/* Do as much as possible off the main server thread.
|
||||
convert username into UUID to avoid depreciation and rate limits (according to https://minotar.net/) */
|
||||
String playerUUID = DiscordClient.minecraftUsernameToUUID(finalNameToAdd);
|
||||
|
||||
final boolean invalidMinecraftName = playerUUID == null;
|
||||
|
||||
/* Configure success & failure messages here instead of on the main server thread -
|
||||
|
@ -407,10 +410,10 @@ public class CommandAdd {
|
|||
});
|
||||
}
|
||||
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_user) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_user) {
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
Member member = event.getMember();
|
||||
|
||||
int timesWhitelisted =0;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package uk.co.angrybee.joe.commands.discord;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -14,11 +16,11 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
public class CommandClear {
|
||||
public static void ExecuteCommand(SlashCommandEvent event) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event) {
|
||||
// Clear whitelists for limited-whitelisters
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
|
||||
if (!DiscordWhitelister.mainConfig.getFileConfiguration().getBoolean("allow-limited-whitelisters-to-unwhitelist-self")) {
|
||||
MessageEmbed messageEmbed = DiscordClient.CreateEmbeddedMessage("This Command is disabled",
|
||||
|
|
|
@ -3,9 +3,9 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -13,11 +13,11 @@ import uk.co.angrybee.joe.stores.InGameRemovedList;
|
|||
import uk.co.angrybee.joe.stores.RemovedList;
|
||||
|
||||
public class CommandClearban {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_user) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_user) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
|
||||
|
||||
if (authorPermissions.isUserCanUseClear()) {
|
||||
|
|
|
@ -2,9 +2,8 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -14,7 +13,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class CommandClearname {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_name) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_name) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package uk.co.angrybee.joe.commands.discord;
|
||||
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
|
||||
public class CommandInfo
|
||||
{
|
||||
public static void ExecuteCommand(SlashCommandEvent event)
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event)
|
||||
{
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
|
|
|
@ -2,7 +2,8 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -17,11 +18,11 @@ import java.util.Set;
|
|||
|
||||
public class CommandRemove {
|
||||
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_name) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_name) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
Member member = event.getMember();
|
||||
|
||||
// Remove Command
|
||||
|
|
|
@ -2,28 +2,20 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.exceptions.AccountTypeException;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
import uk.co.angrybee.joe.configs.MainConfig;
|
||||
import uk.co.angrybee.joe.stores.UserList;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CommandWhoIs {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_name) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_name) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
|
||||
if (!authorPermissions.isUserCanAddRemove() && !authorPermissions.isUserCanAdd()) {
|
||||
DiscordClient.ReplyAndRemoveAfterSeconds(event, DiscordClient.CreateInsufficientPermsMessage(author));
|
||||
|
|
|
@ -3,9 +3,10 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class CommandWhoIsDiscord {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, Member target) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, Member target) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package uk.co.angrybee.joe.events;
|
||||
|
||||
import net.dv8tion.jda.api.events.ShutdownEvent;
|
||||
import net.dv8tion.jda.api.events.session.ShutdownEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.requests.CloseCode;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -13,7 +13,7 @@ public class ShutdownEvents extends ListenerAdapter
|
|||
CheckIntents(shutdownEvent.getCloseCode());
|
||||
}
|
||||
|
||||
// Check for the 'SERVER MEMBERS INTENT' and inform users if not enabled
|
||||
// Check for the 'SERVER MEMBERS INTENT' & 'MESSAGE_CONTENT' and inform users if not enabled
|
||||
private void CheckIntents(CloseCode closeCode)
|
||||
{
|
||||
if(closeCode == null)
|
||||
|
@ -22,7 +22,7 @@ public class ShutdownEvents extends ListenerAdapter
|
|||
if(closeCode == CloseCode.DISALLOWED_INTENTS)
|
||||
{
|
||||
DiscordWhitelister.getPluginLogger().severe("\u001B[31m" + "Cannot connect as this bot is not eligible to request the privileged intent 'GUILD_MEMBERS'" + "\u001B[0m");
|
||||
DiscordWhitelister.getPluginLogger().severe( "\u001B[31m" + "To fix this, please enable 'SERVER MEMBERS INTENT' located " +
|
||||
DiscordWhitelister.getPluginLogger().severe( "\u001B[31m" + "To fix this, please enable 'SERVER MEMBERS INTENT' & 'MESSAGE_CONTENT' located " +
|
||||
"at https://discord.com/developers/applications -> the application you're using to run this bot -> the button called 'bot' on the left" + "\u001B[0m");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="uk.co.angrybee.joe.shaded.ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[DiscordWhitelister] %boldCyan(%-34.-34thread) %red(%10.10X{jda.shard}) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration>
|
||||
|
||||
<configuration>
|
||||
<import class="uk.co.angrybee.joe.shaded.ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
|
||||
<import class="uk.co.angrybee.joe.shaded.ch.qos.logback.core.ConsoleAppender"/>
|
||||
|
||||
<appender name="STDOUT" class="uk.co.angrybee.joe.shaded.ch.qos.logback.core.ConsoleAppender">
|
||||
<append>true</append>
|
||||
<immediateFlush>true</immediateFlush>
|
||||
<encoder class="PatternLayoutEncoder">
|
||||
<!-- <pattern>[DiscordWhitelister] %boldCyan(%-34.-34thread) %red(%10.10X{jda.shard}) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern>-->
|
||||
<pattern>[DiscordWhitelister] %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
</configuration>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -1,5 +1,6 @@
|
|||
name: DiscordWhitelister
|
||||
version: 1.4.8
|
||||
version: 1.5.1
|
||||
api-version: 1.19
|
||||
author: Joe Shimell
|
||||
main: uk.co.angrybee.joe.DiscordWhitelister
|
||||
description: Discord Whitelister.
|
||||
|
|
Loading…
Reference in New Issue