Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Remove ignoreCancelled from ArmorToggleListener, small cleanup
Spigot considers interacting with air "cancelled" Fixes #3240
Dieser Commit ist enthalten in:
Ursprung
fccfadf1b7
Commit
a828c43f99
@ -27,6 +27,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
public final class ArmorToggleListener extends ViaBukkitListener {
|
public final class ArmorToggleListener extends ViaBukkitListener {
|
||||||
|
|
||||||
@ -46,23 +47,26 @@ public final class ArmorToggleListener extends ViaBukkitListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void itemUse(final PlayerInteractEvent event) {
|
public void itemUse(final PlayerInteractEvent event) {
|
||||||
if (!ENABLED) {
|
if (!ENABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!isOnPipe(player) || event.getItem() == null) {
|
final ItemStack item = event.getItem();
|
||||||
|
if (item == null || event.getHand() == null || !isOnPipe(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final EquipmentSlot equipmentSlot = event.getItem().getType().getEquipmentSlot();
|
final EquipmentSlot armorItemSlot = item.getType().getEquipmentSlot();
|
||||||
if (equipmentSlot != EquipmentSlot.HAND && equipmentSlot != EquipmentSlot.OFF_HAND) {
|
if (armorItemSlot != EquipmentSlot.HAND && armorItemSlot != EquipmentSlot.OFF_HAND) {
|
||||||
final ItemStack armor = player.getInventory().getItem(equipmentSlot);
|
final PlayerInventory inventory = player.getInventory();
|
||||||
|
final ItemStack armor = inventory.getItem(armorItemSlot);
|
||||||
// If two pieces of armor are equal, the client will do nothing.
|
// If two pieces of armor are equal, the client will do nothing.
|
||||||
if (armor != null && armor.getType() != Material.AIR && !armor.equals(event.getItem())) {
|
if (armor != null && armor.getType() != Material.AIR && !armor.equals(item)) {
|
||||||
player.updateInventory();
|
inventory.setItem(event.getHand(), inventory.getItem(event.getHand()));
|
||||||
|
inventory.setItem(armorItemSlot, armor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren