Micro optimisations
This commit is contained in:
parent
ad89e9aa83
commit
9d9b3c4349
|
@ -131,6 +131,9 @@ public class ProtocolLibListener implements Listener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
GameProfile playerProfile = null;
|
||||||
|
WrappedGameProfile wgp = null;
|
||||||
|
WrappedChatComponent playerName = null;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
PlayerInfoData npcInfo = list.get(i);
|
PlayerInfoData npcInfo = list.get(i);
|
||||||
if (npcInfo == null)
|
if (npcInfo == null)
|
||||||
|
@ -139,19 +142,22 @@ public class ProtocolLibListener implements Listener {
|
||||||
if (trait == null || !trait.isMirroring(event.getPlayer()))
|
if (trait == null || !trait.isMirroring(event.getPlayer()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GameProfile playerProfile = NMS.getProfile(event.getPlayer());
|
if (playerProfile == null) {
|
||||||
|
playerProfile = NMS.getProfile(event.getPlayer());
|
||||||
|
wgp = WrappedGameProfile.fromPlayer(event.getPlayer());
|
||||||
|
playerName = WrappedChatComponent.fromText(event.getPlayer().getDisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
if (trait.mirrorName()) {
|
if (trait.mirrorName()) {
|
||||||
list.set(i,
|
list.set(i, new PlayerInfoData(wgp.withId(npcInfo.getProfile().getId()), npcInfo.getLatency(),
|
||||||
new PlayerInfoData(
|
npcInfo.getGameMode(), playerName));
|
||||||
WrappedGameProfile.fromPlayer(event.getPlayer())
|
|
||||||
.withId(npcInfo.getProfile().getId()),
|
|
||||||
npcInfo.getLatency(), npcInfo.getGameMode(),
|
|
||||||
WrappedChatComponent.fromText(event.getPlayer().getDisplayName())));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
||||||
if (textures == null || textures.size() == 0)
|
if (textures == null || textures.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
npcInfo.getProfile().getProperties().clear();
|
npcInfo.getProfile().getProperties().clear();
|
||||||
for (String key : playerProfile.getProperties().keySet()) {
|
for (String key : playerProfile.getProperties().keySet()) {
|
||||||
npcInfo.getProfile().getProperties().putAll(key,
|
npcInfo.getProfile().getProperties().putAll(key,
|
||||||
|
@ -162,6 +168,7 @@ public class ProtocolLibListener implements Listener {
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
event.getPacket().getPlayerInfoDataLists().write(0, list);
|
event.getPacket().getPlayerInfoDataLists().write(0, list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1179,14 +1179,17 @@ public class NMSImpl implements NMSBridge {
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) raw;
|
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) raw;
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> list = Lists.newArrayList(packet.entries());
|
List<ClientboundPlayerInfoUpdatePacket.Entry> list = Lists.newArrayList(packet.entries());
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
GameProfile playerProfile = null;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
|
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
|
||||||
if (npcInfo == null)
|
if (npcInfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MirrorTrait trait = mirrorTraits.apply(npcInfo.profileId());
|
MirrorTrait trait = mirrorTraits.apply(npcInfo.profileId());
|
||||||
if (trait == null || !trait.isMirroring(player)) {
|
if (trait == null || !trait.isMirroring(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
|
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
|
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
|
||||||
|
@ -1195,7 +1198,11 @@ public class NMSImpl implements NMSBridge {
|
||||||
npcInfo.chatSession()));
|
npcInfo.chatSession()));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
GameProfile playerProfile = NMS.getProfile(player);
|
|
||||||
|
if (playerProfile == null) {
|
||||||
|
playerProfile = NMS.getProfile(player);
|
||||||
|
}
|
||||||
|
|
||||||
if (trait.mirrorName()) {
|
if (trait.mirrorName()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
|
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
|
||||||
|
@ -1204,15 +1211,19 @@ public class NMSImpl implements NMSBridge {
|
||||||
changed = true;
|
changed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
||||||
if (textures == null || textures.size() == 0)
|
if (textures == null || textures.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
npcInfo.profile().getProperties().clear();
|
npcInfo.profile().getProperties().clear();
|
||||||
for (String key : playerProfile.getProperties().keySet()) {
|
for (String key : playerProfile.getProperties().keySet()) {
|
||||||
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
|
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
try {
|
try {
|
||||||
PLAYER_INFO_ENTRIES_LIST.invoke(packet, list);
|
PLAYER_INFO_ENTRIES_LIST.invoke(packet, list);
|
||||||
|
|
|
@ -1155,6 +1155,7 @@ public class NMSImpl implements NMSBridge {
|
||||||
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) raw;
|
ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) raw;
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> list = Lists.newArrayList(packet.entries());
|
List<ClientboundPlayerInfoUpdatePacket.Entry> list = Lists.newArrayList(packet.entries());
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
GameProfile playerProfile = null;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
|
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
|
||||||
if (npcInfo == null)
|
if (npcInfo == null)
|
||||||
|
@ -1164,6 +1165,7 @@ public class NMSImpl implements NMSBridge {
|
||||||
if (trait == null || !trait.isMirroring(player)) {
|
if (trait == null || !trait.isMirroring(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
|
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
|
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
|
||||||
|
@ -1172,7 +1174,11 @@ public class NMSImpl implements NMSBridge {
|
||||||
npcInfo.chatSession()));
|
npcInfo.chatSession()));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
GameProfile playerProfile = NMS.getProfile(player);
|
|
||||||
|
if (playerProfile == null) {
|
||||||
|
playerProfile = NMS.getProfile(player);
|
||||||
|
}
|
||||||
|
|
||||||
if (trait.mirrorName()) {
|
if (trait.mirrorName()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
|
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
|
||||||
|
@ -1181,15 +1187,19 @@ public class NMSImpl implements NMSBridge {
|
||||||
changed = true;
|
changed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
||||||
if (textures == null || textures.size() == 0)
|
if (textures == null || textures.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
npcInfo.profile().getProperties().clear();
|
npcInfo.profile().getProperties().clear();
|
||||||
for (String key : playerProfile.getProperties().keySet()) {
|
for (String key : playerProfile.getProperties().keySet()) {
|
||||||
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
|
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
try {
|
try {
|
||||||
PLAYER_INFO_ENTRIES_LIST.invoke(packet, list);
|
PLAYER_INFO_ENTRIES_LIST.invoke(packet, list);
|
||||||
|
|
Loading…
Reference in New Issue