Changed the names and some methods so its easily used by outside plugins
This commit is contained in:
parent
74d5dbce9e
commit
43e6e6cc36
@ -263,7 +263,15 @@ public class DisguiseUtilities {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getProfile(final String playerName) {
|
public static Object getProfileFromMojang(String playerName) {
|
||||||
|
return getProfileFromMojang(playerName, 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.
|
||||||
|
*/
|
||||||
|
public static Object getProfileFromMojang(final String playerName, final boolean updateDisguises) {
|
||||||
if (gameProfiles.containsKey(playerName)) {
|
if (gameProfiles.containsKey(playerName)) {
|
||||||
if (gameProfiles.get(playerName) != null) {
|
if (gameProfiles.get(playerName) != null) {
|
||||||
return gameProfiles.get(playerName);
|
return gameProfiles.get(playerName);
|
||||||
@ -287,13 +295,17 @@ public class DisguiseUtilities {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
||||||
gameProfiles.put(playerName, gameProfile);
|
gameProfiles.put(playerName, gameProfile);
|
||||||
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
if (updateDisguises) {
|
||||||
for (TargetedDisguise disguise : disguises) {
|
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||||
if (disguise.getType() == DisguiseType.PLAYER
|
for (TargetedDisguise disguise : disguises) {
|
||||||
&& ((PlayerDisguise) disguise).getName().equals(playerName)) {
|
if (disguise.getType() == DisguiseType.PLAYER
|
||||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
&& ((PlayerDisguise) disguise).getName().equals(playerName)) {
|
||||||
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
|
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
if (disguise.getEntity() instanceof Player
|
||||||
|
&& disguise.isSelfDisguiseVisible()) {
|
||||||
|
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(),
|
||||||
|
disguise);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,31 +377,6 @@ public class DisguiseUtilities {
|
|||||||
return ReflectionManager.grabSkullBlob(gameprofile);
|
return ReflectionManager.grabSkullBlob(gameprofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is safe to call from the main thread
|
|
||||||
*/
|
|
||||||
public static void lookupGameProfileAndStore(final String playerName) {
|
|
||||||
if (!gameProfiles.containsKey(playerName)) {
|
|
||||||
gameProfiles.put(playerName, null);
|
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(libsDisguises, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
final Object gameProfile = lookupGameProfile(playerName);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
|
||||||
gameProfiles.put(playerName, gameProfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Resends
|
* @param Resends
|
||||||
* the entity to all the watching players, which is where the magic begins
|
* the entity to all the watching players, which is where the magic begins
|
||||||
|
@ -201,7 +201,7 @@ public class PacketsManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Object gameProfile = null;
|
Object gameProfile = null;
|
||||||
gameProfile = DisguiseUtilities.getProfile(((PlayerDisguise) disguise).getName());
|
gameProfile = DisguiseUtilities.getProfileFromMojang(((PlayerDisguise) disguise).getName());
|
||||||
spawnPackets[0].getModifier().write(1, gameProfile);
|
spawnPackets[0].getModifier().write(1, gameProfile);
|
||||||
}
|
}
|
||||||
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
||||||
|
Loading…
Reference in New Issue
Block a user