mirror of
https://github.com/JonasunderscoreJones/ZtereoMUSIC.git
synced 2025-10-25 13:39:19 +02:00
fix: misc fixes and cleanups
This commit is contained in:
parent
580594adaf
commit
ccbd627e20
3 changed files with 14 additions and 21 deletions
|
|
@ -2,7 +2,7 @@ package codes.ztereohype.ztereomusic.audio;
|
|||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
|
||||
//import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
|
||||
import net.dv8tion.jda.api.audio.AudioSendHandler;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
|
|||
|
|
@ -2,14 +2,10 @@ package codes.ztereohype.ztereomusic.command.commands;
|
|||
|
||||
import codes.ztereohype.ztereomusic.command.Command;
|
||||
import codes.ztereohype.ztereomusic.command.CommandMeta;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Ping implements Command {
|
||||
CommandMeta meta = new CommandMeta("ping", "A command to get pinged", new String[]{"pong", "pog"}, false, false);
|
||||
private List<String> list;
|
||||
|
||||
@Override
|
||||
public CommandMeta getMeta() {
|
||||
|
|
@ -18,7 +14,6 @@ public class Ping implements Command {
|
|||
|
||||
public void execute(MessageReceivedEvent messageEvent, String[] args) {
|
||||
messageEvent.getMessage().reply("get ping'd lolmao").queue();
|
||||
list.add("owo");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package codes.ztereohype.ztereomusic.command.commands;
|
|||
|
||||
import codes.ztereohype.ztereomusic.Bot;
|
||||
import codes.ztereohype.ztereomusic.audio.AudioPlayerSendHandler;
|
||||
import codes.ztereohype.ztereomusic.audio.TrackScheduer;
|
||||
import codes.ztereohype.ztereomusic.audio.TrackManager;
|
||||
import codes.ztereohype.ztereomusic.command.Command;
|
||||
import codes.ztereohype.ztereomusic.command.CommandMeta;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||
|
|
@ -19,8 +19,8 @@ import java.util.Objects;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Playtest implements Command {
|
||||
CommandMeta meta = new CommandMeta("playtest", "A command to test music commands", new String[]{"play"}, false, false);
|
||||
public class Play implements Command {
|
||||
CommandMeta meta = new CommandMeta("play", "Play music!", new String[]{}, false, false);
|
||||
|
||||
@Override
|
||||
public CommandMeta getMeta() {
|
||||
|
|
@ -49,7 +49,6 @@ public class Playtest implements Command {
|
|||
// check if args merged are/have url, if so try to feed it into lava, else try to youtube api the fuck out of it.
|
||||
String mergedArgs = String.join(" ", args);
|
||||
|
||||
//todo find better one
|
||||
Pattern urlPattern = Pattern.compile("^(http|https)://([a-z]+\\.[a-z]+)+/\\S+$", Pattern.CASE_INSENSITIVE);
|
||||
Matcher matchedUrls = urlPattern.matcher(mergedArgs);
|
||||
boolean urlFound = matchedUrls.find();
|
||||
|
|
@ -57,7 +56,7 @@ public class Playtest implements Command {
|
|||
String identifier;
|
||||
if (!urlFound) {
|
||||
// youtube api shit
|
||||
messageEvent.getMessage().reply("please send a link").queue();
|
||||
messageEvent.getMessage().reply("please send a youtube link").queue();
|
||||
return;
|
||||
} else {
|
||||
// set identifier to the parsed url
|
||||
|
|
@ -70,7 +69,7 @@ public class Playtest implements Command {
|
|||
It is totally fine to create them even if they are unlikely to be used,
|
||||
as they do not use any resources on their own without an active track. */
|
||||
AudioPlayer player;
|
||||
TrackScheduer trackScheduler;
|
||||
TrackManager trackManager;
|
||||
|
||||
boolean isInVC = manager.isConnected();
|
||||
boolean isInSameVC = isInVC && Objects.equals(manager.getConnectedChannel(), voiceChannel);
|
||||
|
|
@ -78,14 +77,13 @@ public class Playtest implements Command {
|
|||
if (isInSameVC && Bot.trackScheduerMap.containsKey(voiceChannel)) {
|
||||
System.out.println("Found a trackScheduler for this VC already! reusing...");
|
||||
|
||||
trackScheduler = Bot.trackScheduerMap.get(voiceChannel);
|
||||
player = trackScheduler.getPlayer();
|
||||
trackManager = Bot.trackScheduerMap.get(voiceChannel);
|
||||
player = trackManager.getPlayer();
|
||||
|
||||
player.addListener(trackScheduler);
|
||||
player.addListener(trackManager);
|
||||
|
||||
} else {
|
||||
// Maybe we don't wanna clear the whole queue when he gets kicked out?
|
||||
// idk
|
||||
if (Bot.trackScheduerMap.containsKey(voiceChannel)) {
|
||||
System.out.println("Found old trackScheduler for this channel. Cleaning it up...");
|
||||
Bot.trackScheduerMap.remove(voiceChannel);
|
||||
|
|
@ -94,25 +92,25 @@ public class Playtest implements Command {
|
|||
System.out.println("Creating a new trackScheduler...");
|
||||
|
||||
player = playerManager.createPlayer();
|
||||
trackScheduler = new TrackScheduer(player, messageChannel);
|
||||
trackManager = new TrackManager(player, messageChannel);
|
||||
|
||||
player.addListener(trackScheduler);
|
||||
player.addListener(trackManager);
|
||||
manager.setSendingHandler(new AudioPlayerSendHandler(player));
|
||||
manager.openAudioConnection(voiceChannel);
|
||||
|
||||
Bot.trackScheduerMap.put(voiceChannel, trackScheduler);
|
||||
Bot.trackScheduerMap.put(voiceChannel, trackManager);
|
||||
}
|
||||
|
||||
playerManager.loadItem(identifier, new AudioLoadResultHandler() {
|
||||
@Override
|
||||
public void trackLoaded(AudioTrack track) {
|
||||
trackScheduler.queue(track);
|
||||
trackManager.queue(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playlistLoaded(AudioPlaylist playlist) {
|
||||
for (AudioTrack track : playlist.getTracks()) {
|
||||
trackScheduler.queue(track);
|
||||
trackManager.queue(track);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue