diff --git a/nms-patches/InventoryMerchant.patch b/nms-patches/InventoryMerchant.patch index 30897b1da3..f46377c3b1 100644 --- a/nms-patches/InventoryMerchant.patch +++ b/nms-patches/InventoryMerchant.patch @@ -55,6 +55,15 @@ public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) { this.itemsInSlots = NonNullList.a(3, ItemStack.a); this.player = entityhuman; +@@ -78,7 +119,7 @@ + } + + public IChatBaseComponent getDisplayName() { +- return new ChatMessage("mob.villager", new Object[0]); ++ return merchant.getScoreboardDisplayName(); // CraftBukkit + } + + public boolean hasCustomName() { @@ -91,7 +132,7 @@ } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index d96c6afdb3..cce9366f4d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -270,6 +270,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { break; case CREATIVE: case CRAFTING: + case MERCHANT: throw new IllegalArgumentException("Can't open a " + type + " inventory!"); } if (getHandle().activeContainer == formerContainer) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index bc898d6960..4f8edbe3ba 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.inventory; +import org.apache.commons.lang.Validate; import net.minecraft.server.BlockPosition; import net.minecraft.server.ChatComponentText; import net.minecraft.server.EntityHuman; @@ -23,12 +24,13 @@ public class CraftMerchantCustom extends CraftMerchant { private static class MinecraftMerchant implements IMerchant { - private final String title; + private final IChatBaseComponent title; private final MerchantRecipeList trades = new MerchantRecipeList(); private EntityHuman tradingPlayer; public MinecraftMerchant(String title) { - this.title = title; + Validate.notNull(title, "Title cannot be null"); + this.title = new ChatComponentText(title); } @Override @@ -58,7 +60,7 @@ public class CraftMerchantCustom extends CraftMerchant { @Override public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(title); + return title; } @Override