Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ItemStack getHeadStack(HeadObject object) throws InstantiationException, NumberFormatException
- {
- UUID uuid = UUID.fromString(object.uuid);
- GameProfile profile = GameProfile.of(uuid);
- profile
- .getPropertyMap()
- .put("textures", ProfileProperty.of(object.displayName, object.value));
- List<Text> lore = new ArrayList<>();
- if(object.displayLore != null)
- {
- for(String line : object.displayLore)
- {
- lore.add(TextSerializers.FORMATTING_CODE.deserialize(line));
- }
- }
- ItemStack stack =
- Sponge.getGame()
- .getRegistry()
- .createBuilder(ItemStack.Builder.class)
- .itemType(ItemTypes.SKULL)
- .add(Keys.DISPLAY_NAME, Text.of(TextColors.AQUA, object.displayName))
- .add(Keys.ITEM_LORE, lore)
- .build();
- Optional<SkullData> opSkullData =
- Optional.of(
- Sponge.getGame()
- .getDataManager()
- .getManipulatorBuilder(SkullData.class)
- .get()
- .create()
- .set(Keys.SKULL_TYPE, SkullTypes.PLAYER));
- Optional<RepresentedPlayerData> opSkinData =
- Optional.of(
- Sponge.getGame()
- .getDataManager()
- .getManipulatorBuilder(RepresentedPlayerData.class)
- .get()
- .create()
- .set(Keys.REPRESENTED_PLAYER, profile));
- SkullData skullData = opSkullData.orElseThrow(InstantiationError::new);
- RepresentedPlayerData skinData = opSkinData.orElseThrow(InstantiationException::new);
- stack.offer(skullData);
- stack.offer(skinData);
- return stack;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement