Ejemplo n.º 1
0
 public static WrappedGameProfile getGameProfileWithThisSkin(
     UUID uuid, String playerName, WrappedGameProfile profileWithSkin) {
   try {
     WrappedGameProfile gameProfile =
         new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
     if (LibVersion.is1_7_6()) {
       gameProfile.getProperties().putAll(profileWithSkin.getProperties());
     }
     return gameProfile;
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return null;
 }
Ejemplo n.º 2
0
 private static WrappedGameProfile getProfileFromMojang(
     final String origName, final Object runnable) {
   final String playerName = origName.toLowerCase();
   if (gameProfiles.containsKey(playerName)) {
     if (gameProfiles.get(playerName) != null) {
       return gameProfiles.get(playerName);
     }
   } else if (Pattern.matches("([A-Za-z0-9_]){1,16}", origName)) {
     getAddedByPlugins().add(playerName);
     Player player = Bukkit.getPlayerExact(playerName);
     if (player != null) {
       WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player);
       if (!LibVersion.is1_7_6() || !gameProfile.getProperties().isEmpty()) {
         gameProfiles.put(playerName, gameProfile);
         return gameProfile;
       }
     }
     // Add null so that if this is called again. I already know I'm doing something about it
     gameProfiles.put(playerName, null);
     Bukkit.getScheduler()
         .runTaskAsynchronously(
             libsDisguises,
             new Runnable() {
               public void run() {
                 try {
                   final WrappedGameProfile gameProfile = lookupGameProfile(origName);
                   Bukkit.getScheduler()
                       .runTask(
                           libsDisguises,
                           new Runnable() {
                             public void run() {
                               if (!LibVersion.is1_7_6()
                                   || !gameProfile.getProperties().isEmpty()) {
                                 if (gameProfiles.containsKey(playerName)
                                     && gameProfiles.get(playerName) == null) {
                                   gameProfiles.put(playerName, gameProfile);
                                 }
                                 if (runnables.containsKey(playerName)) {
                                   for (Object obj : runnables.remove(playerName)) {
                                     if (obj instanceof Runnable) {
                                       ((Runnable) obj).run();
                                     } else if (obj instanceof LibsProfileLookup) {
                                       ((LibsProfileLookup) obj).onLookup(gameProfile);
                                     }
                                   }
                                 }
                               }
                             }
                           });
                 } catch (Exception e) {
                   if (gameProfiles.containsKey(playerName)
                       && gameProfiles.get(playerName) == null) {
                     gameProfiles.remove(playerName);
                     getAddedByPlugins().remove(playerName);
                   }
                   System.out.print(
                       "[LibsDisguises] Error when fetching "
                           + playerName
                           + "'s uuid from mojang: "
                           + e.getMessage());
                 }
               }
             });
   } else {
     return ReflectionManager.getGameProfile(null, origName);
   }
   if (runnable != null) {
     if (!runnables.containsKey(playerName)) {
       runnables.put(playerName, new ArrayList<Object>());
     }
     runnables.get(playerName).add(runnable);
   }
   return ReflectionManager.getGameProfile(null, origName);
 }