Deprecates CompatibleSound in favor of XSound from the XSeries library

This commit is contained in:
Christian Koop 2023-06-24 15:58:08 +02:00
parent b09338f78f
commit 7ce74de993
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
5 changed files with 18 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package com.craftaro.core.compatibility;
import com.cryptomorin.xseries.XSound;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
@ -14,7 +15,10 @@ import org.bukkit.entity.Player;
* sounds were renamed. New sounds have been added by different versions, as
* well. The intent of this class is to provide either the correct sound or a
* near equivalent for the current server.
*
* @deprecated Use {@link XSound} instead.
*/
@Deprecated
public enum CompatibleSound {
// some of these values are missing an API value...
// would using the raw strings be better?

View File

@ -120,6 +120,7 @@
<includes>
<include>com/cryptomorin/xseries/XMaterial*</include>
<include>com/cryptomorin/xseries/XBlock*</include>
<include>com/cryptomorin/xseries/XSound*</include>
</includes>
</filter>

View File

@ -1,5 +1,6 @@
package com.craftaro.core.gui;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.gui.events.GuiClickEvent;
import com.craftaro.core.gui.events.GuiCloseEvent;
import com.craftaro.core.gui.events.GuiDropItemEvent;
@ -11,9 +12,8 @@ import com.craftaro.core.gui.methods.Droppable;
import com.craftaro.core.gui.methods.Openable;
import com.craftaro.core.gui.methods.Pagable;
import com.craftaro.core.utils.ItemUtils;
import com.craftaro.core.compatibility.CompatibleSound;
import com.craftaro.core.compatibility.ServerVersion;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -50,7 +50,7 @@ public class Gui {
protected ItemStack nextPageItem, prevPageItem;
protected ItemStack nextPage, prevPage;
protected Gui parent = null;
protected static ItemStack AIR = new ItemStack(Material.AIR);
protected static final ItemStack AIR = new ItemStack(Material.AIR);
protected GuiManager guiManager;
protected boolean open = false;
@ -60,7 +60,7 @@ public class Gui {
protected Closable closer = null;
protected Droppable dropper = null;
protected Pagable pager = null;
protected CompatibleSound defaultSound = CompatibleSound.UI_BUTTON_CLICK;
protected XSound defaultSound = XSound.UI_BUTTON_CLICK;
public Gui() {
this.rows = 3;
@ -69,6 +69,7 @@ public class Gui {
public Gui(@NotNull GuiType type) {
this.inventoryType = type;
switch (type) {
case HOPPER:
case DISPENSER:
@ -959,11 +960,11 @@ public class Gui {
}
}
public CompatibleSound getDefaultSound() {
public XSound getDefaultSound() {
return defaultSound;
}
public void setDefaultSound(CompatibleSound sound) {
public void setDefaultSound(XSound sound) {
defaultSound = sound;
}
}

View File

@ -237,13 +237,13 @@ public class GuiManager {
event.setCancelled(gui.unlockedCells.entrySet().stream().noneMatch(e -> event.getSlot() == e.getKey() && e.getValue()));
// process button press
if (gui.onClick(manager, player, openInv, event)) {
player.playSound(player.getLocation(), gui.getDefaultSound().getSound(), 1F, 1F);
if (gui.onClick(this.manager, player, openInv, event)) {
gui.getDefaultSound().play(player);
}
} else {
// Player clicked in the bottom inventory while GUI is open
if (gui.onClickPlayerInventory(manager, player, openInv, event)) {
player.playSound(player.getLocation(), gui.getDefaultSound().getSound(), 1F, 1F);
if (gui.onClickPlayerInventory(this.manager, player, openInv, event)) {
gui.getDefaultSound().play(player);
} else if (!gui.acceptsItems || event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
event.setCancelled(true);

View File

@ -1,9 +1,9 @@
package com.craftaro.core.world;
import com.craftaro.core.compatibility.CompatibleHand;
import com.craftaro.core.compatibility.CompatibleSound;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.nms.Nms;
import com.cryptomorin.xseries.XSound;
import org.bukkit.Bukkit;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -93,7 +93,7 @@ public class SItemStack {
Bukkit.getServer().getPluginManager().callEvent(breakEvent);
this.sItem.breakItem(player, amount);
CompatibleSound.ENTITY_ITEM_BREAK.play(player);
XSound.ENTITY_ITEM_BREAK.play(player);
}
public ItemStack getItem() {