diff options
author | blablubbabc <lukas@wirsindwir.de> | 2017-12-16 03:43:04 +0100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2017-12-17 11:41:56 +1100 |
commit | 45c83860e115f1f09c050459b5a4bd2e09bea053 (patch) | |
tree | 24c5799948f312c995b3afffcb5825c5ee56d287 | |
parent | 04595908e5ceae3281480a4abab2f2c91cc05a35 (diff) | |
download | craftbukkit-45c83860e115f1f09c050459b5a4bd2e09bea053.tar craftbukkit-45c83860e115f1f09c050459b5a4bd2e09bea053.tar.gz craftbukkit-45c83860e115f1f09c050459b5a4bd2e09bea053.tar.lz craftbukkit-45c83860e115f1f09c050459b5a4bd2e09bea053.tar.xz craftbukkit-45c83860e115f1f09c050459b5a4bd2e09bea053.zip |
SPIGOT-3696: Clearing custom name of some blocks does not work
5 files changed, 47 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index 4f717f28..9c336e64 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<TileEntityBrewingStand> 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 c5a1326d..f9239e55 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<TileEntityEnchan public void setCustomName(String name) { this.getSnapshot().setCustomName(name); } + + @Override + public void applyTo(TileEntityEnchantTable enchantingTable) { + super.applyTo(enchantingTable); + + if (!this.getSnapshot().hasCustomName()) { + enchantingTable.setCustomName(null); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftEndGateway.java b/src/main/java/org/bukkit/craftbukkit/block/CraftEndGateway.java index 6deb17d3..8ca614bd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftEndGateway.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEndGateway.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.block; +import java.util.Objects; import net.minecraft.server.BlockPosition; import net.minecraft.server.TileEntityEndGateway; import org.bukkit.Location; @@ -27,7 +28,7 @@ public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway> 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<TileEntityEndGateway> 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 fbde4433..047dbe2e 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<TileEntityFurnace> 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 306a47ba..e2af111d 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<T extends TileEntityLootable> 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); + } + } } |