mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-12 01:48:07 +02:00
Just make it a runnable. More convident for my plugins
This commit is contained in:
parent
43e6e6cc36
commit
4e09a64abb
@ -263,15 +263,28 @@ public class DisguiseUtilities {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getProfileFromMojang(String playerName) {
|
public static Object getProfileFromMojang(final String playerName) {
|
||||||
return getProfileFromMojang(playerName, true);
|
return getProfileFromMojang(playerName, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* 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.
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static Object getProfileFromMojang(final String playerName, final boolean updateDisguises) {
|
public static Object getProfileFromMojang(final String playerName, final Runnable runnable) {
|
||||||
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);
|
||||||
@ -295,20 +308,8 @@ 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);
|
||||||
if (updateDisguises) {
|
if (runnable != null) {
|
||||||
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
runnable.run();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user