/** * Construct a new game profile with the same name, but different id. * * @param id - the new id of the profile to create. * @return The new game profile. */ public WrappedGameProfile withId(String id) { return new WrappedGameProfile(id, getName()); }
@Override public int hashCode() { // Mojang's hashCode() is broken, it doesn't handle NULL id or name. So we implement our own return Objects.hashCode(getId(), getName()); }
public static WrappedGameProfile getClonedProfile(WrappedGameProfile gameProfile) { return getGameProfileWithThisSkin(null, gameProfile.getName(), gameProfile); }
public void setGameProfile(WrappedGameProfile gameProfile) { this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, gameProfile.getName(), gameProfile); }
public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) { try { Object playerListName = getNmsClass("ChatComponentText").getDeclaredConstructor(String.class) .newInstance(gameProfile.getName()); return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData") .getDeclaredConstructor(getNmsClass("PacketPlayOutPlayerInfo"), gameProfile.getHandleType(), int.class, getNmsClass("EnumGamemode"), getNmsClass("IChatBaseComponent")) .newInstance(playerInfoPacket, gameProfile.getHandle(), 0, getNmsClass("EnumGamemode").getEnumConstants()[1], playerListName); } catch (Exception ex) { ex.printStackTrace(); } return null; }
/** * Retrieve the UUID of the player. * <p> * Note that Minecraft 1.7.5 and earlier doesn't use UUIDs internally, and it may not be possible to convert the string to an UUID. * <p> * We use the same lax conversion as in {@link #WrappedGameProfile(String, String)}. * * @return The UUID, or NULL if the UUID is NULL. * @throws IllegalStateException If we cannot parse the internal ID as an UUID. */ public UUID getUUID() { UUID uuid = parsedUUID; if (uuid == null) { try { if (GET_UUID_STRING != null) { uuid = parseUUID(getId()); } else if (GET_ID != null) { uuid = (UUID) GET_ID.invoke(handle); } else { throw new IllegalStateException("Unsupported getId() method"); } // Cache for later parsedUUID = uuid; } catch (IllegalArgumentException e) { throw new IllegalStateException("Cannot parse ID " + getId() + " as an UUID in player profile " + getName(), e); } } return uuid; }
@Override public void onLookup(WrappedGameProfile gameProfile) { if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName() .equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) || !gameProfile.getProperties().isEmpty())) { disguise.setGameProfile(gameProfile); DisguiseUtilities.refreshTrackers(disguise); } } }, LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true));
private static WrappedGameProfile getSentName(int sentEntityId, WrappedGameProfile sent, Player destinationPlayer) { // Preconditions.checkState(Bukkit.getServer().isPrimaryThread(), "Can only process events on main thread."); Player namedPlayer = entityIdMap.get(sentEntityId); if (namedPlayer == null) { // They probably were dead when we reloaded return sent; } PlayerReceiveNameTagEvent oldEvent = new PlayerReceiveNameTagEvent(destinationPlayer, namedPlayer, sent.getName()); Bukkit.getServer().getPluginManager().callEvent(oldEvent); StringBuilder builtUUID = new StringBuilder(); if (!sent.getId().contains("-")) { IntStream.range(0, uuidSplit.length - 1).forEach(i -> builtUUID.append(sent.getId(), uuidSplit[i], uuidSplit[i + 1]).append("-")); } else { builtUUID.append(sent.getId()); } AsyncPlayerReceiveNameTagEvent newEvent = new AsyncPlayerReceiveNameTagEvent(destinationPlayer, namedPlayer, getPlayerDisplayName(namedPlayer), UUID.fromString(builtUUID.toString())); Bukkit.getServer().getPluginManager().callEvent(newEvent); return new WrappedGameProfile(newEvent.getUUID(), newEvent.getTag().substring(0, Math.min(newEvent.getTag().length(), 16))); }
factory.cacheInjector(profile.getName(), this);
addTab.getPlayerInfoDataLists().write(0, Collections.singletonList( new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getGameProfile().getName()))));
@Override public PlayerDisguise clone() { PlayerDisguise disguise = new PlayerDisguise(); disguise.playerName = getName(); if (currentLookup == null && gameProfile != null) { disguise.skinToUse = getSkin(); disguise.gameProfile = ReflectionManager .getGameProfileWithThisSkin(disguise.uuid, getGameProfile().getName(), getGameProfile()); } else { disguise.setSkin(getSkin()); } disguise.setReplaceSounds(isSoundsReplaced()); disguise.setViewSelfDisguise(isSelfDisguiseVisible()); disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced()); disguise.setHideArmorFromSelf(isHidingArmorFromSelf()); disguise.setHideHeldItemFromSelf(isHidingHeldItemFromSelf()); disguise.setVelocitySent(isVelocitySent()); disguise.setModifyBoundingBox(isModifyBoundingBox()); if (getWatcher() != null) { disguise.setWatcher(getWatcher().clone(disguise)); } disguise.createDisguise(); return disguise; }