From 45c83860e115f1f09c050459b5a4bd2e09bea053 Mon Sep 17 00:00:00 2001 From: blablubbabc Date: Sat, 16 Dec 2017 03:43:04 +0100 Subject: [PATCH] SPIGOT-3696: Clearing custom name of some blocks does not work --- .../bukkit/craftbukkit/block/CraftBrewingStand.java | 9 +++++++++ .../craftbukkit/block/CraftEnchantingTable.java | 9 +++++++++ .../bukkit/craftbukkit/block/CraftEndGateway.java | 12 +++++++++++- .../org/bukkit/craftbukkit/block/CraftFurnace.java | 9 +++++++++ .../org/bukkit/craftbukkit/block/CraftLootable.java | 9 +++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index 4f717f2849..9c336e6445 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java @@ -61,4 +61,13 @@ public class CraftBrewingStand extends CraftContainer im public void setCustomName(String name) { this.getSnapshot().setCustomName(name); } + + @Override + public void applyTo(TileEntityBrewingStand brewingStand) { + super.applyTo(brewingStand); + + if (!this.getSnapshot().hasCustomName()) { + brewingStand.setCustomName(null); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java index c5a1326d45..f9239e55f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java @@ -25,4 +25,13 @@ public class CraftEnchantingTable extends CraftBlockEntityState public void setExitLocation(Location location) { if (location == null) { this.getSnapshot().exitPortal = null; - } else if (location.getWorld() != (this.isPlaced() ? this.getWorld() : null)) { + } else if (!Objects.equals(location.getWorld(), this.isPlaced() ? this.getWorld() : null)) { throw new IllegalArgumentException("Cannot set exit location to different world"); } else { this.getSnapshot().exitPortal = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); @@ -43,4 +44,13 @@ public class CraftEndGateway extends CraftBlockEntityState public void setExactTeleport(boolean exact) { this.getSnapshot().exactTeleport = exact; } + + @Override + public void applyTo(TileEntityEndGateway endGateway) { + super.applyTo(endGateway); + + if (this.getSnapshot().exitPortal == null) { + endGateway.exitPortal = null; + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index fbde4433ea..047dbe2e57 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -61,4 +61,13 @@ public class CraftFurnace extends CraftContainer implements F public void setCustomName(String name) { this.getSnapshot().setCustomName(name); } + + @Override + public void applyTo(TileEntityFurnace furnace) { + super.applyTo(furnace); + + if (!this.getSnapshot().hasCustomName()) { + furnace.setCustomName(null); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index 306a47ba83..e2af111d57 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -25,4 +25,13 @@ public abstract class CraftLootable extends CraftC public void setCustomName(String name) { this.getSnapshot().setCustomName(name); } + + @Override + public void applyTo(T lootable) { + super.applyTo(lootable); + + if (!this.getSnapshot().hasCustomName()) { + lootable.setCustomName(null); + } + } }