mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-08-22 22:53:01 +02:00
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;
|
||||
}
|
||||
|
||||
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.get(playerName) != null) {
|
||||
return gameProfiles.get(playerName);
|
||||
|
@ -287,13 +295,17 @@ public class DisguiseUtilities {
|
|||
public void run() {
|
||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
||||
gameProfiles.put(playerName, gameProfile);
|
||||
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||
for (TargetedDisguise disguise : disguises) {
|
||||
if (disguise.getType() == DisguiseType.PLAYER
|
||||
&& ((PlayerDisguise) disguise).getName().equals(playerName)) {
|
||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
||||
if (disguise.getEntity() instanceof Player && disguise.isSelfDisguiseVisible()) {
|
||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
||||
if (updateDisguises) {
|
||||
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||
for (TargetedDisguise disguise : disguises) {
|
||||
if (disguise.getType() == DisguiseType.PLAYER
|
||||
&& ((PlayerDisguise) disguise).getName().equals(playerName)) {
|
||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* the entity to all the watching players, which is where the magic begins
|
||||
|
|
|
@ -201,7 +201,7 @@ public class PacketsManager {
|
|||
}
|
||||
} else {
|
||||
Object gameProfile = null;
|
||||
gameProfile = DisguiseUtilities.getProfile(((PlayerDisguise) disguise).getName());
|
||||
gameProfile = DisguiseUtilities.getProfileFromMojang(((PlayerDisguise) disguise).getName());
|
||||
spawnPackets[0].getModifier().write(1, gameProfile);
|
||||
}
|
||||
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
||||
|
|
Loading…
Reference in New Issue
Block a user