mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 05:19:43 +05:00
Some minor changes
was trying to get a way to control the audio channel
This commit is contained in:
@@ -30,7 +30,6 @@ dependencies {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://repo.dmulloy2.net/repository/public/" }
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "henkelmax.public"
|
||||
|
||||
@@ -7,12 +7,9 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
|
||||
@@ -36,7 +35,7 @@ public class JukeBox implements Listener {
|
||||
|
||||
private final Map<UUID, AudioPlayer> playerMap = new ConcurrentHashMap<>();
|
||||
public static AudioFormat FORMAT = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 48000.0F, 16, 1, 2, 48000.0F, false);
|
||||
private UUID id;
|
||||
private static UUID id;
|
||||
|
||||
@EventHandler
|
||||
public void onInsert(PlayerInteractEvent event) throws IOException {
|
||||
@@ -44,15 +43,16 @@ public class JukeBox implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null || event.getItem() == null || event.getItem().getItemMeta() == null) return;
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null || event.getItem() == null || event.getItem().getItemMeta() == null || block == null) return;
|
||||
if (event.getClickedBlock().getType() != Material.JUKEBOX) return;
|
||||
id = UUID.randomUUID();
|
||||
|
||||
if (isCustomMusicDisc(event)) {
|
||||
|
||||
Component soundFileNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(1).asComponent();
|
||||
String soundFileName = PlainTextComponentSerializer.plainText().serialize(soundFileNameComponent);
|
||||
|
||||
id = UUID.randomUUID();
|
||||
|
||||
Path soundFilePath = Path.of(CustomDiscs.getInstance().getDataFolder() + "\\musicdata\\" + soundFileName);
|
||||
if (soundFilePath.toFile().exists()) {
|
||||
Component songNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(0).asComponent();
|
||||
@@ -71,7 +71,7 @@ public class JukeBox implements Listener {
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Sound file not found.");
|
||||
event.setCancelled(true);
|
||||
throw new FileNotFoundException("ERROR: Sound file is missing!");
|
||||
throw new FileNotFoundException("Sound file is missing!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,11 +102,6 @@ public class JukeBox implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJukeboxBreak(BlockBreakEvent Event) {
|
||||
|
||||
}
|
||||
|
||||
public static short[] readSoundFile(Path file) throws UnsupportedAudioFileException, IOException {
|
||||
AudioInputStream inputStream = AudioSystem.getAudioInputStream(file.toFile());
|
||||
AudioInputStream convertedInputStream = AudioSystem.getAudioInputStream(FORMAT, inputStream);
|
||||
|
||||
Reference in New Issue
Block a user