mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Sanitize ability buffs when using Item Frames (#4475)
* Remove skill ability buffs from items when placed into Item Frames * Ensure compatibility on versions before 1.16
This commit is contained in:
parent
48afb81174
commit
002887e244
@ -973,6 +973,43 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When a {@link Player} attempts to place an {@link ItemStack}
|
||||||
|
* into an {@link ItemFrame}, we want to make sure to remove any
|
||||||
|
* Ability buffs from that item.
|
||||||
|
*
|
||||||
|
* @param event The {@link PlayerInteractEntityEvent} to handle
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
|
/*
|
||||||
|
* We can check for an instance instead of EntityType here, so we are
|
||||||
|
* ready for the infamous "Glow Item Frame" in 1.17 too!
|
||||||
|
*/
|
||||||
|
if (event.getRightClicked() instanceof ItemFrame) {
|
||||||
|
ItemFrame frame = (ItemFrame) event.getRightClicked();
|
||||||
|
|
||||||
|
// Check for existing items (ignore rotations)
|
||||||
|
if (frame.getItem().getType() != Material.AIR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the item the Player is about to place
|
||||||
|
ItemStack itemInHand;
|
||||||
|
|
||||||
|
if (event.getHand() == EquipmentSlot.OFF_HAND) {
|
||||||
|
itemInHand = event.getPlayer().getInventory().getItemInOffHand();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
itemInHand = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
}
|
||||||
|
|
||||||
|
// and remove any skill ability buffs!
|
||||||
|
SkillUtils.removeAbilityBuff(itemInHand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
// public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
|
// public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user