From abb770ef654691fa3ff2e3d30e547176a9a67a01 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Wed, 27 Mar 2024 09:43:40 +0100 Subject: [PATCH] fix: Replaces usage of depreacted CompatibleSound with XSound The CompatibleSound class will be removed from the Core and this ensures compatibility with new versions of the Core and newer Minecraft versions --- .../craftaro/epicvouchers/voucher/VoucherExecutor.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/craftaro/epicvouchers/voucher/VoucherExecutor.java b/src/main/java/com/craftaro/epicvouchers/voucher/VoucherExecutor.java index bd3c481..d54986a 100644 --- a/src/main/java/com/craftaro/epicvouchers/voucher/VoucherExecutor.java +++ b/src/main/java/com/craftaro/epicvouchers/voucher/VoucherExecutor.java @@ -1,10 +1,10 @@ package com.craftaro.epicvouchers.voucher; -import com.craftaro.core.compatibility.CompatibleSound; import com.craftaro.core.compatibility.ServerVersion; import com.craftaro.epicvouchers.EpicVouchers; import com.craftaro.epicvouchers.events.VoucherRedeemEvent; import com.craftaro.epicvouchers.listeners.PlayerCommandListener; +import com.craftaro.third_party.com.cryptomorin.xseries.XSound; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.Optional; import java.util.logging.Level; public class VoucherExecutor { @@ -142,11 +143,8 @@ public class VoucherExecutor { } if (voucher.getSound() != null && !voucher.getSound().isEmpty()) { - try { - CompatibleSound sound = CompatibleSound.valueOf(voucher.getSound()); - sound.play(player, Integer.MAX_VALUE, voucher.getSoundPitch()); - } catch (IllegalArgumentException ignored) { - } + Optional sound = XSound.matchXSound(voucher.getSound()); + sound.ifPresent(xSound -> xSound.play(player, 1.0f, voucher.getSoundPitch())); } String particle = voucher.getParticle();