Search in sources :

Example 1 with Skin

use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.

the class EditMode method gui.

@Subcommand("gui")
@CommandPermission("%admin")
public void gui(@Nonnull User sender) {
    if (editMode.contains(sender.getUuid())) {
        // TODO implement paginated invs
        InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle(Lang.legacy(LangKey.INV_MARKER));
        for (int i = 0; i < mapHandler.getMarkerDefinitions().size(); i++) {
            MarkerDefinition markerDefinition = mapHandler.getMarkerDefinitions().get(i);
            ItemStack is = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(markerDefinition.getPrefix()).meta((itemMeta -> {
                char prefix = markerDefinition.getPrefix().toUpperCase().charAt(0);
                Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
                ((SkullMeta) itemMeta).setPlayerProfile(textureHandler.getPlayerProfile(skin));
                ((SkullMeta) itemMeta).setOwner(markerDefinition.getPrefix());
            })).build();
            builder.withItem(i, is, (player, clickType, itemStack) -> sender.getPlayer().performCommand("editmode skull " + itemStack.getItemMeta().getDisplayName()), ClickType.LEFT);
        }
        builder.show(sender.getPlayer());
    } else {
        Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
    }
}
Also used : ItemBuilder(com.voxelgameslib.voxelgameslib.utils.ItemBuilder) InventoryMenuBuilder(org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder) VoxelGameLibException(com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException) Skin(org.mineskin.data.Skin) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) MarkerDefinition(com.voxelgameslib.voxelgameslib.map.MarkerDefinition) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 2 with Skin

use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.

the class EditMode method skull.

@Subcommand("skull")
@CommandPermission("%admin")
@Syntax("<name> - the name of the skull")
public void skull(@Nonnull User sender, @Nonnull String name) {
    if (editMode.contains(sender.getUuid())) {
        ItemStack skull = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(name).meta((itemMeta -> {
            char prefix = name.toUpperCase().charAt(0);
            Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
            ((SkullMeta) itemMeta).setPlayerProfile(textureHandler.getPlayerProfile(skin));
            ((SkullMeta) itemMeta).setOwner(name);
        })).build();
        sender.getPlayer().getInventory().setItemInMainHand(skull);
    } else {
        Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
    }
}
Also used : ItemBuilder(com.voxelgameslib.voxelgameslib.utils.ItemBuilder) VoxelGameLibException(com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException) Skin(org.mineskin.data.Skin) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) Subcommand(co.aikar.commands.annotation.Subcommand) Syntax(co.aikar.commands.annotation.Syntax) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 3 with Skin

use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.

the class TextureHandler method loadSkin.

@Nullable
public Skin loadSkin(@Nonnull String name) {
    try {
        FileReader fr = new FileReader(new File(skinsFolder, name + ".json"));
        Skin skin = gson.fromJson(fr, Skin.class);
        fr.close();
        loadedSkins.add(skin);
        return skin;
    } catch (Exception ex) {
        log.log(Level.WARNING, "could not load skin " + name, ex);
    }
    return null;
}
Also used : FileReader(java.io.FileReader) Skin(org.mineskin.data.Skin) File(java.io.File) IOException(java.io.IOException) Nullable(javax.annotation.Nullable)

Example 4 with Skin

use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.

the class TextureListener method doStuff.

public Skin doStuff(PlayerProfile playerProfile) {
    Skin skin = textureHandler.getSkin(118300).orElseThrow(() -> new RuntimeException("d"));
    playerProfile.clearProperties();
    playerProfile.setProperty(new ProfileProperty("textures", skin.data.texture.value, skin.data.texture.signature));
    return skin;
}
Also used : ProfileProperty(com.destroystokyo.paper.profile.ProfileProperty) Skin(org.mineskin.data.Skin)

Example 5 with Skin

use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.

the class TextureListener method onLogin.

@EventHandler
public void onLogin(com.destroystokyo.paper.event.profile.PreLookupProfileEvent e) {
    Skin skin = doStuff(Bukkit.createProfile(e.getUUID(), e.getName()));
    e.setProfileProperties(new HashSet<ProfileProperty>() {

        {
            add(new ProfileProperty("textures", skin.data.texture.value, skin.data.texture.signature));
        }
    });
}
Also used : ProfileProperty(com.destroystokyo.paper.profile.ProfileProperty) Skin(org.mineskin.data.Skin) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Skin (org.mineskin.data.Skin)7 IOException (java.io.IOException)3 CommandPermission (co.aikar.commands.annotation.CommandPermission)2 Subcommand (co.aikar.commands.annotation.Subcommand)2 ProfileProperty (com.destroystokyo.paper.profile.ProfileProperty)2 VoxelGameLibException (com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException)2 ItemBuilder (com.voxelgameslib.voxelgameslib.utils.ItemBuilder)2 ItemStack (org.bukkit.inventory.ItemStack)2 SkullMeta (org.bukkit.inventory.meta.SkullMeta)2 SkinCallback (org.mineskin.data.SkinCallback)2 Syntax (co.aikar.commands.annotation.Syntax)1 MarkerDefinition (com.voxelgameslib.voxelgameslib.map.MarkerDefinition)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Nullable (javax.annotation.Nullable)1 EventHandler (org.bukkit.event.EventHandler)1 InventoryMenuBuilder (org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder)1