@Override public void onProfileLookupSucceeded(GameProfile profile) { gameProfile = WrappedGameProfile.fromHandle(profile); }
@Override public WrappedGameProfile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = json.getAsJsonObject(); if (obj.has("id") && !obj.get("id").getAsString().contains("-")) { obj.addProperty("id", Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)") .matcher(obj.get("id").getAsString()).replaceFirst("$1-$2-$3-$4-$5")); } return WrappedGameProfile.fromHandle(context.deserialize(json, GameProfile.class)); } }
/** * Retrieve the associated game profile of an offline player. * <p> * Note that this may not exist in the current Minecraft version. * * @param player - the offline player. * @return The game profile. */ public static WrappedGameProfile fromOfflinePlayer(OfflinePlayer player) { FieldAccessor accessor = OFFLINE_PROFILE; if (accessor == null) { accessor = Accessors.getFieldAccessor(player.getClass(), GAME_PROFILE, true); OFFLINE_PROFILE = accessor; } return WrappedGameProfile.fromHandle(OFFLINE_PROFILE.get(player)); }
public static WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) { try { Object minecraftServer = getMinecraftServer(); for (Method method : getNmsClass("MinecraftServer").getMethods()) { if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) { Object session = method.invoke(minecraftServer); return WrappedGameProfile.fromHandle(session.getClass() .getDeclaredMethod("fillProfileProperties", gameProfile.getHandleType(), boolean.class) .invoke(session, gameProfile.getHandle(), true)); } } } catch (Exception ex) { ex.printStackTrace(); } return null; }
/** * Set the displayed lst of logged in players. * @param players - the players to display. */ public void setBukkitPlayers(Iterable<? extends Player> players) { List<WrappedGameProfile> profiles = Lists.newArrayList(); for (Player player : players) { Object profile = ENTITY_HUMAN_PROFILE.get(BukkitUnwrapper.getInstance().unwrapItem(player)); profiles.add(WrappedGameProfile.fromHandle(profile)); } setPlayers(profiles); }
WrappedGameProfile profile = WrappedGameProfile.fromHandle(LOGIN_GAME_PROFILE.get(packet));
/** * Retrieve the associated game profile of a player. * <p> * Note that this may not exist in the current Minecraft version. * * @param player - the player. * @return The game profile. */ public static WrappedGameProfile fromPlayer(Player player) { FieldAccessor accessor = PLAYER_PROFILE; if (accessor == null) { accessor = Accessors.getFieldAccessor(MinecraftReflection.getEntityHumanClass(), GAME_PROFILE, true); PLAYER_PROFILE = accessor; } Object nmsPlayer = BukkitUnwrapper.getInstance().unwrapItem(player); return WrappedGameProfile.fromHandle(PLAYER_PROFILE.get(nmsPlayer)); }