Update to JDA 4.2.0

This commit is contained in:
Alex Stewart
2021-01-02 14:50:57 -08:00
parent edaf312a93
commit 0e92eb5075
9 changed files with 136 additions and 157 deletions
+2 -2
View File
@@ -12,7 +12,6 @@
<classpathentry kind="lib" path="lib/httpclient-4.5.5.jar"/> <classpathentry kind="lib" path="lib/httpclient-4.5.5.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.4.9.jar"/> <classpathentry kind="lib" path="lib/httpcore-4.4.9.jar"/>
<classpathentry kind="lib" path="lib/WolframAlpha-1.1.jar"/> <classpathentry kind="lib" path="lib/WolframAlpha-1.1.jar"/>
<classpathentry kind="lib" path="lib/JDA-3.7.1_385-withDependencies.jar"/>
<classpathentry kind="lib" path="lib/sqlite-jdbc-3.23.1.jar"/> <classpathentry kind="lib" path="lib/sqlite-jdbc-3.23.1.jar"/>
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.25.jar"/> <classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.25.jar"/>
<classpathentry kind="lib" path="lib/twitter4j-core-4.0.7-javadoc.jar"/> <classpathentry kind="lib" path="lib/twitter4j-core-4.0.7-javadoc.jar"/>
@@ -27,6 +26,7 @@
<classpathentry kind="lib" path="lib/google-http-client-1.32.0.jar"/> <classpathentry kind="lib" path="lib/google-http-client-1.32.0.jar"/>
<classpathentry kind="lib" path="lib/google-api-services-youtube-v3-rev212-1.25.0.jar"/> <classpathentry kind="lib" path="lib/google-api-services-youtube-v3-rev212-1.25.0.jar"/>
<classpathentry kind="lib" path="lib/nanohttpd-2.3.1.jar"/> <classpathentry kind="lib" path="lib/nanohttpd-2.3.1.jar"/>
<classpathentry kind="lib" path="G:/Shared/Coding/Java/workspace/ProKitty/lib/LavaPlayerJar-1.3.50-jar-with-dependencies.jar"/> <classpathentry kind="lib" path="lib/LavaPlayerJar-1.3.50-jar-with-dependencies.jar"/>
<classpathentry kind="lib" path="H:/GallusRecovery/TempFolder/Shared/Coding/Java/workspace/ProKitty/lib/JDA-4.2.0_168-withDependencies.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
Binary file not shown.
+1 -1
View File
@@ -43,4 +43,4 @@ public class CommandChoose extends Command
res.send(String.format(LocStrings.stub("ChooseChoice"), (choices[(int) (Math.random()*choices.length)]).toString())); res.send(String.format(LocStrings.stub("ChooseChoice"), (choices[(int) (Math.random()*choices.length)]).toString()));
} }
} }
+8 -9
View File
@@ -23,15 +23,14 @@ import dataStructures.KittyRole;
import dataStructures.KittyStartupMode; import dataStructures.KittyStartupMode;
import dataStructures.KittyUser; import dataStructures.KittyUser;
import main.Main; import main.Main;
import net.dv8tion.jda.core.AccountType; import net.dv8tion.jda.api.AccountType;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.core.JDABuilder; import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.core.entities.Emote; import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.core.entities.Game; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import offline.Ref; import offline.Ref;
import utils.AdminControl; import utils.AdminControl;
//import utils.AudioUtils; //import utils.AudioUtils;
+13 -13
View File
@@ -1,13 +1,13 @@
package dataStructures; package dataStructures;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.api.JDA;
public class KittyCore public class KittyCore
{ {
public final JDA jda; public final JDA jda;
public KittyCore(JDA kitty) public KittyCore(JDA kitty)
{ {
this.jda = kitty; this.jda = kitty;
} }
} }
+5 -5
View File
@@ -3,11 +3,11 @@ package dataStructures;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.core.MessageBuilder; import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.core.events.message.guild.*; import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import utils.GlobalLog; import utils.GlobalLog;
import utils.LogFilter; import utils.LogFilter;
+100 -100
View File
@@ -1,100 +1,100 @@
package dataStructures; package dataStructures;
import java.util.List; import java.util.List;
import core.ObjectBuilderFactory; import core.ObjectBuilderFactory;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
public class UserInput public class UserInput
{ {
// Variables // Variables
public String key; public String key;
public String args; public String args;
public KittyUser [] mentions; public KittyUser [] mentions;
private boolean isValid; private boolean isValid;
public String message; public String message;
// NOTE(wisp): Designed to parse a string as it's constructed. // NOTE(wisp): Designed to parse a string as it's constructed.
// If a user enters the command "!ping some stuff here :D" // If a user enters the command "!ping some stuff here :D"
// and if the command indicator is !, then... // and if the command indicator is !, then...
// //
// key=ping // key=ping
// args=some stuff here :D // args=some stuff here :D
// //
// The CommandIndicator and spaces between the key and args are dropped. // The CommandIndicator and spaces between the key and args are dropped.
public UserInput(GuildMessageReceivedEvent event, KittyGuild guildContext) public UserInput(GuildMessageReceivedEvent event, KittyGuild guildContext)
{ {
String toParse = event.getMessage().getContentRaw(); String toParse = event.getMessage().getContentRaw();
message = toParse; message = toParse;
key = ""; key = "";
args = ""; args = "";
if(toParse.length() <= 0) if(toParse.length() <= 0)
return; return;
if(!event.getMessage().getMentionedMembers().isEmpty()) if(!event.getMessage().getMentionedMembers().isEmpty())
mentions = findMentionedUsers(event); mentions = findMentionedUsers(event);
toParse = toParse.trim(); toParse = toParse.trim();
String commandIndicator = guildContext.getCommandIndicator(); String commandIndicator = guildContext.getCommandIndicator();
if(toParse.startsWith(commandIndicator)) if(toParse.startsWith(commandIndicator))
{ {
int loc = findFirstWhitespace(toParse); int loc = findFirstWhitespace(toParse);
if(loc <= 0) if(loc <= 0)
{ {
key = toParse.substring(commandIndicator.length()).trim().toLowerCase(); key = toParse.substring(commandIndicator.length()).trim().toLowerCase();
} }
else else
{ {
key = toParse.substring(commandIndicator.length(), loc).trim().toLowerCase(); key = toParse.substring(commandIndicator.length(), loc).trim().toLowerCase();
args = toParse.substring(loc).trim(); args = toParse.substring(loc).trim();
} }
isValid = true; isValid = true;
} }
else else
{ {
isValid = false; isValid = false;
} }
} }
// Used for injecting direct commands from plugins // Used for injecting direct commands from plugins
public UserInput(String input, KittyGuild contextGuild) public UserInput(String input, KittyGuild contextGuild)
{ {
int loc = findFirstWhitespace(input); int loc = findFirstWhitespace(input);
key = input.substring(0, loc); key = input.substring(0, loc);
args = input.substring(loc); args = input.substring(loc);
isValid = true; isValid = true;
} }
public boolean isValid() public boolean isValid()
{ {
return isValid; return isValid;
} }
// Finds first whitespace in the string // Finds first whitespace in the string
private int findFirstWhitespace(String str) private int findFirstWhitespace(String str)
{ {
for (int i = 0; i < str.length(); ++i) for (int i = 0; i < str.length(); ++i)
{ {
if (Character.isWhitespace(str.charAt(i))) if (Character.isWhitespace(str.charAt(i)))
return i; return i;
} }
return -1; return -1;
} }
private KittyUser[] findMentionedUsers(GuildMessageReceivedEvent event) private KittyUser[] findMentionedUsers(GuildMessageReceivedEvent event)
{ {
List <Member> JDAMentions = event.getMessage().getMentionedMembers(); List <Member> JDAMentions = event.getMessage().getMentionedMembers();
KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()]; KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()];
for(int i = 0; i < KittyMentions.length; i ++) for(int i = 0; i < KittyMentions.length; i ++)
{ {
KittyMentions [i] = ObjectBuilderFactory.getKittyUser(event.getGuild().getId(), JDAMentions.get(i).getUser().getId()); KittyMentions [i] = ObjectBuilderFactory.getKittyUser(event.getGuild().getId(), JDAMentions.get(i).getUser().getId());
} }
return KittyMentions; return KittyMentions;
} }
} }
+2 -23
View File
@@ -1,21 +1,9 @@
package main; package main;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
import core.CharacterManager; import core.CharacterManager;
import core.CommandEnabler; import core.CommandEnabler;
import core.CommandManager; import core.CommandManager;
@@ -30,17 +18,8 @@ import dataStructures.KittyGuild;
import dataStructures.KittyUser; import dataStructures.KittyUser;
import dataStructures.Response; import dataStructures.Response;
import dataStructures.UserInput; import dataStructures.UserInput;
import net.dv8tion.jda.core.AccountType; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.audio.AudioSendHandler;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.VoiceChannel;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import net.dv8tion.jda.core.managers.AudioManager;
import offline.Ref;
import utils.GlobalLog; import utils.GlobalLog;
// http://www.slf4j.org/ - this JDA logging tool has been disabled by specifying NOP implementation. // http://www.slf4j.org/ - this JDA logging tool has been disabled by specifying NOP implementation.
+5 -4
View File
@@ -9,10 +9,11 @@ import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame; import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
import net.dv8tion.jda.core.audio.AudioSendHandler; import net.dv8tion.jda.api.audio.AudioSendHandler;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.api.entities.VoiceChannel;
import net.dv8tion.jda.core.managers.AudioManager; import net.dv8tion.jda.api.managers.AudioManager;
public class AudioUtils public class AudioUtils
{ {