org.bukkit.configuration.MemoryConfiguration#org.bukkit.inventory.meta.SkullMeta源码实例Demo

下面列出了org.bukkit.configuration.MemoryConfiguration#org.bukkit.inventory.meta.SkullMeta 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: XSeries   文件: SkullUtils.java
@SuppressWarnings("deprecation")
@Nonnull
public static SkullMeta applySkin(@Nonnull ItemMeta head, @Nonnull String player) {
    boolean isId = isUUID(getFullUUID(player));
    SkullMeta meta = (SkullMeta) head;

    if (isId || isUsername(player)) {
        if (isId) return getSkullByValue(meta, getSkinValue(player, true));
        if (XMaterial.isNewVersion()) meta.setOwningPlayer(Bukkit.getOfflinePlayer(player));
        else meta.setOwner(player);
    }

    if (player.contains("textures.minecraft.net")) return getValueFromTextures(meta, player);
    if (player.length() > 100 && isBase64(player)) return getSkullByValue(meta, player);
    return getTexturesFromUrlValue(meta, player);
}
 
源代码2 项目: XSeries   文件: SkullUtils.java
@Nonnull
public static SkullMeta getSkullByValue(@Nonnull SkullMeta head, @Nonnull String value) {
    Validate.notEmpty(value, "Skull value cannot be null or empty");
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);

    profile.getProperties().put("textures", new Property("textures", value));
    try {
        Field profileField = head.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(head, profile);
    } catch (SecurityException | NoSuchFieldException | IllegalAccessException ex) {
        ex.printStackTrace();
    }

    return head;
}
 
源代码3 项目: TrMenu   文件: CommandTemplate.java
private ConfigurationSection display(ItemStack item) {
    ConfigurationSection section = new MemoryConfiguration();
    ItemMeta meta = item.getItemMeta();
    String mat = item.getType().name();
    if (meta instanceof SkullMeta) {
        String texture = Skulls.getTexture(item);
        mat = texture != null ? "<skull:" + Skulls.getTexture(item) + ">" : mat;
    }
    if (item.getAmount() > 1) {
        section.set("amount", item.getAmount());
    }
    if (meta != null) {
        if (meta.hasDisplayName()) {
            section.set("name", meta.getDisplayName());
        }
        if (meta.hasLore()) {
            section.set("lore", meta.getLore());
        }
    }
    section.set("mats", mat);
    return section;
}
 
源代码4 项目: TrMenu   文件: TabooMenuMigrater.java
private static String migrateMat(Icon icon) {
    if (icon.getItemSource() != null) {
        ItemStack itemStack = icon.getItemSource();
        if (itemStack.getItemMeta() instanceof SkullMeta) {
            String hdb = HookHeadDatabase.getId(itemStack);
            return Strings.nonEmpty(hdb) ? "<hdb:" + hdb + ">" : "<skull:" + Skulls.getTexture(itemStack) + ">";
        }
    }
    if (Strings.nonEmpty(icon.getSkullTexture())) {
        return "<skull:" + icon.getSkullTexture() + ">";
    } else if (Strings.nonEmpty(icon.getSkullOwner())) {
        return "<head:" + icon.getSkullOwner() + ">";
    } else if (icon.getColor() != null && !(icon.getColor().getRed() == 0 && icon.getColor().getGreen() == 0 && icon.getColor().getBlue() == 0)) {
        return icon.getMaterial().name().toLowerCase() + "<dye:" + icon.getColor().getRed() + "," + icon.getColor().getGreen() + "," + icon.getColor().getBlue() + ">";
    } else if (icon.getBannerPatterns() != null) {
        return icon.getMaterial().name().toLowerCase() + "<banner:" + String.join(",", icon.getBannerPatterns()) + ">";
    } else if (icon.getData() > 0) {
        return icon.getMaterial().name().toLowerCase() + ":" + icon.getData();
    }
    return icon.getMaterial().name().toLowerCase();
}
 
源代码5 项目: QualityArmory   文件: MaterialStorage.java
public static MaterialStorage getMS(ItemStack is, int variant) {

		if (is == null) {
			return EMPTY;
		}

		String extraData = is.getType() == MultiVersionLookup.getSkull() ? ((SkullMeta) is.getItemMeta()).getOwner()
				: null;
		String temp = null;
		if (extraData != null)
			temp = SkullHandler.getURL64(is);
		try {
			return getMS(is.getType(), is.getItemMeta().hasCustomModelData() ? is.getItemMeta().getCustomModelData() : 0, variant,
					is.getType() == MultiVersionLookup.getSkull() ? ((SkullMeta) is.getItemMeta()).getOwner() : null, temp);

		} catch (Error | Exception e4) {
		}
		return getMS(is.getType(), is.getDurability(), variant,
				is.getType() == MultiVersionLookup.getSkull() ? ((SkullMeta) is.getItemMeta()).getOwner() : null, temp);
	}
 
源代码6 项目: Transport-Pipes   文件: ItemService.java
public ItemStack createHeadItem(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.PLAYER_HEAD);
    SkullMeta sm = (SkullMeta) skull.getItemMeta();
    sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(uuid)));

    Field profileField;
    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;
}
 
源代码7 项目: Guilds   文件: SkullUtils.java
/**
 * Get the skull from a url
 * @param skinUrl url to use
 * @return skull
 */
public static ItemStack getSkull(String skinUrl) {
    ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
    if (skinUrl.isEmpty()) return head;

    SkullMeta headMeta = (SkullMeta) head.getItemMeta();
    GameProfile profile = getGameProfile(skinUrl);
    Field profileField;
    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;
}
 
源代码8 项目: ProRecipes   文件: Recipes.java
public ItemStack checkTexture(ItemStack i, ConfigurationSection s, String path){
	if(i == null || i.getType() != MinecraftVersion.getMaterial("SKULL_ITEM","PLAYER_HEAD")){
		return i;
	}
	if(s == null){
		return i;
	}
	SkullMeta meta = (SkullMeta) i.getItemMeta();
	if(meta.hasOwner()){
		return i;
	}
	if(s.contains(path)){
		String texture = s.getString(path + ".texture");
		String id = s.getString(path + ".uuid");
		return ItemUtils.createHead(UUID.fromString(id), i, texture);
	}else{
		return i;
	}
}
 
源代码9 项目: ProRecipes   文件: ItemUtils.java
public static ItemStack createHead(UUID id, ItemStack c, String texture)
 {
   GameProfile profile = createGameProfile(texture, id);
   ItemStack head = c.clone();
   ItemMeta headMeta = head.getItemMeta();
   try {
	ReflectionUtils.setValue(headMeta, headMeta.getClass(), true, "profile", profile);
} catch (IllegalArgumentException | IllegalAccessException
		| NoSuchFieldException | SecurityException e) {
	e.printStackTrace();
}
   head.setItemMeta(headMeta);
   SkullMeta skullMeta = (SkullMeta)head.getItemMeta();
   head.setItemMeta(skullMeta);
   return head.clone();
 }
 
源代码10 项目: CS-CoreLib   文件: SkullItem.java
@Deprecated
public SkullItem(String name, String owner) {
	super(new ItemStack(MaterialHook.parse("PLAYER_HEAD", "SKULL_ITEM")));
	
	if (ReflectionUtils.isVersion("v1_10_", "v1_11_", "v1_12_")) {
		setDurability((short) 3);
	}
	
	ItemMeta im = getItemMeta();
	im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));

	((SkullMeta) im).setOwner(owner);
	
	setItemMeta(im);
	this.owner = owner;
}
 
源代码11 项目: CS-CoreLib   文件: SkullItem.java
@Deprecated
public SkullItem(String name, String owner, String... lore) {
	super(new ItemStack(MaterialHook.parse("PLAYER_HEAD", "SKULL_ITEM")));

	if (ReflectionUtils.isVersion("v1_10_", "v1_11_", "v1_12_")) {
		setDurability((short) 3);
	}
	
	ItemMeta im = getItemMeta();
	im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
	List<String> lines = new ArrayList<>();
	for (String line: lore) {
		lines.add(ChatColor.translateAlternateColorCodes('&', line));
	}
	im.setLore(lines);
	((SkullMeta) im).setOwner(owner);
	setItemMeta(im);
	this.owner = owner;
}
 
源代码12 项目: CS-CoreLib   文件: Config.java
/**
 * Returns the ItemStack at the specified Path
 *
 * @param  path The path in the Config File
 * @return      The ItemStack at that Path
 */ 
public ItemStack getItem(String path) {
	ItemStack item = config.getItemStack(path);
	if (item == null) return null;
	try {
		if (item.hasItemMeta() && item.getItemMeta() instanceof SkullMeta) {
			if (this.contains(path + "_extra.custom-skull")) item = CustomSkull.getItem((ItemStack) item, this.getString(path + "_extra.custom-skull"));
			if (this.contains(path + "_extra.custom-skullOwner") && !((ItemStack) item).getItemMeta().hasDisplayName()) {
				ItemMeta im = ((ItemStack) item).getItemMeta();
				im.setDisplayName(ChatColor.RESET + this.getString(path + "_extra.custom-skullOwner") + "'s Head");
				((ItemStack) item).setItemMeta(im);
			}
		}
		else {
			this.store(path + "_extra.custom-skull", null);
			this.store(path + "_extra.custom-skullOwner", null);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return item;
}
 
源代码13 项目: EliteMobs   文件: LootGUI.java
private void lootNavigationConstructor(Inventory inventory) {

        ItemStack arrowLeft = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        SkullMeta arrowLeftSkullMeta = (SkullMeta) arrowLeft.getItemMeta();
        arrowLeftSkullMeta.setOwner("MHF_ArrowLeft");
        arrowLeftSkullMeta.setDisplayName("Previous Loot Page");
        arrowLeft.setItemMeta(arrowLeftSkullMeta);

        inventory.setItem(27, arrowLeft);


        ItemStack arrowRight = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        SkullMeta arrowRightSkullMeta = (SkullMeta) arrowRight.getItemMeta();
        arrowRightSkullMeta.setOwner("MHF_ArrowRight");
        arrowRightSkullMeta.setDisplayName("Next Loot Page");
        arrowRight.setItemMeta(arrowRightSkullMeta);

        inventory.setItem(35, arrowRight);

    }
 
源代码14 项目: UHC   文件: GoldenHeadsModule.java
@EventHandler
public void on(PrepareItemCraftEvent event) {
    if (event.getRecipe().getResult().getType() != Material.GOLDEN_APPLE) return;

    final ItemStack centre = event.getInventory().getMatrix()[CRAFTING_INVENTORY_CENTRE_SLOT_ID];

    if (centre == null || centre.getType() != Material.SKULL_ITEM) return;

    if (!isEnabled()) {
        event.getInventory().setResult(new ItemStack(Material.AIR));
        return;
    }

    final SkullMeta meta = (SkullMeta) centre.getItemMeta();
    final ItemStack goldenHeadItem = getGoldenHeadItem(meta.hasOwner() ? meta.getOwner() : "Manually Crafted");
    event.getInventory().setResult(goldenHeadItem);
}
 
源代码15 项目: SkyWarsReloaded   文件: MatchManager.java
private void prepareSpectateInv(Player player, GameMap gameMap) {
	int slot = 9;
       for (Player player1: gameMap.getAlivePlayers()) {
           if (player1 != null) {
            ItemStack playerhead1 = SkyWarsReloaded.getNMS().getBlankPlayerHead();
    		SkullMeta meta1 = (SkullMeta)playerhead1.getItemMeta();
    		SkyWarsReloaded.getNMS().updateSkull(meta1, player1);
    		meta1.setDisplayName(ChatColor.YELLOW + player1.getName());
    		List<String> lore = new ArrayList<>();
    		lore.add(new Messaging.MessageFormatter().setVariable("player", player1.getName()).format("spectate.playeritemlore"));
    		meta1.setLore(lore);
    		playerhead1.setItemMeta(meta1);
    		if (player != null) {
				player.getInventory().setItem(slot, playerhead1);
			} else {
    			break;
			}
    		slot++;
           }
       }
	if (player != null) {
		player.updateInventory();
	}
}
 
源代码16 项目: Shopkeepers   文件: Utils.java
public static boolean isCustomHeadItem(ItemStack item) {
	if (item == null) return false;
	if (item.getType() != Material.SKULL_ITEM) {
		return false;
	}
	if (item.getDurability() != SkullType.PLAYER.ordinal()) {
		return false;
	}

	ItemMeta meta = item.getItemMeta();
	if (meta instanceof SkullMeta) {
		SkullMeta skullMeta = (SkullMeta) meta;
		if (skullMeta.hasOwner() && skullMeta.getOwner() == null) {
			// custom head items usually don't have a valid owner
			return true;
		}
	}
	return false;
}
 
源代码17 项目: IridiumSkyblock   文件: Utils.java
public static ItemStack makeItem(Inventories.Item item, List<Placeholder> placeholders) {
    try {
        ItemStack itemstack = makeItem(item.material, item.amount, processMultiplePlaceholders(item.title, placeholders), processMultiplePlaceholders(item.lore, placeholders));
        if (item.material == XMaterial.PLAYER_HEAD && item.headOwner != null) {
            SkullMeta m = (SkullMeta) itemstack.getItemMeta();
            m.setOwner(processMultiplePlaceholders(item.headOwner, placeholders));
            itemstack.setItemMeta(m);
        }
        return itemstack;
    } catch (Exception e) {
        return makeItem(XMaterial.STONE, item.amount, processMultiplePlaceholders(item.title, placeholders), processMultiplePlaceholders(item.lore, placeholders));
    }
}
 
源代码18 项目: IridiumSkyblock   文件: Utils.java
public static ItemStack makeItem(Inventories.Item item) {
    try {
        ItemStack itemstack = makeItem(item.material, item.amount, item.title, item.lore);
        if (item.material == XMaterial.PLAYER_HEAD && item.headOwner != null) {
            SkullMeta m = (SkullMeta) itemstack.getItemMeta();
            m.setOwner(item.headOwner);
            itemstack.setItemMeta(m);
        }
        return itemstack;
    } catch (Exception e) {
        return makeItem(XMaterial.STONE, item.amount, item.title, item.lore);
    }
}
 
源代码19 项目: IridiumSkyblock   文件: Utils.java
public static ItemStack makeItem(Inventories.Item item, Island island) {
    try {
        ItemStack itemstack = makeItem(item.material, item.amount, processIslandPlaceholders(item.title, island), color(processIslandPlaceholders(item.lore, island)));
        if (item.material == XMaterial.PLAYER_HEAD && item.headOwner != null) {
            SkullMeta m = (SkullMeta) itemstack.getItemMeta();
            m.setOwner(item.headOwner);
            itemstack.setItemMeta(m);
        }
        return itemstack;
    } catch (Exception e) {
        return makeItem(XMaterial.STONE, item.amount, processIslandPlaceholders(item.title, island), color(processIslandPlaceholders(item.lore, island)));
    }
}
 
源代码20 项目: IridiumSkyblock   文件: Utils.java
public static ItemStack makeItemHidden(Inventories.Item item) {
    try {
        ItemStack itemstack = makeItemHidden(item.material, item.amount, item.title, item.lore);
        if (item.material == XMaterial.PLAYER_HEAD && item.headOwner != null) {
            SkullMeta m = (SkullMeta) itemstack.getItemMeta();
            m.setOwner(item.headOwner);
            itemstack.setItemMeta(m);
        }
        return itemstack;
    } catch (Exception e) {
        return makeItemHidden(XMaterial.STONE, item.amount, item.title, item.lore);
    }
}
 
源代码21 项目: IridiumSkyblock   文件: Utils.java
public static ItemStack makeItemHidden(Inventories.Item item, List<Placeholder> placeholders) {
    try {
        ItemStack itemstack = makeItemHidden(item.material, item.amount, processMultiplePlaceholders(item.title, placeholders), color(processMultiplePlaceholders(item.lore, placeholders)));
        if (item.material == XMaterial.PLAYER_HEAD && item.headOwner != null) {
            SkullMeta m = (SkullMeta) itemstack.getItemMeta();
            m.setOwner(item.headOwner);
            itemstack.setItemMeta(m);
        }
        return itemstack;
    } catch (Exception e) {
        e.printStackTrace();
        return makeItemHidden(XMaterial.STONE, item.amount, processMultiplePlaceholders(item.title, placeholders), color(processMultiplePlaceholders(item.lore, placeholders)));
    }
}
 
源代码22 项目: XSeries   文件: SkullUtils.java
@SuppressWarnings("deprecation")
@Nonnull
public static ItemStack getSkull(@Nonnull UUID id) {
    ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
    SkullMeta meta = (SkullMeta) head.getItemMeta();

    if (XMaterial.isNewVersion()) meta.setOwningPlayer(Bukkit.getOfflinePlayer(id));
    else meta.setOwner(id.toString());

    head.setItemMeta(meta);
    return head;
}
 
源代码23 项目: PGM   文件: KitParser.java
public ItemStack parseHead(Element el) throws InvalidXMLException {
  ItemStack itemStack = parseItem(el, Material.SKULL_ITEM, (short) 3);
  SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
  meta.setOwner(
      XMLUtils.parseUsername(Node.fromChildOrAttr(el, "name")),
      XMLUtils.parseUuid(Node.fromRequiredChildOrAttr(el, "uuid")),
      XMLUtils.parseUnsignedSkin(Node.fromRequiredChildOrAttr(el, "skin")));
  itemStack.setItemMeta(meta);
  return itemStack;
}
 
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    ItemStack stack = ((Player) sender).getInventory().getItemInMainHand();
    SkullMeta itemMeta = (SkullMeta) stack.getItemMeta();
    itemMeta.setOwner("Yamakaja");
    stack.setItemMeta(itemMeta);
    ((Player) sender).getInventory().setItemInMainHand(stack);
    return true;
}
 
源代码25 项目: ProjectAres   文件: ItemConfigurationParser.java
public void needSkull(ItemStack stack, ConfigurationSection section, String key) throws InvalidConfigurationException {
    final ItemMeta meta = stack.getItemMeta();
    if(!(meta instanceof SkullMeta)) {
        throw new InvalidConfigurationException(section, key, "Item type " + NMSHacks.getKey(stack.getType()) + " cannot be skinned");
    }
    ((SkullMeta) meta).setOwner("SkullOwner", UUID.randomUUID(), needSkin(section.needString(key)));
    stack.setItemMeta(meta);
}
 
源代码26 项目: SkinsRestorerX   文件: SkinsGUI.java
private ItemStack createSkull(String name, Object property) {
    ItemStack is = XMaterial.PLAYER_HEAD.parseItem();
    SkullMeta sm = (SkullMeta) is.getItemMeta();
    List<String> lore = new ArrayList<>();
    lore.add(Locale.SKINSMENU_SELECT_SKIN.replace("&", "§"));
    sm.setDisplayName(name);
    sm.setLore(lore);
    is.setItemMeta(sm);
    setSkin(is, ((Property) property).getValue());
    return is;
}
 
源代码27 项目: EnchantmentsEnhance   文件: ItemBuilder.java
/**
 * Set the skull owner for the item. Works on skulls only.
 *
 * @param owner The name of the skull's owner.
 */
public ItemBuilder setSkullOwner(String owner) {
    try {
        SkullMeta im = (SkullMeta) is.getItemMeta();
        im.setOwner(owner);
        is.setItemMeta(im);
    } catch (ClassCastException expected) {
    }
    return this;
}
 
源代码28 项目: UhcCore   文件: VersionUtils_1_13.java
@Override
public ItemStack createPlayerSkull(String name, UUID uuid) {
    ItemStack item = UniversalMaterial.PLAYER_HEAD.getStack();
    SkullMeta im = (SkullMeta) item.getItemMeta();
    im.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
    item.setItemMeta(im);
    return item;
}
 
源代码29 项目: UhcCore   文件: VersionUtils_1_8.java
@Override
public ItemStack createPlayerSkull(String name, UUID uuid) {
    ItemStack item = UniversalMaterial.PLAYER_HEAD.getStack();
    SkullMeta im = (SkullMeta) item.getItemMeta();
    im.setOwner(name);
    item.setItemMeta(im);
    return item;
}
 
源代码30 项目: UhcCore   文件: VersionUtils_1_12.java
@Override
public ItemStack createPlayerSkull(String name, UUID uuid) {
    ItemStack item = UniversalMaterial.PLAYER_HEAD.getStack();
    SkullMeta im = (SkullMeta) item.getItemMeta();
    im.setOwner(name);
    item.setItemMeta(im);
    return item;
}