This commit is contained in:
GregTCLTK 2019-12-28 13:12:10 +01:00
parent 14387062bd
commit 6e73bcb554
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67
7 changed files with 27 additions and 31 deletions

View file

@ -30,19 +30,23 @@ public class AudioManager {
AudioSourceManagers.registerRemoteSources(myManager);
}
public static Map<String, Map.Entry<AudioPlayer, TrackManager>> players = new HashMap<>();
public Map<String, Map.Entry<AudioPlayer, TrackManager>> players = new HashMap<>();
private final AudioPlayerManager myManager = new DefaultAudioPlayerManager();
public boolean hasPlayer(Guild guild) {
return players.containsKey(guild.getId());
}
public static void removePlayer(Guild g) {
public void removePlayer(Guild g) {
System.out.println(players.toString());
players.remove(g.getId());
System.out.println(players.toString());
}
public Map<String, Map.Entry<AudioPlayer, TrackManager>> getPlayers () {
return players;
}
public AudioPlayer getPlayer(Guild guild) {
AudioPlayer p;
if (hasPlayer(guild)) {

View file

@ -26,7 +26,7 @@ public class BanCommand implements Command {
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.ban.success.title",
"",
"",
"commands.moderation.ban.success.description",
victim.getUser().getName() + ".").build()).queue();
} else {
@ -74,7 +74,7 @@ public class BanCommand implements Command {
}
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.moderation.ban.success.title",
"",
"",
"commands.moderation.ban.massban.success.description",
String.valueOf(event.getMessage().getMentionedMembers().size())).build()).queue();
}

View file

@ -3,6 +3,7 @@ package com.bbn.hadder.commands.music;
import com.bbn.hadder.audio.AudioManager;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
/**
@ -17,35 +18,22 @@ public class InfoCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (new AudioManager().hasPlayer(event.getGuild())) {
event.getTextChannel().sendMessage("Ja Player is auch wieder da");
}
if (new AudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) {
event.getTextChannel().sendMessage("Joo playing track net anwesend^^").queue();
}
if (!new AudioManager().hasPlayer(event.getGuild()) || new AudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) {
event.getTextChannel().sendMessage("Shut up eyyyy du kek").queue();
} else {
if (new AudioManager().hasPlayer(event.getGuild()) && new AudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) {
AudioTrack track = new AudioManager().getPlayer(event.getGuild()).getPlayingTrack();
event.getTextChannel().sendMessage("Track Info" + String.format(QUEUE_DESCRIPTION, CD, new AudioManager().getOrNull(track.getInfo().title),
"\n\u23F1 **|>** `[ " + getTimestamp(track.getPosition()) + " / " + getTimestamp(track.getInfo().length) + " ]`",
"\n\u23F1 **|>** `[ " + new AudioManager().getTimestamp(track.getPosition()) + " / " + new AudioManager().getTimestamp(track.getInfo().length) + " ]`",
"\n" + MIC, new AudioManager().getOrNull(track.getInfo().author),
"\n\uD83C\uDFA7 **|>** " + "")).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}
}
private String getTimestamp(long milis) {
long seconds = milis / 1000;
long hours = Math.floorDiv(seconds, 3600);
seconds = seconds - (hours * 3600);
long mins = Math.floorDiv(seconds, 60);
seconds = seconds - (mins * 60);
return (hours == 0 ? "" : hours + ":") + String.format("%02d", mins) + ":" + String.format("%02d", seconds);
}
@Override
public String[] labels() {
return new String[]{"info"};
return new String[]{"info", "songinfo"};
}
@Override

View file

@ -30,7 +30,7 @@ public class LeaveCommand implements Command {
@Override
public String[] labels() {
return new String[]{"leave"};
return new String[]{"leave", "quit"};
}
@Override

View file

@ -14,7 +14,7 @@ public class StopCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (new AudioManager().hasPlayer(event.getGuild())) {
AudioManager.removePlayer(event.getGuild());
new AudioManager().players.remove(event.getGuild().getId());
new AudioManager().getPlayer(event.getGuild()).destroy();
new AudioManager().getTrackManager(event.getGuild()).purgeQueue();
event.getGuild().getAudioManager().closeAudioConnection();

View file

@ -5,6 +5,7 @@ package com.bbn.hadder.commands.owner;
*/
import com.bbn.hadder.Hadder;
import com.bbn.hadder.audio.AudioManager;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -43,6 +44,7 @@ public class EvalCommand implements Command {
engine.put("author", event.getAuthor());
engine.put("member", event.getMember());
engine.put("self", event.getGuild().getSelfMember());
engine.put("audio", new AudioManager());
ScheduledExecutorService service = Executors.newScheduledThreadPool(1);

View file

@ -84,7 +84,7 @@ commands.misc.screenshare.channel.existing.error = Hol' up
commands.misc.screenshare.channel.existing.description = There is no Voice Channel named like this. \n\nNote\: Make sure the Voice Channel is in this Guild.
commands.misc.screenshare.help.description = Shows you the link to share your screen.
commands.moderation.ban.success.title = %extra% Successfully banned %extra%
commands.moderation.ban.success.title = Successfully banned
commands.moderation.ban.success.description = I successfully baned %extra%
commands.moderation.ban.error.title = Not possible
commands.moderation.ban.myself.error.description = I can not ban myself\!
@ -203,6 +203,8 @@ commands.music.play.success.length = Length
commands.music.play.help.description = Plays a song
commands.music.stop.success.title = Successfully stopped
commands.music.stop.success.description = I successfully stopped the song.
commands.music.info.error.title = No playing track
commands.music.info.error.description = I am not playing anything at the moment
commands.music.stop.help.description = Stops the song
commands.music.queue.error.title = No queue
commands.music.queue.error.description = There are no queued songs at the moment