Fix a little typo for disguise cloning

This commit is contained in:
libraryaddict 2017-03-21 19:34:12 +13:00
parent e0fffdaa14
commit 477464851e
2 changed files with 13 additions and 15 deletions

View File

@ -99,12 +99,11 @@ public class PlayerDisguise extends TargetedDisguise {
disguise.playerName = getName(); disguise.playerName = getName();
if (disguise.currentLookup == null && disguise.gameProfile != null) { if (currentLookup == null && gameProfile != null) {
disguise.skinToUse = getSkin(); disguise.skinToUse = getSkin();
disguise.gameProfile = ReflectionManager.getGameProfileWithThisSkin(disguise.uuid, getGameProfile().getName(), disguise.gameProfile = ReflectionManager.getGameProfileWithThisSkin(disguise.uuid,
getGameProfile()); getGameProfile().getName(), getGameProfile());
} } else {
else {
disguise.setSkin(getSkin()); disguise.setSkin(getSkin());
} }
@ -129,8 +128,7 @@ public class PlayerDisguise extends TargetedDisguise {
if (gameProfile == null) { if (gameProfile == null) {
if (getSkin() != null) { if (getSkin() != null) {
gameProfile = ReflectionManager.getGameProfile(uuid, getName()); gameProfile = ReflectionManager.getGameProfile(uuid, getName());
} } else {
else {
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getName(), gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getName(),
DisguiseUtilities.getProfileFromMojang(this)); DisguiseUtilities.getProfileFromMojang(this));
} }
@ -280,8 +278,7 @@ public class PlayerDisguise extends TargetedDisguise {
if (newSkin == null) { if (newSkin == null) {
currentLookup = null; currentLookup = null;
gameProfile = null; gameProfile = null;
} } else {
else {
if (newSkin.length() > 16) { if (newSkin.length() > 16) {
skinToUse = newSkin.substring(0, 16); skinToUse = newSkin.substring(0, 16);
} }
@ -293,8 +290,7 @@ public class PlayerDisguise extends TargetedDisguise {
/** /**
* Set the GameProfile, without tampering. * Set the GameProfile, without tampering.
* *
* @param gameProfile * @param gameProfile GameProfile
* GameProfile
* @return * @return
*/ */
public PlayerDisguise setSkin(WrappedGameProfile gameProfile) { public PlayerDisguise setSkin(WrappedGameProfile gameProfile) {
@ -315,15 +311,16 @@ public class PlayerDisguise extends TargetedDisguise {
if (isDisplayedInTab()) { if (isDisplayedInTab()) {
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); addTab.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
addTab.getPlayerInfoDataLists().write(0, Arrays.asList(new PlayerInfoData(getGameProfile(), 0, addTab.getPlayerInfoDataLists().write(0, Arrays.asList(
NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(getName())))); new PlayerInfoData(getGameProfile(), 0, NativeGameMode.SURVIVAL,
WrappedChatComponent.fromText(getName()))));
PacketContainer deleteTab = addTab.shallowClone(); PacketContainer deleteTab = addTab.shallowClone();
deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER); deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
try { try {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if (!((TargetedDisguise) this).canSee(player)) if (!canSee(player))
continue; continue;
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab); ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);

View File

@ -430,8 +430,9 @@ public class ReflectionManager {
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(),
playerName); playerName);
if (profileWithSkin != null) if (profileWithSkin != null) {
gameProfile.getProperties().putAll(profileWithSkin.getProperties()); gameProfile.getProperties().putAll(profileWithSkin.getProperties());
}
return gameProfile; return gameProfile;
} }