本文整理汇总了Java中org.bukkit.Material.SKULL_ITEM属性的典型用法代码示例。如果您正苦于以下问题:Java Material.SKULL_ITEM属性的具体用法?Java Material.SKULL_ITEM怎么用?Java Material.SKULL_ITEM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.SKULL_ITEM属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSkull
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;
}
示例2: onInventoryClick
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack clicked = event.getCurrentItem();
Inventory inventory = event.getInventory();
if (inventory.getName().equals("Faction Management")) {
if (clicked.getType() == Material.SKULL_ITEM) {
if (event.getClick() == ClickType.LEFT) {
Bukkit.dispatchCommand(player, "f promote " + clicked.getItemMeta().getDisplayName());
event.setCancelled(true);
}
if (event.getClick() == ClickType.MIDDLE){
Bukkit.dispatchCommand(player, "f leader " + clicked.getItemMeta().getDisplayName());
event.setCancelled(true);
}
if (event.getClick() == ClickType.RIGHT) {
Bukkit.dispatchCommand(player, "f demote " + clicked.getItemMeta().getDisplayName());
event.setCancelled(true);
}
}
}
}
示例3: getCustomHead
/**
* Create a player head with a base64 encoded texture
*
* @param texture Base64 texture
*
* @return A custom head with your texture
*/
public static ItemStack getCustomHead(String texture)
{
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta headMeta = head.getItemMeta();
try
{
Reflection.setValue(headMeta, "profile", getHeadCustomizedGameProfile(texture));
}
catch (NoSuchFieldException | IllegalAccessException e)
{
e.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
示例4: getCustomSkull
public static ItemStack getCustomSkull(String url) {
GameProfile profile = SkinChangeUtil.changeSkin(url);
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta headMeta = head.getItemMeta();
Class<?> headMetaClass = headMeta.getClass();
try {
Field f = headMetaClass.getDeclaredField("profile");
f.setAccessible(true);
f.set(headMeta, profile);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
示例5: activateHeadByURL
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;
}
示例6: getPlayerSkull
public static ItemStack getPlayerSkull(String playerName) {
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
headMeta.setOwner(playerName);
head.setItemMeta(headMeta);
return head;
}
示例7: refresh
public void refresh(VPPlayer viewer, Inventory inv){
MenuLink ml = (MenuLink) ((inv.getHolder() instanceof MenuLink) ? inv.getHolder() : null);
for (int i = 1; i < icons.length; i++) {
if (icons[i] != null && !icons[i].isStatic()){
Icon icon = icons[i].getIcon(viewer);
if(icon == null) {
if(type == InventoryType.PLAYER) {
ItemStack[] memory = viewer.getInventory(false);
if(memory[i-1] != null) {
inv.setItem(i-1, memory[i-1]);
memory[i-1] = null;
viewer.setInventory(memory, false);
}
}else
inv.setItem(i-1, new ItemStack(Material.AIR));
continue;
}
if(icon.skullSelf()){
ItemStack item = inv.getItem(i-1);
if(item != null && item.getType() == Material.SKULL_ITEM){
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(icon.getLores(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
itemMeta.setDisplayName(icon.getName(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
((SkullMeta)itemMeta).setOwner(ml == null ? viewer.getName() : ml.getView().getName());
item.setItemMeta(itemMeta);
continue;
}
}
if(icon != null)
inv.setItem(i-1, icon.getItemstack(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
}
}
}
示例8: getSkull
public static ItemStack getSkull(String skin) {
final ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
if (skin.length() > 20) {
if (skin.contains("http")) {
return activateHeadByURL(skin, itemStack);
} else {
return activateHeadByCode(skin, itemStack);
}
} else {
return activateHeadByName(skin, itemStack);
}
}
示例9: onPlayerDeath
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer != null && killer.hasPermission(KILL_BEHEAD_PERMISSION)) {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(player.getName());
skull.setItemMeta(meta);
event.getDrops().add(skull);
}
}
示例10: head
public static ItemStack head(String playerName, String displayName, String... lore) {
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwner(playerName);
meta.setDisplayName(displayName);
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return item;
}
示例11: constructGhostSkull
public ItemStack constructGhostSkull() {
ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
skullMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&f&lGhost Skull"));
itemStack.setItemMeta(skullMeta);
new SkullProfile(this.getConfig().getString("ghost-skull-hash"))
.applyTextures(itemStack);
return itemStack;
}
示例12: linkHeadDatabaseItemToPetBlocks
/**
* Sets the given itemStack as petMeta skin if it full fills the skull requirements
*
* @param itemStack itemStack
* @param player player
*/
private void linkHeadDatabaseItemToPetBlocks(ItemStack itemStack, Player player) {
if (itemStack != null
&& itemStack.getType() == Material.SKULL_ITEM
&& itemStack.getItemMeta() != null
&& itemStack.getItemMeta().getDisplayName() != null
&& itemStack.getItemMeta().getDisplayName().startsWith(ChatColor.BLUE.toString())) {
player.closeInventory();
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
final com.github.shynixn.petblocks.api.persistence.entity.PetMeta petMeta = this.manager.getPetMetaController().getByPlayer(player);
final SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
if (meta.getOwner() == null) {
petMeta.setSkin(itemStack.getType().getId(), itemStack.getDurability(), SkinHelper.getItemStackSkin(itemStack).get(), false);
} else {
petMeta.setSkin(itemStack.getType().getId(), itemStack.getDurability(), ((SkullMeta) itemStack.getItemMeta()).getOwner(), false);
}
this.manager.getPetMetaController().store(petMeta);
this.plugin.getServer().getScheduler().runTask(this.plugin, () -> {
final PetBlock petBlock;
if ((petBlock = this.getPetBlock(player)) != null) {
petBlock.respawn();
}
player.performCommand("petblock");
}
);
});
}
}
示例13: getPlayerSkull
public static ItemStack getPlayerSkull(String name) {
ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
meta.setOwner(name);
itemStack.setItemMeta(meta);
return itemStack;
}
示例14: DisplayArmorstand
/**
* Initializes the armorstand
*
* @param player player
* @param location location
* @param id id
* @param data data
* @param watchers watchers
*/
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
super();
this.watchers = watchers;
this.player = player;
this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
final NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("invulnerable", true);
compound.setBoolean("Invisible", true);
compound.setBoolean("PersistenceRequired", true);
compound.setBoolean("NoBasePlate", true);
this.armorStand.a(compound);
this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
this.storedId = id;
this.storedData = data;
ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
this.getCraftEntity().setHelmet(stackBuilder.build());
this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));
if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
} else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
} else {
stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
}
((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
}
}
示例15: withSkullOwner
public ItemBuilder withSkullOwner(String name) {
if (stack.getType() == Material.SKULL_ITEM && stack.getDurability() == (short) 3) {
((SkullMeta) meta).setOwner(name);
}
return this;
}