diff --git a/src/main/java/com/bbn/hadder/audio/AudioManager.java b/src/main/java/com/bbn/hadder/audio/AudioManager.java index 0cee6cd..f16baa2 100644 --- a/src/main/java/com/bbn/hadder/audio/AudioManager.java +++ b/src/main/java/com/bbn/hadder/audio/AudioManager.java @@ -30,19 +30,23 @@ public class AudioManager { AudioSourceManagers.registerRemoteSources(myManager); } - public static Map> players = new HashMap<>(); + public Map> 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> getPlayers () { + return players; + } + public AudioPlayer getPlayer(Guild guild) { AudioPlayer p; if (hasPlayer(guild)) { diff --git a/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java index 406d699..de948d9 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java @@ -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(); } diff --git a/src/main/java/com/bbn/hadder/commands/music/InfoCommand.java b/src/main/java/com/bbn/hadder/commands/music/InfoCommand.java index 3baeb46..f38f0ef 100644 --- a/src/main/java/com/bbn/hadder/commands/music/InfoCommand.java +++ b/src/main/java/com/bbn/hadder/commands/music/InfoCommand.java @@ -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 diff --git a/src/main/java/com/bbn/hadder/commands/music/LeaveCommand.java b/src/main/java/com/bbn/hadder/commands/music/LeaveCommand.java index eb860db..c2a0398 100644 --- a/src/main/java/com/bbn/hadder/commands/music/LeaveCommand.java +++ b/src/main/java/com/bbn/hadder/commands/music/LeaveCommand.java @@ -15,14 +15,14 @@ public class LeaveCommand implements Command { if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) { event.getGuild().getAudioManager().closeAudioConnection(); event.getTextChannel().sendMessage(event.getMessageEditor().getMessage( - MessageEditor.MessageType.INFO, - "commands.music.leave.success.title", + MessageEditor.MessageType.INFO, + "commands.music.leave.success.title", "commands.music.leave.success.description") .build()).queue(); } else { event.getTextChannel().sendMessage(event.getMessageEditor().getMessage( - MessageEditor.MessageType.WARNING, - "commands.music.leave.error.tile", + MessageEditor.MessageType.WARNING, + "commands.music.leave.error.tile", "commands.music.leave.error.description") .build()).queue(); } @@ -30,7 +30,7 @@ public class LeaveCommand implements Command { @Override public String[] labels() { - return new String[]{"leave"}; + return new String[]{"leave", "quit"}; } @Override diff --git a/src/main/java/com/bbn/hadder/commands/music/StopCommand.java b/src/main/java/com/bbn/hadder/commands/music/StopCommand.java index 33c03f9..97e8691 100644 --- a/src/main/java/com/bbn/hadder/commands/music/StopCommand.java +++ b/src/main/java/com/bbn/hadder/commands/music/StopCommand.java @@ -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(); diff --git a/src/main/java/com/bbn/hadder/commands/owner/EvalCommand.java b/src/main/java/com/bbn/hadder/commands/owner/EvalCommand.java index ca5fac2..e0f4e31 100644 --- a/src/main/java/com/bbn/hadder/commands/owner/EvalCommand.java +++ b/src/main/java/com/bbn/hadder/commands/owner/EvalCommand.java @@ -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); diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 6ff6c80..2da7c59 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -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