Fix empty custom name to allow empty lines.

This commit is contained in:
filoghost 2014-12-23 12:16:52 +01:00
parent 5064c989ed
commit def5ad31b7
8 changed files with 27 additions and 21 deletions

View File

@ -81,7 +81,11 @@ public class ProtocolLibHook {
WrappedDataWatcher dataWatcher = spawnEntityPacket.getMetadata();
String customName = dataWatcher.getString(customNameWatcherIndex);
if (customName == null) {
return;
}
if (customName.contains("{player}") || customName.contains("{displayname}")) {
WrappedDataWatcher dataWatcherClone = dataWatcher.deepClone();
@ -144,10 +148,10 @@ public class ProtocolLibHook {
for (int i = 0; i < dataWatcherValues.size(); i++) {
if (dataWatcherValues.get(i).getIndex() == customNameWatcherIndex) {
if (dataWatcherValues.get(i).getIndex() == customNameWatcherIndex && dataWatcherValues.get(i).getValue() != null) {
Object customNameObject = dataWatcherValues.get(i).deepClone().getValue();
if (customNameObject instanceof String == false) {
if (customNameObject == null || customNameObject instanceof String == false) {
return;
}
@ -167,7 +171,7 @@ public class ProtocolLibHook {
}
}
}
}
}
});
return true;

View File

@ -68,7 +68,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -108,7 +108,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
name = name.substring(0, 64);
}
super.setCustomName(name);
super.setCustomNameVisible(name != null);
super.setCustomNameVisible(name != null && !name.isEmpty());
}
@Override

View File

@ -68,7 +68,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -108,7 +108,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
name = name.substring(0, 300);
}
super.setCustomName(name);
super.setCustomNameVisible(name != null);
super.setCustomNameVisible(name != null && !name.isEmpty());
}
@Override

View File

@ -68,7 +68,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -108,7 +108,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
name = name.substring(0, 300);
}
super.setCustomName(name);
super.setCustomNameVisible(name != null);
super.setCustomNameVisible(name != null && !name.isEmpty());
}
@Override

View File

@ -68,7 +68,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -108,7 +108,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
name = name.substring(0, 300);
}
super.setCustomName(name);
super.setCustomNameVisible(name != null);
super.setCustomNameVisible(name != null && !name.isEmpty());
}
@Override

View File

@ -68,7 +68,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -108,7 +108,7 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
name = name.substring(0, 300);
}
super.setCustomName(name);
super.setCustomNameVisible(name != null);
super.setCustomNameVisible(name != null && !name.isEmpty());
}
@Override

View File

@ -67,7 +67,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
@Override
public boolean isInvulnerable(DamageSource source) {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -141,7 +141,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
name = name.substring(0, 300);
}
super.setCustomName(name);
super.setCustomNameVisible(name != null);
super.setCustomNameVisible(name != null && !name.isEmpty());
}
@Override

View File

@ -41,12 +41,14 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
if (nmsNameble != null) {
if (text != null && !text.isEmpty()) {
nmsNameble.setCustomNameNMS(text);
if (getParent().isAllowPlaceholders()) {
PlaceholdersManager.trackIfNecessary(this);
}
} else {
nmsNameble.setCustomNameNMS(null);
}
if (getParent().isAllowPlaceholders()) {
PlaceholdersManager.trackIfNecessary(this);
nmsNameble.setCustomNameNMS(""); // It will not appear
if (getParent().isAllowPlaceholders()) {
PlaceholdersManager.untrack(this);
}
}
}
}