2024-12-11 22:26:55 +01:00
--- a/net/minecraft/server/commands/GiveCommand.java
+++ b/net/minecraft/server/commands/GiveCommand.java
2021-06-21 06:55:59 +02:00
@@ -38,6 +38,7 @@
private static int giveItem(CommandSourceStack source, ItemInput item, Collection<ServerPlayer> targets, int count) throws CommandSyntaxException {
ItemStack itemstack = item.createItemStack(1, false);
+ final Component displayName = itemstack.getDisplayName(); // Paper - get display name early
int j = itemstack.getMaxStackSize();
int k = j * 100;
@@ -60,7 +61,7 @@
2024-12-11 22:26:55 +01:00
ItemEntity entityitem;
2022-03-11 21:47:13 +01:00
2023-06-07 17:30:00 +02:00
if (flag && itemstack1.isEmpty()) {
2024-04-23 17:15:00 +02:00
- entityitem = entityplayer.drop(itemstack, false);
+ entityitem = entityplayer.drop(itemstack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event
2022-03-11 21:47:13 +01:00
if (entityitem != null) {
entityitem.makeFakeItem();
}
2021-06-21 06:55:59 +02:00
@@ -79,11 +80,11 @@
if (targets.size() == 1) {
source.sendSuccess(() -> {
- return Component.translatable("commands.give.success.single", count, itemstack.getDisplayName(), ((ServerPlayer) targets.iterator().next()).getDisplayName());
+ return Component.translatable("commands.give.success.single", count, displayName, ((ServerPlayer) targets.iterator().next()).getDisplayName()); // Paper - use cached display name
}, true);
} else {
source.sendSuccess(() -> {
- return Component.translatable("commands.give.success.single", count, itemstack.getDisplayName(), targets.size());
+ return Component.translatable("commands.give.success.single", count, displayName, targets.size()); // Paper - use cached display name
}, true);
}