diff --git a/src/main/java/eu/m724/tweaks/player/MusicPlayer.java b/src/main/java/eu/m724/tweaks/player/MusicPlayer.java deleted file mode 100644 index a1b475e..0000000 --- a/src/main/java/eu/m724/tweaks/player/MusicPlayer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2024 Minecon724 - * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file - * in the project root for the full license text. - */ - -package eu.m724.tweaks.player; - -import de.maxhenkel.voicechat.api.BukkitVoicechatService; -import de.maxhenkel.voicechat.api.VoicechatServerApi; -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.audiochannel.AudioPlayer; -import de.maxhenkel.voicechat.api.audiochannel.EntityAudioChannel; -import de.maxhenkel.voicechat.api.opus.OpusEncoderMode; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.UnsupportedAudioFileException; -import java.io.IOException; -import java.util.UUID; - -public class MusicPlayer { - private static final String PLAYER_CATEGORY = "music_player"; - - private VoicechatServerApi voicechat = null; - - private final Plugin plugin; - - public MusicPlayer(Plugin plugin) { - this.plugin = plugin; - } - - public void init() { - BukkitVoicechatService service = plugin.getServer().getServicesManager().load(BukkitVoicechatService.class); - service.registerPlugin(new MyVoicechatPlugin(this)); - } - - void unlock(VoicechatServerApi voicechat) { - VolumeCategory category = voicechat.volumeCategoryBuilder() - .setId(PLAYER_CATEGORY) - .setName("Music players") - .build(); - - voicechat.registerVolumeCategory(category); - - this.voicechat = voicechat; - } - - public void create(Player player) { - UUID channelID = UUID.randomUUID(); - EntityAudioChannel channel = voicechat.createEntityAudioChannel(channelID, voicechat.fromEntity(player)); - - channel.setCategory(PLAYER_CATEGORY); - channel.setDistance(10); - - short[] arr; - try { - AudioInputStream audio = AudioSystem.getAudioInputStream(plugin.getResource("music.flac")); - int samples = (int) (audio.available() / audio.getFrameLength()); - arr = new short[samples]; - for (int i=0; i