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
This commit is contained in:
Christian Koop 2024-03-27 09:43:40 +01:00
parent 57746b195c
commit abb770ef65
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -1,10 +1,10 @@
package com.craftaro.epicvouchers.voucher; package com.craftaro.epicvouchers.voucher;
import com.craftaro.core.compatibility.CompatibleSound;
import com.craftaro.core.compatibility.ServerVersion; import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.epicvouchers.EpicVouchers; import com.craftaro.epicvouchers.EpicVouchers;
import com.craftaro.epicvouchers.events.VoucherRedeemEvent; import com.craftaro.epicvouchers.events.VoucherRedeemEvent;
import com.craftaro.epicvouchers.listeners.PlayerCommandListener; import com.craftaro.epicvouchers.listeners.PlayerCommandListener;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
public class VoucherExecutor { public class VoucherExecutor {
@ -142,11 +143,8 @@ public class VoucherExecutor {
} }
if (voucher.getSound() != null && !voucher.getSound().isEmpty()) { if (voucher.getSound() != null && !voucher.getSound().isEmpty()) {
try { Optional<XSound> sound = XSound.matchXSound(voucher.getSound());
CompatibleSound sound = CompatibleSound.valueOf(voucher.getSound()); sound.ifPresent(xSound -> xSound.play(player, 1.0f, voucher.getSoundPitch()));
sound.play(player, Integer.MAX_VALUE, voucher.getSoundPitch());
} catch (IllegalArgumentException ignored) {
}
} }
String particle = voucher.getParticle(); String particle = voucher.getParticle();