Fix up player disguises skins

This commit is contained in:
libraryaddict 2016-06-14 21:08:53 +12:00
parent 6e77551f2e
commit f498867d5c
5 changed files with 256 additions and 204 deletions

View File

@ -1,130 +1,130 @@
# Shall I notify people of a LibsDisguises update? # Shall I notify people of a LibsDisguises update?
NotifyUpdate: true NotifyUpdate: true
# Whats the permission to get the notification? # Whats the permission to get the notification?
Permission: 'libsdisguises.update' Permission: 'libsdisguises.update'
# Whats the max size allowed for command disguiseradius # Whats the max size allowed for command disguiseradius
DisguiseRadiusMax: 50 DisguiseRadiusMax: 50
# Whats the max size allowed for command undisguiseradius # Whats the max size allowed for command undisguiseradius
UndisguiseRadiusMax: 50 UndisguiseRadiusMax: 50
# Shall the players view their disguises? # Shall the players view their disguises?
# Best used when viewing yourself in 3rd person # Best used when viewing yourself in 3rd person
ViewSelfDisguises: true ViewSelfDisguises: true
# Shall I disguise the sounds? # Shall I disguise the sounds?
# This turns your damage sound into a MOOOO # This turns your damage sound into a MOOOO
DisguiseSounds: true DisguiseSounds: true
# Shall the disguised hear their disguise sounds or their damage sounds. # Shall the disguised hear their disguise sounds or their damage sounds.
# I disable this as it can be a little confusing when not used with self disguises # I disable this as it can be a little confusing when not used with self disguises
HearSelfDisguise: true HearSelfDisguise: true
# Shall I send the velocity packets? I REALLY recommend you don't disable. # Shall I send the velocity packets? I REALLY recommend you don't disable.
# This is the only thing allowing the mobs to fly without glitching out. # This is the only thing allowing the mobs to fly without glitching out.
SendVelocity: true SendVelocity: true
# For self disguises, they need to have the armor and the held item removed # For self disguises, they need to have the armor and the held item removed
# Else they see floating armor, floating held items. # Else they see floating armor, floating held items.
# This turns the items invisible in the disguised players inventory. It does not actually remove them! # This turns the items invisible in the disguised players inventory. It does not actually remove them!
RemoveArmor: true RemoveArmor: true
RemoveHeldItem: false RemoveHeldItem: false
# If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible. # If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible.
# Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking # Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking
# This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise. # This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise.
AddEntityAnimations: true AddEntityAnimations: true
# When a sheep or wolf is right clicked with dye. The client automatically assumes it was successful and displays the sheeps wool or the wolfs collar as dyed. # When a sheep or wolf is right clicked with dye. The client automatically assumes it was successful and displays the sheeps wool or the wolfs collar as dyed.
# This is a option that either prevents that happening, or it changes their color officially in the plugin so that everyone sees it changed. # This is a option that either prevents that happening, or it changes their color officially in the plugin so that everyone sees it changed.
# Its currently set to false which means that the color is not changed and will refresh itself to the player. # Its currently set to false which means that the color is not changed and will refresh itself to the player.
# Please note that this will not remove the dye from their hands. This also does not check if the disguised entity is actually a sheep/wolf and wants a say in its color. # Please note that this will not remove the dye from their hands. This also does not check if the disguised entity is actually a sheep/wolf and wants a say in its color.
DyeableSheep: false DyeableSheep: false
DyeableWolf: false DyeableWolf: false
# This is only called into action when the disguise is constructed using the commands. # This is only called into action when the disguise is constructed using the commands.
# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance. # And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance.
# Such as prophunt. Its also false because its kind of a retarded feature. # Such as prophunt. Its also false because its kind of a retarded feature.
# This is pretty simple. It shows the players displayname (Name as it appears in chat) above their head. # This is pretty simple. It shows the players displayname (Name as it appears in chat) above their head.
# This also overrides any custom name they have set in their disguise options. # This also overrides any custom name they have set in their disguise options.
ShowNamesAboveDisguises: false ShowNamesAboveDisguises: false
# This supports the above option. # This supports the above option.
# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not. # If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not.
NameAboveHeadAlwaysVisible: true NameAboveHeadAlwaysVisible: true
# This modifys the bounding box, This is stuff like can a arrow hit them. # This modifys the bounding box, This is stuff like can a arrow hit them.
# If you turn this to true, arrows will act like they hit the disguise in the right place! # If you turn this to true, arrows will act like they hit the disguise in the right place!
# So someone disguised as a enderdragon will easily get shot down by arrows! # So someone disguised as a enderdragon will easily get shot down by arrows!
# This WILL conflict with NoCheatPlus. Other plugins may also get problems. # This WILL conflict with NoCheatPlus. Other plugins may also get problems.
# This shouldn't really be enabled for players as it also interferes with their movement because the server thinks the player is larger than he really is. # This shouldn't really be enabled for players as it also interferes with their movement because the server thinks the player is larger than he really is.
# That makes the player unable to approach this building because the server thinks he is trying to glitch inside blocks. # That makes the player unable to approach this building because the server thinks he is trying to glitch inside blocks.
ModifyBoundingBox: false ModifyBoundingBox: false
# This prevents disguised players from being targeted by monsters. # This prevents disguised players from being targeted by monsters.
# This doesn't prevent their targeting you if already targeting when disguised # This doesn't prevent their targeting you if already targeting when disguised
# They will just ignore you unless provoked. # They will just ignore you unless provoked.
MonstersIgnoreDisguises: false MonstersIgnoreDisguises: false
# Sigh. People are going to want this. # Sigh. People are going to want this.
# So lets make your disguise blown if you are attacked.. # So lets make your disguise blown if you are attacked..
# Works only for disguised players when attacked by a entity (arrow, monster. etc) # Works only for disguised players when attacked by a entity (arrow, monster. etc)
# This will blow all disguises he has on him # This will blow all disguises he has on him
BlowDisguises: false BlowDisguises: false
BlownDisguiseMessage: '&cYour disguise was blown!' BlownDisguiseMessage: '&cYour disguise was blown!'
#Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected! #Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected!
StopShulkerDisguisesFromMoving: true StopShulkerDisguisesFromMoving: true
# A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring # A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring
DisguiseEntityExpire: 10 DisguiseEntityExpire: 10
# Another option to choose the same thing for DisguiseClone command # Another option to choose the same thing for DisguiseClone command
DisguiseCloneExpire: 10 DisguiseCloneExpire: 10
# Max disguises to store at a time with the DisguiseClone command # Max disguises to store at a time with the DisguiseClone command
DisguiseCloneSize: 3 DisguiseCloneSize: 3
# This I don't really recommend turning on as it can make a memory leak.. # This I don't really recommend turning on as it can make a memory leak..
# These disguises, as normal will not persist after a server restart. # These disguises, as normal will not persist after a server restart.
# There is also no EntityDeath option as entities do not revive after death. # There is also no EntityDeath option as entities do not revive after death.
KeepDisguises: KeepDisguises:
EntityDespawn: false EntityDespawn: false
PlayerDeath: false PlayerDeath: false
PlayerLogout: false PlayerLogout: false
# This controls if a entitys max health is determined by the entity, or by the disguise. # This controls if a entitys max health is determined by the entity, or by the disguise.
# Wither is 200, a player is 20. With this enabled, a player disguised as a wither will have the boss bar health accurate to the players health. # Wither is 200, a player is 20. With this enabled, a player disguised as a wither will have the boss bar health accurate to the players health.
# Else it will be 1/20 of the boss bar when he is full health. # Else it will be 1/20 of the boss bar when he is full health.
# Setting this in LivingWatcher overrides both values. # Setting this in LivingWatcher overrides both values.
MaxHealthDeterminedByEntity: true MaxHealthDeterminedByEntity: true
# This here is a option to turn off misc disguises. # This here is a option to turn off misc disguises.
# This means you can not have a living entity disguise as a non-living entity. # This means you can not have a living entity disguise as a non-living entity.
# This disables the Attributes packet, Non-living entities can still disguise as other non-living # This disables the Attributes packet, Non-living entities can still disguise as other non-living
# This means that the above option will not work as it uses the attribute packet. # This means that the above option will not work as it uses the attribute packet.
MiscDisguisesForLiving: true MiscDisguisesForLiving: true
# Turn this to true to have players undisguised when switching worlds # Turn this to true to have players undisguised when switching worlds
UndisguiseOnWorldChange: false UndisguiseOnWorldChange: false
# Contact Mojang's servers? Disabling this option will disable player skin disguises! # Contact Mojang's servers? Disabling this option will disable player skin disguises!
ContactMojangServers: true ContactMojangServers: true
# This will help performance, especially with CPU # This will help performance, especially with CPU
# Due to safety reasons, self disguises can never have their packets disabled. # Due to safety reasons, self disguises can never have their packets disabled.
PacketsEnabled: PacketsEnabled:
# This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash. # This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash.
# Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash # Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash
Animation: true Animation: true
# Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player # Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player
# This also sends a chunk packet at key positions else it doesn't work for 1.8. Lazyness means it does it for older versions too currently. # This also sends a chunk packet at key positions else it doesn't work for 1.8. Lazyness means it does it for older versions too currently.
Bed: true Bed: true
# This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it # This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it
# This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well # This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well
Collect: true Collect: true
# This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching. # This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching.
EntityStatus: true EntityStatus: true
# Entity equipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item. # Entity equipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item.
# Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing. # Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing.
Equipment: true Equipment: true
# This doesn't actually disable the packet. It would introduce problems. Instead it does the next best thing and caches the data. # This doesn't actually disable the packet. It would introduce problems. Instead it does the next best thing and caches the data.
# This means that entity metadata will not change, and will only be sent in the spawn packet. # This means that entity metadata will not change, and will only be sent in the spawn packet.
# This is good if performance is extremely in need. # This is good if performance is extremely in need.
# This is bad to disable unless you are ONLY going to use the disguises for decorations. # This is bad to disable unless you are ONLY going to use the disguises for decorations.
# To be honest. This is basically "Disable entity animations". That option is called 'AddEntityAnimations' in the config but unlike that, this is always in effect. # To be honest. This is basically "Disable entity animations". That option is called 'AddEntityAnimations' in the config but unlike that, this is always in effect.
# Animations set by use of the api or through the disguise command are still in effect. # Animations set by use of the api or through the disguise command are still in effect.
Metadata: true Metadata: true
# Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up. # Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up.
# If you are using the Item_Frame disguise, when a packet is sent (Roughly every 2min) the disguise will bug up until they move. # If you are using the Item_Frame disguise, when a packet is sent (Roughly every 2min) the disguise will bug up until they move.
Movement: true Movement: true
# Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity # Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity
Riding: true Riding: true
# When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way. # When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way.
WitherSkull: true WitherSkull: true

View File

@ -14,28 +14,14 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
public class PlayerDisguise extends TargetedDisguise public class PlayerDisguise extends TargetedDisguise
{ {
private LibsProfileLookup currentLookup; private LibsProfileLookup currentLookup;
private WrappedGameProfile gameProfile; private WrappedGameProfile gameProfile;
private String playerName; private String playerName;
private String skinToUse; private String skinToUse;
public PlayerDisguise(String name) private PlayerDisguise()
{ {
if (name.length() > 16) // Internal usage only
{
name = name.substring(0, 16);
}
playerName = name;
createDisguise(DisguiseType.PLAYER);
}
public PlayerDisguise(String name, String skinToUse)
{
this(name);
setSkin(skinToUse);
} }
public PlayerDisguise(Player player) public PlayerDisguise(Player player)
@ -48,18 +34,40 @@ public class PlayerDisguise extends TargetedDisguise
this(ReflectionManager.getGameProfile(player), ReflectionManager.getGameProfile(skinToUse)); this(ReflectionManager.getGameProfile(player), ReflectionManager.getGameProfile(skinToUse));
} }
public PlayerDisguise(String name)
{
setName(name);
setSkin(name);
createDisguise(DisguiseType.PLAYER);
}
public PlayerDisguise(String name, String skinToUse)
{
setName(name);
setSkin(skinToUse);
createDisguise(DisguiseType.PLAYER);
}
public PlayerDisguise(WrappedGameProfile gameProfile) public PlayerDisguise(WrappedGameProfile gameProfile)
{ {
this(gameProfile.getName()); setName(gameProfile.getName());
this.gameProfile = gameProfile; this.gameProfile = gameProfile;
createDisguise(DisguiseType.PLAYER);
} }
public PlayerDisguise(WrappedGameProfile gameProfile, WrappedGameProfile skinToUse) public PlayerDisguise(WrappedGameProfile gameProfile, WrappedGameProfile skinToUse)
{ {
this(gameProfile); setName(gameProfile.getName());
this.gameProfile = gameProfile;
setSkin(skinToUse); setSkin(skinToUse);
createDisguise(DisguiseType.PLAYER);
} }
@Override @Override
@ -77,12 +85,14 @@ public class PlayerDisguise extends TargetedDisguise
@Override @Override
public PlayerDisguise clone() public PlayerDisguise clone()
{ {
PlayerDisguise disguise = new PlayerDisguise(getName()); PlayerDisguise disguise = new PlayerDisguise();
disguise.playerName = getName();
if (disguise.currentLookup == null && disguise.gameProfile != null) if (disguise.currentLookup == null && disguise.gameProfile != null)
{ {
disguise.skinToUse = getSkin(); disguise.skinToUse = getSkin();
disguise.gameProfile = gameProfile; disguise.gameProfile = ReflectionManager.getClonedProfile(getGameProfile());
} }
else else
{ {
@ -98,12 +108,9 @@ public class PlayerDisguise extends TargetedDisguise
disguise.setModifyBoundingBox(isModifyBoundingBox()); disguise.setModifyBoundingBox(isModifyBoundingBox());
disguise.setWatcher(getWatcher().clone(disguise)); disguise.setWatcher(getWatcher().clone(disguise));
return disguise; disguise.createDisguise(DisguiseType.PLAYER);
}
public void setGameProfile(WrappedGameProfile gameProfile) return disguise;
{
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, gameProfile.getName(), gameProfile);
} }
public WrappedGameProfile getGameProfile() public WrappedGameProfile getGameProfile()
@ -170,6 +177,11 @@ public class PlayerDisguise extends TargetedDisguise
return (PlayerDisguise) super.setEntity(entity); return (PlayerDisguise) super.setEntity(entity);
} }
public void setGameProfile(WrappedGameProfile gameProfile)
{
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, gameProfile.getName(), gameProfile);
}
@Override @Override
public PlayerDisguise setHearSelfDisguise(boolean hearSelfDisguise) public PlayerDisguise setHearSelfDisguise(boolean hearSelfDisguise)
{ {
@ -212,55 +224,63 @@ public class PlayerDisguise extends TargetedDisguise
return (PlayerDisguise) super.setModifyBoundingBox(modifyBox); return (PlayerDisguise) super.setModifyBoundingBox(modifyBox);
} }
private void setName(String name)
{
if (name.length() > 16)
{
name = name.substring(0, 16);
}
playerName = name;
}
@Override @Override
public PlayerDisguise setReplaceSounds(boolean areSoundsReplaced) public PlayerDisguise setReplaceSounds(boolean areSoundsReplaced)
{ {
return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced); return (PlayerDisguise) super.setReplaceSounds(areSoundsReplaced);
} }
public PlayerDisguise setSkin(String skinToUse) public PlayerDisguise setSkin(String newSkin)
{ {
this.skinToUse = skinToUse; skinToUse = newSkin;
if (skinToUse == null) if (newSkin == null)
{ {
this.currentLookup = null; currentLookup = null;
this.gameProfile = null; gameProfile = null;
} }
else else
{ {
if (skinToUse.length() > 16) if (newSkin.length() > 16)
{ {
this.skinToUse = skinToUse.substring(0, 16); skinToUse = newSkin.substring(0, 16);
} }
if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)) currentLookup = new LibsProfileLookup()
{ {
currentLookup = new LibsProfileLookup() @Override
public void onLookup(WrappedGameProfile gameProfile)
{ {
@Override if (currentLookup != this || gameProfile == null)
public void onLookup(WrappedGameProfile gameProfile) return;
{
if (currentLookup == this && gameProfile != null)
{
setSkin(gameProfile);
if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this))
{
DisguiseUtilities.refreshTrackers(PlayerDisguise.this);
}
currentLookup = null;
}
}
};
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup);
if (gameProfile != null)
{
setSkin(gameProfile); setSkin(gameProfile);
if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this))
{
DisguiseUtilities.refreshTrackers(PlayerDisguise.this);
}
currentLookup = null;
} }
};
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup,
LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true));
if (gameProfile != null)
{
setSkin(gameProfile);
} }
} }
@ -286,6 +306,7 @@ public class PlayerDisguise extends TargetedDisguise
if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true)) if (LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true))
{ {
Validate.notEmpty(gameProfile.getName(), "Name must be set"); Validate.notEmpty(gameProfile.getName(), "Name must be set");
this.skinToUse = gameProfile.getName(); this.skinToUse = gameProfile.getName();
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile); this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(null, getName(), gameProfile);
} }

View File

@ -640,6 +640,7 @@ public class DisguiseUtilities
public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise) public static WrappedGameProfile getProfileFromMojang(final PlayerDisguise disguise)
{ {
final String nameToFetch = disguise.getSkin() != null ? disguise.getSkin() : disguise.getName(); final String nameToFetch = disguise.getSkin() != null ? disguise.getSkin() : disguise.getName();
final boolean remove = getAddedByPlugins().contains(nameToFetch.toLowerCase()); final boolean remove = getAddedByPlugins().contains(nameToFetch.toLowerCase());
return getProfileFromMojang(nameToFetch, new LibsProfileLookup() return getProfileFromMojang(nameToFetch, new LibsProfileLookup()
@ -662,7 +663,7 @@ public class DisguiseUtilities
DisguiseUtilities.refreshTrackers(disguise); DisguiseUtilities.refreshTrackers(disguise);
} }
} }
}); }, LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true));
} }
/** /**
@ -688,10 +689,20 @@ public class DisguiseUtilities
*/ */
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn)
{ {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn); return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, true);
} }
private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable) /**
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
*/
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn,
boolean contactMojang)
{
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
}
private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable, boolean contactMojang)
{ {
final String playerName = origName.toLowerCase(); final String playerName = origName.toLowerCase();
@ -715,6 +726,7 @@ public class DisguiseUtilities
if (!gameProfile.getProperties().isEmpty()) if (!gameProfile.getProperties().isEmpty())
{ {
gameProfiles.put(playerName, gameProfile); gameProfiles.put(playerName, gameProfile);
return gameProfile; return gameProfile;
} }
} }
@ -736,25 +748,27 @@ public class DisguiseUtilities
@Override @Override
public void run() public void run()
{ {
if (!gameProfile.getProperties().isEmpty()) if (gameProfile.getProperties().isEmpty())
{ {
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) return;
{ }
gameProfiles.put(playerName, gameProfile);
}
if (runnables.containsKey(playerName)) if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null)
{
gameProfiles.put(playerName, gameProfile);
}
if (runnables.containsKey(playerName))
{
for (Object obj : runnables.remove(playerName))
{ {
for (Object obj : runnables.remove(playerName)) if (obj instanceof Runnable)
{ {
if (obj instanceof Runnable) ((Runnable) obj).run();
{ }
((Runnable) obj).run(); else if (obj instanceof LibsProfileLookup)
} {
else if (obj instanceof LibsProfileLookup) ((LibsProfileLookup) obj).onLookup(gameProfile);
{
((LibsProfileLookup) obj).onLookup(gameProfile);
}
} }
} }
} }
@ -786,6 +800,7 @@ public class DisguiseUtilities
{ {
runnables.put(playerName, new ArrayList<>()); runnables.put(playerName, new ArrayList<>());
} }
runnables.get(playerName).add(runnable); runnables.get(playerName).add(runnable);
} }
@ -798,7 +813,16 @@ public class DisguiseUtilities
*/ */
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn)
{ {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn); return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, true);
}
/**
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
*/
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn, boolean contactMojang)
{
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
} }
public static HashSet<UUID> getSelfDisguised() public static HashSet<UUID> getSelfDisguised()

View File

@ -221,7 +221,7 @@ public class PacketsManager
{ {
PlayerDisguise playerDisguise = (PlayerDisguise) disguise; PlayerDisguise playerDisguise = (PlayerDisguise) disguise;
String name = playerDisguise.getSkin() != null ? playerDisguise.getSkin() : playerDisguise.getName(); String name = playerDisguise.getName();
int entityId = disguisedEntity.getEntityId(); int entityId = disguisedEntity.getEntityId();
boolean removeName = false; boolean removeName = false;

View File

@ -438,12 +438,19 @@ public class ReflectionManager
return null; return null;
} }
public static WrappedGameProfile getClonedProfile(WrappedGameProfile gameProfile)
{
return getGameProfileWithThisSkin(null, gameProfile.getName(), gameProfile);
}
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin)
{ {
try try
{ {
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName); WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
gameProfile.getProperties().putAll(profileWithSkin.getProperties()); gameProfile.getProperties().putAll(profileWithSkin.getProperties());
return gameProfile; return gameProfile;
} }
catch (Exception ex) catch (Exception ex)