SPIGOT-3696: Clearing custom name of some blocks does not work

This commit is contained in:
blablubbabc 2017-12-16 03:43:04 +01:00 committed by md_5
parent 04595908e5
commit 45c83860e1
5 changed files with 47 additions and 1 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}