org.bukkit.Skin Java Examples

The following examples show how to use org.bukkit.Skin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabRender.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
private void appendAddition(TabEntry entry, int index) {
  Skin skin = entry.getSkin(this.view);
  BaseComponent displayName = this.getContent(entry, index);
  this.addPacket.b.add(
      NMSHacks.playerListPacketData(
          this.addPacket,
          entry.getId(),
          entry.getName(this.view),
          displayName,
          entry.getGamemode(),
          entry.getPing(),
          entry.getSkin(this.view)));

  // Due to a client bug, display name is ignored in ADD_PLAYER packets,
  // so we have to send an UPDATE_DISPLAY_NAME afterward.
  this.updatePacket.b.add(
      NMSHacks.playerListPacketData(this.updatePacket, entry.getId(), displayName));

  this.updateFakeEntity(entry, true);
}
 
Example #2
Source File: XMLUtils.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Skin parseUnsignedSkin(@Nullable Node node) throws InvalidXMLException {
    if(node == null) return null;
    String data = node.getValueNormalize();
    try {
        Base64.decodeBase64(data.getBytes());
    } catch(IllegalArgumentException e) {
        throw new InvalidXMLException("Skin data is not valid base64", node);
    }
    return new Skin(data, null);
}
 
Example #3
Source File: ItemConfigurationParser.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public Skin needSkin(String text) {
    return MapUtils.computeIfAbsent(skins, text, t -> {
        final ConfigurationSection skinSection = root.getConfigurationSection("skins");
        if(skinSection != null) {
            final String referenced = skinSection.getString(text);
            if(referenced != null && !referenced.equals(text)) {
                return needSkin(referenced);
            }
        }
        return new Skin(text, null);
    });
}
 
Example #4
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static PacketPlayOutPlayerInfo.PlayerInfoData playerListPacketData(PacketPlayOutPlayerInfo packet, UUID uuid, String name, @Nullable BaseComponent displayName, GameMode gamemode, int ping, @Nullable Skin skin) {
    GameProfile profile = new GameProfile(uuid, name);
    if(skin != null) {
        for(Map.Entry<String, Collection<Property>> entry : Skins.toProperties(skin).asMap().entrySet()) {
            profile.getProperties().putAll(entry.getKey(), entry.getValue());
        }
    }
    PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(profile, ping, gamemode == null ? null : EnumGamemode.getById(gamemode.getValue()), null);
    data.displayName = displayName == null ? null : new BaseComponent[]{ displayName };
    return data;
}
 
Example #5
Source File: SkinCommands.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Command(aliases = {"info"},
         desc = "Dump the encoded data for a player's skin",
         usage = "[player]")
public void info(CommandContext args, CommandSender sender) throws CommandException {
    Skin skin = CommandUtils.getPlayerOrSelf(args, sender, 0).getSkin();
    sender.sendMessage(ChatColor.BLUE + "Textures: " + ChatColor.WHITE + skin.getData());
    sender.sendMessage(ChatColor.BLUE + "Signature: " + ChatColor.WHITE + skin.getSignature());
}
 
Example #6
Source File: SkinCommands.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Command(aliases = {"none"},
         desc = "Clear a player's skin, making them steve/alex",
         usage = "[player]")
public void none(CommandContext args, CommandSender sender) throws CommandException {
    Player player = CommandUtils.getPlayerOrSelf(args, sender, 0);

    player.setSkin(Skin.EMPTY);
    sender.sendMessage(ChatColor.WHITE + "Cleared the skin of " + player.getDisplayName(sender));
}
 
Example #7
Source File: PlayerAppearanceChanger.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Refresh the given player's fake appearance for the given viewer, assuming the given identity
 */
private void refreshFakeNameAndSkin(Player player, Identity identity, @Nullable String fakeDisplayName, Player viewer) {
    if(identity.isRevealed(viewer)) {
        player.setFakeNameAndSkin(viewer, null, null);
        player.setFakeDisplayName(viewer, null);
    } else {
        player.setFakeNameAndSkin(viewer, identity.getNickname(), Skin.EMPTY);
        player.setFakeDisplayName(viewer, fakeDisplayName);
    }
}
 
Example #8
Source File: TabEntry.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
/** Skin for the entry's icon */
@Nullable
Skin getSkin(TabView view);
 
Example #9
Source File: SimpleTabEntry.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public @Nullable Skin getSkin(TabView view) {
  return DEFAULT_SKIN;
}
 
Example #10
Source File: PlayerTabEntry.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public @Nullable Skin getSkin(TabView view) {
  return this.player.getSkin();
}
 
Example #11
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Packet playerListAddPacket(UUID uuid, String name, @Nullable BaseComponent displayName, GameMode gamemode, int ping, @Nullable Skin skin) {
    PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
    packet.add(playerListPacketData(packet, uuid, name, displayName, gamemode, ping, skin));
    return packet;
}
 
Example #12
Source File: SimpleTabEntry.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public @Nullable Skin getSkin(TabView view) {
    return DEFAULT_SKIN;
}
 
Example #13
Source File: PlayerTabEntry.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public @Nullable Skin getSkin(TabView view) {
    final Identity identity = identityProvider.currentIdentity(player);
    return identity.isDisguised(view.getViewer()) ? null : player.getSkin();
}
 
Example #14
Source File: TabList.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onPlayerChangeSkinParts(PlayerSkinPartsChangeEvent event) {
    getPlayer(event.getPlayer()).setHat(event.getPlayer().getSkinParts().contains(Skin.Part.HAT));
}
 
Example #15
Source File: TabEntry.java    From ProjectAres with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Skin for the entry's icon
 */
@Nullable Skin getSkin(TabView view);