From 6dde4b9fda8f5e609642aebdcb6db11008268db5 Mon Sep 17 00:00:00 2001
From: blablubbabc <lukas@wirsindwir.de>
Date: Fri, 21 Jun 2019 05:06:16 +0200
Subject: [PATCH] SPIGOT-5094: Allow opening merchant for wandering traders and
 hide the xp bar for custom merchants

---
 .../bukkit/craftbukkit/entity/CraftHumanEntity.java  | 12 +++++++-----
 .../craftbukkit/inventory/CraftMerchantCustom.java   |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 93c8441f48..5cc5074a5e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -596,11 +596,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
 
         IMerchant mcMerchant;
         IChatBaseComponent name;
-        int level = 0;
-        if (merchant instanceof CraftVillager) {
-            mcMerchant = ((CraftVillager) merchant).getHandle();
-            name = ((CraftVillager) merchant).getHandle().getScoreboardDisplayName();
-            level = ((CraftVillager) merchant).getHandle().getVillagerData().getLevel();
+        int level = 1; // note: using level 0 with active 'is-regular-villager'-flag allows hiding the name suffix
+        if (merchant instanceof CraftAbstractVillager) {
+            mcMerchant = ((CraftAbstractVillager) merchant).getHandle();
+            name = ((CraftAbstractVillager) merchant).getHandle().getScoreboardDisplayName();
+            if (merchant instanceof CraftVillager) {
+                level = ((CraftVillager) merchant).getHandle().getVillagerData().getLevel();
+            }
         } else if (merchant instanceof CraftMerchantCustom) {
             mcMerchant = ((CraftMerchantCustom) merchant).getMerchant();
             name = ((CraftMerchantCustom) merchant).getMerchant().getScoreboardDisplayName();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
index 311326ee63..e3628237cb 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
@@ -95,7 +95,7 @@ public class CraftMerchantCustom extends CraftMerchant {
 
         @Override
         public boolean eb() {
-            return true;
+            return false; // is-regular-villager flag (hides some gui elements: xp bar, name suffix)
         }
 
         @Override