Fix {player} and {displayname} not being relative to the player viewing

them.
This commit is contained in:
filoghost 2016-06-09 13:06:44 +02:00
parent 3b49b121fb
commit d521465385
2 changed files with 7 additions and 1 deletions

View File

@ -176,7 +176,12 @@ public class ProtocolLibHookImpl implements ProtocolLibHook {
String customName = (String) customNameObject;
if (customName.contains("{player}") || customName.contains("{displayname}")) {
watchableObject.setValue(customName.replace("{player}", player.getName()).replace("{displayname}", player.getDisplayName()));
String replacement = customName.replace("{player}", player.getName()).replace("{displayname}", player.getDisplayName());
dataWatcherValues.set(i, new WrappedWatchableObject(watchableObject.getWatcherObject(), replacement));
PacketContainer clone = packet.shallowClone();
clone.getWatchableCollectionModifier().write(0, dataWatcherValues);
event.setPacket(clone);
return;
}
}

View File

@ -58,6 +58,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.SPAWN_ENTITY_LIVING, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.ENTITY_METADATA) {
@SuppressWarnings("deprecation")
@Override
public void onPacketSending(PacketEvent event) {