diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2019-10-27 00:38:52 -0400 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2019-10-27 00:38:52 -0400 |
commit | c50216132981a993fb827315c7c4d6fb3d5857a1 (patch) | |
tree | 2e10a70799009c3a6fe9f245e644b7c9f4a68de8 /src | |
parent | d2bb59cf2c21c5ba3000d1523bb62bb969eb38d4 (diff) | |
download | SoundChan-c50216132981a993fb827315c7c4d6fb3d5857a1.tar.gz SoundChan-c50216132981a993fb827315c7c4d6fb3d5857a1.tar.bz2 SoundChan-c50216132981a993fb827315c7c4d6fb3d5857a1.zip |
Starting work to update libraries
JDA v4 has many breaking changes that will need to be checked
Lavaplayer shouldn't have any major changes, but needs version bump to
continue working with various sites
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/soundchan/AudioPlayerSendHandler.java | 11 | ||||
-rw-r--r-- | src/main/java/soundchan/BotListener/BotListener.java | 32 | ||||
-rw-r--r-- | src/main/java/soundchan/BotListener/BotListenerHelpers.java | 6 | ||||
-rw-r--r-- | src/main/java/soundchan/LocalAudioManager.java | 2 | ||||
-rw-r--r-- | src/main/java/soundchan/Main.java | 13 |
5 files changed, 30 insertions, 34 deletions
diff --git a/src/main/java/soundchan/AudioPlayerSendHandler.java b/src/main/java/soundchan/AudioPlayerSendHandler.java index 5e174ca..fdd9774 100644 --- a/src/main/java/soundchan/AudioPlayerSendHandler.java +++ b/src/main/java/soundchan/AudioPlayerSendHandler.java @@ -2,7 +2,9 @@ package soundchan; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame; -import net.dv8tion.jda.core.audio.AudioSendHandler; +import net.dv8tion.jda.api.audio.AudioSendHandler; + +import java.nio.ByteBuffer; /** * This is a wrapper around AudioPlayer which makes it behave as an AudioSendHandler for JDA. As JDA calls canProvide @@ -30,15 +32,12 @@ public class AudioPlayerSendHandler implements AudioSendHandler { } @Override - public byte[] provide20MsAudio() { + public ByteBuffer provide20MsAudio() { if (lastFrame == null) { lastFrame = audioPlayer.provide(); } - byte[] data = lastFrame != null ? lastFrame.getData() : null; - lastFrame = null; - - return data; + return ByteBuffer.wrap(lastFrame.getData()); } @Override diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java index 4864ae2..0bd920d 100644 --- a/src/main/java/soundchan/BotListener/BotListener.java +++ b/src/main/java/soundchan/BotListener/BotListener.java @@ -7,17 +7,17 @@ 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.sun.istack.internal.NotNull; -import net.dv8tion.jda.client.events.call.voice.CallVoiceJoinEvent; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.MessageChannel; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.events.guild.voice.GuildVoiceJoinEvent; -import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; -import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent; -import net.dv8tion.jda.core.events.message.MessageReceivedEvent; -import net.dv8tion.jda.core.hooks.ListenerAdapter; -import net.dv8tion.jda.core.managers.AudioManager; + +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.entities.VoiceChannel; +import net.dv8tion.jda.api.events.guild.voice.GuildVoiceJoinEvent; +import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent; +import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.managers.AudioManager; +import org.jetbrains.annotations.NotNull; import soundchan.*; import java.nio.file.WatchEvent; @@ -109,11 +109,6 @@ public class BotListener extends ListenerAdapter{ return musicManager; } - @Override - public void onCallVoiceJoin(CallVoiceJoinEvent event){ - super.onCallVoiceJoin(event); - } - /** * Plays an audio clip when a user connects to the voice channel if enabled in the config file. For the sound to play, * there needs to be a sound file with the same name as the user, otherwise it won't play anything. @@ -195,7 +190,10 @@ public class BotListener extends ListenerAdapter{ public void onMessageReceived(MessageReceivedEvent event) { String[] command = event.getMessage().getContentRaw().split(" ", 2); - Guild guild = event.getGuild(); + Guild guild = null; + if(event.isFromGuild()) { + guild = event.getGuild(); + } MessageChannel channel = helper.GetReplyChannel(event); // If we haven't set the Monitored Guild yet, set the value diff --git a/src/main/java/soundchan/BotListener/BotListenerHelpers.java b/src/main/java/soundchan/BotListener/BotListenerHelpers.java index 98ad31a..4c589a3 100644 --- a/src/main/java/soundchan/BotListener/BotListenerHelpers.java +++ b/src/main/java/soundchan/BotListener/BotListenerHelpers.java @@ -1,8 +1,8 @@ package soundchan.BotListener; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.MessageChannel; -import net.dv8tion.jda.core.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; public class BotListenerHelpers { diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java index ea5b317..4db7010 100644 --- a/src/main/java/soundchan/LocalAudioManager.java +++ b/src/main/java/soundchan/LocalAudioManager.java @@ -1,6 +1,6 @@ package soundchan; -import net.dv8tion.jda.core.entities.MessageChannel; +import net.dv8tion.jda.api.entities.MessageChannel; import java.io.File; import java.io.FileInputStream; diff --git a/src/main/java/soundchan/Main.java b/src/main/java/soundchan/Main.java index a7aa6a3..587c7e9 100644 --- a/src/main/java/soundchan/Main.java +++ b/src/main/java/soundchan/Main.java @@ -1,8 +1,8 @@ package soundchan; -import net.dv8tion.jda.core.AccountType; -import net.dv8tion.jda.core.JDA; -import net.dv8tion.jda.core.JDABuilder; +import net.dv8tion.jda.api.AccountType; +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.JDABuilder; import soundchan.BotListener.*; import java.io.FileInputStream; @@ -17,10 +17,9 @@ public class Main { JDA jda = new JDABuilder(AccountType.BOT) .setToken(properties.getProperty("botToken")) - .buildBlocking(); - - - jda.addEventListener(new BotListener(properties)); + .addEventListeners(new BotListener(properties)) + .build(); + jda.awaitReady(); } private static Properties LoadProperties(){ |