mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 13:30:24 +05:00
@@ -28,6 +28,9 @@ dependencies {
|
||||
|
||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||
|
||||
implementation 'org.jflac:jflac-codec:1.5.2'
|
||||
shadow 'org.jflac:jflac-codec:1.5.2'
|
||||
|
||||
// To use this dependency, you need to compile bukkit by yourself
|
||||
// See https://www.spigotmc.org/wiki/buildtools/
|
||||
// implementation "org.bukkit:craftbukkit:${bukkit_version}"
|
||||
@@ -60,4 +63,4 @@ shadowJar {
|
||||
classifier 'shadow-dev'
|
||||
//relocate 'javazoom', "me.navoei.${mod_id}.javazoom"
|
||||
//relocate 'org.tritonus', "me.navoei.${mod_id}.tritonus"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ A Paper fork of henkelmax's Audio Player.
|
||||
- Play custom music discs using the Simple Voice Chat API. (The voice chat mod is required on the client and server.)
|
||||
- Use ```/customdisc``` or ```/cd``` to create a custom disc.
|
||||
- Music files should go into ```plugins/CustomDiscs/musicdata/```
|
||||
- Music files must be in the ```.wav``` or ```.mp3``` format.
|
||||
- Music files must be in the ```.wav```, ```.flac```, or ```.mp3``` format.
|
||||
- Only custom discs are compatible with hoppers.
|
||||
|
||||
Permission Nodes (Required to run the commands. Playing discs does not require a permission.):
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jflac.sound.spi.Flac2PcmAudioInputStream;
|
||||
import org.jflac.sound.spi.FlacAudioFileReader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.sound.sampled.*;
|
||||
@@ -121,6 +123,12 @@ public class PlayerManager {
|
||||
AudioInputStream convertedInputStream = new MpegFormatConversionProvider().getAudioInputStream(decodedFormat, inputStream);
|
||||
finalInputStream = AudioSystem.getAudioInputStream(audioFormat, convertedInputStream);
|
||||
|
||||
} else if (getFileExtension(file.toFile().toString()).equals("flac")) {
|
||||
AudioInputStream inputStream = new FlacAudioFileReader().getAudioInputStream(file.toFile());
|
||||
AudioFormat baseFormat = inputStream.getFormat();
|
||||
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getFrameRate(), false);
|
||||
AudioInputStream convertedInputStream = new Flac2PcmAudioInputStream(inputStream, decodedFormat, inputStream.getFrameLength());
|
||||
finalInputStream = AudioSystem.getAudioInputStream(audioFormat, convertedInputStream);
|
||||
}
|
||||
|
||||
assert finalInputStream != null;
|
||||
|
||||
@@ -66,10 +66,10 @@ public class CreateCommand extends SubCommand {
|
||||
File getDirectory = new File(CustomDiscs.getInstance().getDataFolder(), "musicdata");
|
||||
File songFile = new File(getDirectory.getPath(), filename);
|
||||
if (songFile.exists()) {
|
||||
if (getFileExtension(filename).equals("wav") || getFileExtension(filename).equals("mp3")) {
|
||||
if (getFileExtension(filename).equals("wav") || getFileExtension(filename).equals("mp3") || getFileExtension(filename).equals("flac")) {
|
||||
songname = args[1];
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "File is not in wav or mp3 format!");
|
||||
player.sendMessage(ChatColor.RED + "File is not in wav, flac, or mp3 format!");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user