Skip to content

Commit

Permalink
Make the give notification message work for any player that has a server
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Mar 21, 2022
1 parent 62b2f40 commit 9db2be0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Forge/src/main/java/mezz/jei/util/CommandUtilServer.java
Expand Up @@ -149,9 +149,9 @@ public static void mousePickupItemStack(Player sender, ItemStack itemStack) {
giveCount = itemStack.getCount();
}

if (giveCount > 0 && sender instanceof ServerPlayer serverPlayerEntity) {
if (giveCount > 0) {
itemStackCopy.setCount(giveCount);
notifyGive(serverPlayerEntity, itemStackCopy);
notifyGive(sender, itemStackCopy);
containerMenu.broadcastChanges();
}
}
Expand Down Expand Up @@ -185,11 +185,14 @@ private static void giveToInventory(Player entityplayermp, ItemStack itemStack)
notifyGive(entityplayermp, itemStackCopy);
}

private static void notifyGive(Player entityPlayerMP, ItemStack stack) {
CommandSourceStack commandSource = entityPlayerMP.createCommandSourceStack();
private static void notifyGive(Player player, ItemStack stack) {
if (player.getServer() == null) {
return;
}
CommandSourceStack commandSource = player.createCommandSourceStack();
int count = stack.getCount();
Component stackTextComponent = stack.getDisplayName();
Component displayName = entityPlayerMP.getDisplayName();
Component displayName = player.getDisplayName();
TranslatableComponent message = new TranslatableComponent("commands.give.success.single", count, stackTextComponent, displayName);
commandSource.sendSuccess(message, true);
}
Expand Down

0 comments on commit 9db2be0

Please sign in to comment.