From 327417dc67f5746f972e90a2016fc7a973401b1c Mon Sep 17 00:00:00 2001 From: Chaosdave34 Date: Mon, 23 Dec 2024 09:29:40 +0100 Subject: [PATCH] Rename item to weapon and projectile to projectile item in the event, adjust javadocs, fix using old parameter name when calling event in Player#getProjectile --- .../PlayerUseBowWithoutProjectileEvent.java | 32 ++++++++----------- .../world/entity/player/Player.java.patch | 4 +-- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerUseBowWithoutProjectileEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerUseBowWithoutProjectileEvent.java index 59e432878c..1f7d3cd5b6 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerUseBowWithoutProjectileEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerUseBowWithoutProjectileEvent.java @@ -8,39 +8,35 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Called when a player tries to draw a bow or load a crossbow without having a suitable projectile in their inventory + * Called when a player tries to draw a bow or load a crossbow without having a suitable projectile item in their inventory */ @NullMarked public class PlayerUseBowWithoutProjectileEvent extends PlayerEvent { private static final HandlerList HANDLER_LIST = new HandlerList(); - private final ItemStack item; - private ItemStack projectile; + private final ItemStack weapon; + private ItemStack projectileItem; @ApiStatus.Internal - public PlayerUseBowWithoutProjectileEvent(final Player player, final ItemStack item) { + public PlayerUseBowWithoutProjectileEvent(final Player player, final ItemStack weapon) { super(player); - this.item = item; - this.projectile = ItemStack.empty(); + this.weapon = weapon; + this.projectileItem = ItemStack.empty(); } /** - * Gets the item which the player tries to use - * - * @return the item + * @return The weapon wich the player tries to use */ - public ItemStack getItem() { - return item.clone(); + public ItemStack getWeapon() { + return weapon.clone(); } /** - * Gets the projectile that should be used - * - * @return the projectile + * @return The projectile that should be used */ - public ItemStack getProjectile() { - return projectile.clone(); + public ItemStack getProjectileItem() { + return projectileItem.clone(); } /** @@ -50,8 +46,8 @@ public class PlayerUseBowWithoutProjectileEvent extends PlayerEvent { * * @param projectile the projectile */ - public void setProjectile(ItemStack projectile) { - this.projectile = projectile.clone(); + public void setProjectileItem(ItemStack projectile) { + this.projectileItem = projectile.clone(); } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index f6139ed498..2281e7958e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -678,9 +678,9 @@ + if (this.abilities.instabuild) { + return new ItemStack(Items.ARROW); + } else { -+ io.papermc.paper.event.player.PlayerUseBowWithoutProjectileEvent event = new io.papermc.paper.event.player.PlayerUseBowWithoutProjectileEvent((org.bukkit.entity.Player) getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(stack)); ++ io.papermc.paper.event.player.PlayerUseBowWithoutProjectileEvent event = new io.papermc.paper.event.player.PlayerUseBowWithoutProjectileEvent((org.bukkit.entity.Player) getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(shootable)); + event.callEvent(); -+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getProjectile()); ++ return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getProjectileItem()); + } + // Paper end - PlayerUseBowWithoutProjectileEvent }