當前位置: 首頁>>代碼示例>>Java>>正文


Java SkullMeta類代碼示例

本文整理匯總了Java中org.bukkit.inventory.meta.SkullMeta的典型用法代碼示例。如果您正苦於以下問題:Java SkullMeta類的具體用法?Java SkullMeta怎麽用?Java SkullMeta使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SkullMeta類屬於org.bukkit.inventory.meta包,在下文中一共展示了SkullMeta類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createHeadPlayer

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static ItemStack createHeadPlayer(String displayname, String username, List<String> lore) {
    ItemStack playerHead = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta sm = (SkullMeta)playerHead.getItemMeta();
    sm.setOwner(username);
    ArrayList<String> colorLore = new ArrayList<>();
    if (lore != null) {
        lore.forEach(str -> colorLore.add(Utils.colorize(str)));
        sm.setLore(colorLore);
    }

    sm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
    sm.setDisplayName(Utils.colorize(displayname));
    playerHead.setItemMeta(sm);
    return playerHead;
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:17,代碼來源:ItemUtil.java

示例2: getSkull

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static ItemStack getSkull(String url) {
    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    if (url.isEmpty())
        return head;
    SkullMeta headMeta = (SkullMeta) head.getItemMeta();
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
    profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
    Field profileField = null;
    try {
        profileField = headMeta.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(headMeta, profile);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
        e1.printStackTrace();
    }
    head.setItemMeta(headMeta);
    return head;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:20,代碼來源:RHead.java

示例3: setItemStackSkin

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static void setItemStackSkin(ItemStack itemStack, String skin) {
    final ItemMeta meta = itemStack.getItemMeta();
    if (!(meta instanceof SkullMeta)) {
        return;
    }

    String newSkin = skin;
    if (newSkin.contains("textures.minecraft.net")) {
        if (!newSkin.startsWith("http://")) {
            newSkin = "http://" + newSkin;
        }
        try {
            final Class<?> cls = createClass("org.bukkit.craftbukkit.VERSION.inventory.CraftMetaSkull");
            final Object real = cls.cast(meta);
            final Field field = real.getClass().getDeclaredField("profile");
            field.setAccessible(true);
            field.set(real, getNonPlayerProfile(newSkin));
            itemStack.setItemMeta(SkullMeta.class.cast(real));
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException | ClassNotFoundException e) {
            Bukkit.getLogger().log(Level.WARNING, "Failed to set url of itemstack.", e);
        }
    } else {
        ((SkullMeta) meta).setOwner(skin);
        itemStack.setItemMeta(meta);
    }
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:27,代碼來源:SkinHelper.java

示例4: createPlayerHead

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
private ItemStack createPlayerHead(Player player)
{
    AbstractPlayerData playerData = SamaGamesAPI.get().getPlayerManager().getPlayerData(player.getUniqueId());

    ItemStack stack = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
    SkullMeta meta = (SkullMeta) stack.getItemMeta();
    meta.setOwner(player.getName());
    meta.setDisplayName(PlayerUtils.getFullyFormattedPlayerName(player));

    List<String> lore = new ArrayList<>();
    lore.add(ChatColor.GRAY + "Pièces : " + ChatColor.GOLD + NumberUtils.format(playerData.getCoins()));
    lore.add(ChatColor.GRAY + "Perles : " + ChatColor.GREEN + NumberUtils.format(this.hub.getInteractionManager().getGraouManager().getPlayerPearls(player.getUniqueId()).size()));
    lore.add(ChatColor.GRAY + "Poussière d'" + ChatColor.AQUA + "\u272F" + ChatColor.GRAY + " : " + ChatColor.AQUA + NumberUtils.format(playerData.getPowders()));

    meta.setLore(lore);
    stack.setItemMeta(meta);

    return stack;
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:20,代碼來源:GuiProfile.java

示例5: createSkullItemStack

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static ItemStack createSkullItemStack(String uuid, String textureValue, String textureSignature) {

		WrappedGameProfile wrappedProfile = new WrappedGameProfile(UUID.fromString(uuid), null);
		wrappedProfile.getProperties().put("textures", new WrappedSignedProperty("textures", textureValue, textureSignature));

		ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
		SkullMeta sm = (SkullMeta) skull.getItemMeta();

		Field profileField = null;
		try {
			profileField = sm.getClass().getDeclaredField("profile");
			profileField.setAccessible(true);
			profileField.set(sm, wrappedProfile.getHandle());
		} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
			e1.printStackTrace();
		}

		skull.setItemMeta(sm);
		return skull;
	}
 
開發者ID:RoboTricker,項目名稱:Transport-Pipes,代碼行數:21,代碼來源:InventoryUtils.java

示例6: getNameComponent

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static BaseComponent getNameComponent(ItemStack item) {
    if (item == null) throw new IllegalArgumentException();
    if (item.hasItemMeta() && item.getItemMeta().hasDisplayName())
        return new TextComponent(item.getItemMeta().getDisplayName());
    Material type = item.getType();
    if (type == Material.SKULL_ITEM && item.getDurability() == 3) {
        SkullMeta meta = (SkullMeta) item.getItemMeta();
        if (meta.hasOwner()) {
            return new TranslatableComponent("item.skull.player.name", meta.getOwner());
        } else {
            return new TranslatableComponent("item.skull.char.name");
        }
    } else {
        return new TranslatableComponent(getUnlocalizedName(item));
    }
}
 
開發者ID:NyaaCat,項目名稱:NyaaCore,代碼行數:17,代碼來源:LocaleUtils.java

示例7: activateHeadByURL

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static ItemStack activateHeadByURL(String skinUrl, ItemStack itemStack) {
    if (itemStack.getType() == Material.SKULL_ITEM) {
        SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
        try {
            final Class<?> cls = ReflectionLib.getClassFromName("org.bukkit.craftbukkit.VERSION.inventory.CraftMetaSkull");
            final Object real = cls.cast(meta);
            final Field field = real.getClass().getDeclaredField("profile");
            field.setAccessible(true);
            field.set(real, getNonPlayerProfile(skinUrl));
            meta = SkullMeta.class.cast(real);
            itemStack.setItemMeta(meta);
            itemStack = new ItemStackBuilder(itemStack).setDisplayName("TMP");
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
            Bukkit.getLogger().log(Level.WARNING, "Failed to set url of itemstack.", e);
        }
    }
    return itemStack;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:19,代碼來源:SSKulls.java

示例8: onPlayerDeath

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
/**
 * Drop player head on kill
 *
 * @param event Event
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);

    SkullMeta skullMeta = (SkullMeta)head.getItemMeta();
    skullMeta.setOwner(event.getEntity().getName());
    skullMeta.setDisplayName(ChatColor.AQUA + "Tête de " + event.getEntity().getName());

    head.setItemMeta(skullMeta);
    event.getDrops().add(head);

    List<PotionEffect> effectList = new ArrayList<>();
    effectList.addAll(event.getEntity().getActivePotionEffects());

    this.effects.put(event.getEntity().getName(), effectList);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:23,代碼來源:CookieHeadModule.java

示例9: onPlayerInteract

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
/**
 * Give old player enchants on head eating
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3
            || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
        return;

    SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta();
    List<PotionEffect> effectList = this.effects.get(skullMeta.getOwner());

    if (effectList != null)
    {
        effectList.forEach(event.getPlayer()::addPotionEffect);
        this.effects.remove(skullMeta.getOwner());
        event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1F, 1F);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:23,代碼來源:CookieHeadModule.java

示例10: gui

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
@Subcommand("gui")
@CommandPermission("%admin")
public void gui(@Nonnull User sender) {
    if (editMode.contains(sender.getUuid())) {
        PagedInventory inventory = inventoryHandler.createInventory(PagedInventory.class, sender, Lang.legacy(LangKey.INV_MARKER), 9);

        Map<ItemStack, BiConsumer<ItemStack, User>> content = new HashMap<>();
        mapHandler.getMarkerDefinitions().forEach(markerDefinition -> {
            ItemStack is = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(markerDefinition.getPrefix())
                    .meta((itemMeta -> ((SkullMeta) itemMeta).setOwner(markerDefinition.getPrefix()))).build();
            content.put(is, (item, user) -> user.getPlayer().performCommand("editmode skull " + is.getItemMeta().getDisplayName()));
        });
        inventory.autoConstructPages(content.keySet().toArray(new ItemStack[content.size()]));
        content.forEach(inventory::addClickAction);
        inventory.open();
    } else {
        Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:20,代碼來源:EditMode.java

示例11: applyTextureToMeta

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static SkullMeta applyTextureToMeta(Object meta, Object profile) throws Exception {
    if (meta == null) {
        throw new IllegalArgumentException("meta cannot be null");
    }
    if (profile == null) {
        throw new IllegalArgumentException("profile cannot be null");
    }
    Object baseNBTTag = NBTTagCompound.newInstance();
    Object ownerNBTTag = NBTTagCompound.newInstance();

    GameProfileSerializerMethodResolver.resolve(new ResolverQuery("serialize", NBTTagCompound, GameProfile)).invoke(null, ownerNBTTag, profile);
    NBTTagCompoundMethodResolver.resolve(new ResolverQuery("set", String.class, NBTBase)).invoke(baseNBTTag, "SkullOwner", ownerNBTTag);

    SkullMeta newMeta = (SkullMeta) CraftMetaSkullConstructorResolver.resolve(new Class[]{NBTTagCompound}).newInstance(baseNBTTag);

    Field profileField = CraftMetaSkullFieldResolver.resolve("profile");
    profileField.set(meta, profile);
    profileField.set(newMeta, profile);

    return newMeta;
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:22,代碼來源:HeadTextureChanger.java

示例12: createHeadPlayer

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static ItemStack createHeadPlayer(String displayname, String username, List<String> lore) {
    ItemStack playerHead = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta sm = (SkullMeta) playerHead.getItemMeta();
    sm.setOwner(username);
    ArrayList<String> colorLore = new ArrayList<>();
    if (lore != null) {
        lore.forEach(str -> colorLore.add(Utils.colorize(str)));
        sm.setLore(colorLore);
    }

    sm.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
    sm.setDisplayName(Utils.colorize(displayname));
    playerHead.setItemMeta(sm);
    return playerHead;
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:17,代碼來源:ItemUtil.java

示例13: getSkullFromURL

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static ItemStack getSkullFromURL(String url, String name)
		throws Exception {
	ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
	SkullMeta sm = (SkullMeta) skull.getItemMeta();
	sm.setOwner("NacOJerk");
	skull.setItemMeta(sm);
	url = Base64Coder.encodeString("{textures:{SKIN:{url:\"" + url
			+ "\"}}}");
	GameProfile gp = new GameProfile(UUID.randomUUID(), name);
	gp.getProperties().put("textures", new Property("textures", url));
	Object isskull = asNMSCopy(skull);
	Object nbt = getNMS("NBTTagCompound").getConstructor().newInstance();
	Method serialize = getNMS("GameProfileSerializer").getMethod(
			"serialize", getNMS("NBTTagCompound"), GameProfile.class);
	serialize.invoke(null, nbt, gp);
	Object nbtr = isskull.getClass().getMethod("getTag").invoke(isskull);
	nbtr.getClass().getMethod("set", String.class, getNMS("NBTBase"))
			.invoke(nbtr, "SkullOwner", nbt);
	isskull.getClass().getMethod("setTag", getNMS("NBTTagCompound"))
			.invoke(isskull, nbtr);
	skull = asBukkitCopy(isskull);
	return skull;
}
 
開發者ID:NacOJerk,項目名稱:Pokecraft,代碼行數:24,代碼來源:ItemStackUtils.java

示例14: setSkullTexture

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
@Override
public SkullMeta setSkullTexture(SkullMeta meta, String skinUrl) {
    if (meta == null) {
        return meta;
    }

    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    profile.getProperties().put("textures", new Property("textures", new String(Utils.getSkullTexture(skinUrl))));

    try {
        Field profileField = meta.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(meta, profile);

    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return meta;
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:20,代碼來源:ItemUtils_V1_10_R1.java

示例15: createMemberMenu

import org.bukkit.inventory.meta.SkullMeta; //導入依賴的package包/類
public static List<Inventory> createMemberMenu(Clans clan){
	Clan clanProfile = new Clan(clan);
	List<Inventory> pages = new ArrayList<Inventory>();
	int page = 1;
	pages.add(Bukkit.createInventory(null, 54, "Page "+page));
	List<ca.damocles.accountsystem.Character> clansmen = clanProfile.getClansmen();
	for(ca.damocles.accountsystem.Character members : clansmen){
	       ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal());
	       SkullMeta meta = (SkullMeta) skull.getItemMeta();
	       meta.setOwningPlayer(Bukkit.getOfflinePlayer(members.uuid));
	         skull.setItemMeta(meta);
		if(pages.get(pages.size()-1).firstEmpty() == -1){
			page = page+1;
			pages.add(Bukkit.createInventory(null, 54, "Page "+page));
			pages.get(pages.size()-1).addItem(skull);
		}else{
			pages.get(pages.size()-1).addItem(skull);
		}
		members.getPlayer().updateInventory();
	}
	return pages;
}
 
開發者ID:DamoclesProject,項目名稱:Damocles,代碼行數:23,代碼來源:ClanMenu.java


注:本文中的org.bukkit.inventory.meta.SkullMeta類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。