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

@ -82,6 +82,10 @@ 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;
}

View File

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

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

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

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

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

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