Some minor changes

was trying to get a way to control the audio channel
This commit is contained in:
Navoei
2022-07-09 21:35:28 -05:00
parent 287b41f004
commit af77bffaac
3 changed files with 5 additions and 14 deletions

View File

@@ -30,7 +30,6 @@ dependencies {
}
repositories {
maven { url "https://repo.dmulloy2.net/repository/public/" }
mavenCentral()
maven {
name = "henkelmax.public"

View File

@@ -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;

View File

@@ -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);