java类org.bukkit.inventory.meta.SkullMeta的实例源码

RHead.java 文件源码 项目:ZentrelaCore 阅读 17 收藏 0 点赞 0 评论 0
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;
}
SkinHelper.java 文件源码 项目:PetBlocks 阅读 34 收藏 0 点赞 0 评论 0
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);
    }
}
ItemUtil.java 文件源码 项目:WC 阅读 26 收藏 0 点赞 0 评论 0
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;
}
GuiProfile.java 文件源码 项目:Hub 阅读 21 收藏 0 点赞 0 评论 0
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;
}
InventoryUtils.java 文件源码 项目:Transport-Pipes 阅读 21 收藏 0 点赞 0 评论 0
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;
    }
LocaleUtils.java 文件源码 项目:NyaaCore 阅读 24 收藏 0 点赞 0 评论 0
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));
    }
}
SSKulls.java 文件源码 项目:BlockBall 阅读 14 收藏 0 点赞 0 评论 0
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;
}
CookieHeadModule.java 文件源码 项目:SurvivalAPI 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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);
}
CookieHeadModule.java 文件源码 项目:SurvivalAPI 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
EditMode.java 文件源码 项目:VoxelGamesLibv2 阅读 14 收藏 0 点赞 0 评论 0
@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);
    }
}
HeadTextureChanger.java 文件源码 项目:VoxelGamesLibv2 阅读 16 收藏 0 点赞 0 评论 0
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;
}
ItemUtil.java 文件源码 项目:PA 阅读 24 收藏 0 点赞 0 评论 0
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;
}
ItemStackUtils.java 文件源码 项目:Pokecraft 阅读 30 收藏 0 点赞 0 评论 0
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;
}
ItemUtils_V1_10_R1.java 文件源码 项目:GameBoxx 阅读 16 收藏 0 点赞 0 评论 0
@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;
}
ClanMenu.java 文件源码 项目:Damocles 阅读 23 收藏 0 点赞 0 评论 0
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;
}
HeadTextureChanger.java 文件源码 项目:SoundMuffler 阅读 17 收藏 0 点赞 0 评论 0
public static SkullMeta applyTextureToMeta(SkullMeta 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;
}
SpectatorMenu.java 文件源码 项目:MinigameManager 阅读 18 收藏 0 点赞 0 评论 0
public SpectatorMenu(final Minigame minigame, String[] alive, String title, ItemStack backItem, ItemStack nextItem) {
    super(minigame, title, backItem, nextItem, new EventListener<InventoryClickEvent>() {
        public void onEvent(InventoryClickEvent event) {
            ItemStack item = event.getCurrentItem();
            if (item != null && item.getType() == Material.SKULL_ITEM) {
                HumanEntity human = event.getWhoClicked();
                // only works for spectators
                if (!(human instanceof Player) || minigame.isAlive(((Player) human)))
                    return;
                SkullMeta meta = (SkullMeta) item.getItemMeta();
                Player target = Bukkit.getPlayer(meta.getOwner());
                human.teleport(target);
            }
        };
    }, getHeadsForPlayers(alive));
}
Tracker.java 文件源码 项目:StickyTracker 阅读 28 收藏 0 点赞 0 评论 0
private void spawnTracker() {
    Player p = (Player) getTarget();
    ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta sm = (SkullMeta) skull.getItemMeta();
    sm.setOwner(playerWithTrackerHead);
    skull.setItemMeta(sm);

    World w = p.getWorld();
    armorStand = w.spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);

    /*slime = w.spawnEntity(p.getLocation(), EntityType.SLIME);
    ((Slime) slime).setInvulnerable(true);
    ((Slime) slime).setAI(false);
    ((Slime) slime).setSize(2);
    slime.setPassenger(armorStand);*/
    p.setPassenger(armorStand);
    ((ArmorStand) armorStand).setHelmet(skull);
    ((ArmorStand) armorStand).setVisible(false);
    ((ArmorStand) armorStand).setSmall(true);
    ((ArmorStand) armorStand).setBodyPose(new EulerAngle(0.0, 3.57, 0.0));
}
XMLItemMeta.java 文件源码 项目:Arcade2 阅读 29 收藏 0 点赞 0 评论 0
public static ItemMeta parse(Element xml, ItemMeta source) {
    if (source instanceof BannerMeta) {
        return parseBanner(xml, (BannerMeta) source);
    } else if (source instanceof BookMeta) {
        return parseBook(xml, (BookMeta) source);
    } else if (source instanceof EnchantmentStorageMeta) {
        return parseEnchantmentStorage(xml, (EnchantmentStorageMeta) source);
    } else if (source instanceof FireworkMeta) {
        return parseFirework(xml, (FireworkMeta) source);
    } else if (source instanceof FireworkEffectMeta) {
        return parseFireworkEffect(xml, (FireworkEffectMeta) source);
    } else if (source instanceof LeatherArmorMeta) {
        return parseLeatherArmor(xml, (LeatherArmorMeta) source);
    } else if (source instanceof MapMeta) {
        return parseMap(xml, (MapMeta) source);
    } else if (source instanceof PotionMeta) {
        return parsePotion(xml, (PotionMeta) source);
    } else if (source instanceof SkullMeta) {
        return parseSkull(xml, (SkullMeta) source);
    } else if (source instanceof SpawnEggMeta) {
        return parseSpawnEgg(xml, (SpawnEggMeta) source);
    }

    return source;
}
Config.java 文件源码 项目:CS-CoreLib 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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 (config.contains(path + "_extra.custom-skull")) item = CustomSkull.getItem((ItemStack) item, config.getString(path + "_extra.custom-skull"));
            if (config.contains(path + "_extra.custom-skullOwner") && !((ItemStack) item).getItemMeta().hasDisplayName()) {
                ItemMeta im = ((ItemStack) item).getItemMeta();
                im.setDisplayName("�r" + config.getString(path + "_extra.custom-skullOwner") + "'s Head");
                ((ItemStack) item).setItemMeta(im);
            }
        }
        else {
            config.set(path + "_extra.custom-skull", null);
            config.set(path + "_extra.custom-skullOwner", null);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return item;
}
InventoryManager.java 文件源码 项目:PretparkCore 阅读 16 收藏 0 点赞 0 评论 0
public static void setInventory(Player p){
    p.getInventory().clear();

    ItemStack skull = ItemUtils.createItemstack(Material.SKULL_ITEM, 1, (byte)3, "&aJouw Profiel &3(Rechter Klik)", "&7&oTODO"); //TODO: MAKE LORE
    SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
    skullMeta.setOwner(p.getName());
    skull.setItemMeta(skullMeta);
    ItemUtils.createInventoryDisplay(p, skull, 1);

    ItemUtils.createInventoryDisplay(p, Material.MINECART, 1, (byte)0, "&aAttracties &3(Rechter Klik)", "&7&oTODO", 2); //TODO: MAKE LORE
    if(p.hasPermission("pretparkcore.controlrides")) {
        ItemUtils.createInventoryDisplay(p, Material.COMMAND_MINECART, 1, (byte) 0, "&aAttractie Besturing &3(Rechter Klik)", "&7&oTODO", 3); //TODO: MAKE LORE
    }
    ItemUtils.createInventoryDisplay(p, Material.CHEST, 1, (byte) 0, "&aSwag Menu &3(Rechter Klik)", "&7Upgrade je swag naar &lOVER 9000!", 9); //TODO: MAKE LORE

    p.getInventory().setHelmet(new ItemStack(Vars.helmet.get(p.getName())));
    p.getInventory().setChestplate(new ItemStack(Vars.chest.get(p.getName())));
    p.getInventory().setLeggings(new ItemStack(Vars.legs.get(p.getName())));
    p.getInventory().setBoots(new ItemStack(Vars.boots.get(p.getName())));
}
WarpPanel.java 文件源码 项目:acidisland 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Gets the skull for this player UUID
 * @param playerUUID
 * @return Player skull item
 */
private ItemStack getSkull(UUID playerUUID) {
    String playerName = plugin.getPlayers().getName(playerUUID);
    if (DEBUG)
        plugin.getLogger().info("DEBUG: name of warp = " + playerName);
    ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    if (playerName == null) {
        if (DEBUG)
            plugin.getLogger().warning("Warp for Player: UUID " + playerUUID.toString() + " is unknown on this server, skipping...");
        return null;
        //playerName = playerUUID.toString().substring(0, 10);
    }
    SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
    meta.setOwner(playerName);
    meta.setDisplayName(ChatColor.WHITE + playerName);
    playerSkull.setItemMeta(meta);
    return playerSkull;
}
WarpPanel.java 文件源码 项目:askyblock 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Gets the skull for this player UUID
 * @param playerUUID
 * @return Player skull item
 */
private ItemStack getSkull(UUID playerUUID) {
    String playerName = plugin.getPlayers().getName(playerUUID);
    if (DEBUG)
        plugin.getLogger().info("DEBUG: name of warp = " + playerName);
    ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    if (playerName == null) {
        if (DEBUG)
            plugin.getLogger().warning("Warp for Player: UUID " + playerUUID.toString() + " is unknown on this server, skipping...");
        return null;
        //playerName = playerUUID.toString().substring(0, 10);
    }
    SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
    meta.setOwner(playerName);
    meta.setDisplayName(ChatColor.WHITE + playerName);
    playerSkull.setItemMeta(meta);
    return playerSkull;
}
CmdSkull.java 文件源码 项目:Necessities 阅读 16 收藏 0 点赞 0 评论 0
public boolean commandUse(CommandSender sender, String[] args) {
    Variables var = Necessities.getVar();
    if (args.length == 0) {
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You must enter a player to get their head.");
        return true;
    }
    if (sender instanceof Player) {
        Player p = (Player) sender;
        ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        SkullMeta meta = (SkullMeta) skull.getItemMeta();
        meta.setOwner(args[0]);
        skull.setItemMeta(meta);
        p.getInventory().addItem(skull);
        p.sendMessage(var.getMessages() + "You have been given 1 head of " + var.getObj() + args[0]);
    } else
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You do not have an inventory.");
    return true;
}
Voodoo.java 文件源码 项目:DDCustomPlugin 阅读 16 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void onPlayerInteract(final PlayerInteractEvent event) { 
    final Player player = event.getPlayer();
    if (player.hasPermission("customplugin.voodoo")) {
        ItemStack i = player.getItemInHand();
        if (i.getTypeId() == 397 && i.getDurability() == (byte) 3) {
            SkullMeta skull = (SkullMeta)i.getItemMeta();
            Player p = Bukkit.getPlayer(skull.getOwner());
            if (p != null) {
                if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                    p.setVelocity(player.getLocation().getDirection().multiply(-1));
                } else {
                    p.setVelocity(player.getLocation().getDirection());
                }
            }
        }
    }
}
StaffVotes.java 文件源码 项目:DDCustomPlugin 阅读 16 收藏 0 点赞 0 评论 0
public void voteNo(Player player) {
    removePlayer(player);

    ItemStack head = new ItemStack(Material.SKULL_ITEM);
    head.setDurability((short)3);

    SkullMeta skull = (SkullMeta) head.getItemMeta();
    skull.setOwner(player.getName());
    head.setItemMeta(skull);

    ItemMeta im = head.getItemMeta();
    im.setDisplayName(ChatColor.DARK_RED + player.getName());
    ArrayList<String> lore = new ArrayList<String>();
    lore.add("Voting NO");
    im.setLore(lore);
    head.setItemMeta(im);

    getChest().setItem(getNextNoSlot(), head);
    player.openInventory(getChest());
}
StaffVotes.java 文件源码 项目:DDCustomPlugin 阅读 16 收藏 0 点赞 0 评论 0
public void voteYes(Player player) {
    removePlayer(player);

    ItemStack head = new ItemStack(Material.SKULL_ITEM);
    head.setDurability((short)3);

    SkullMeta skull = (SkullMeta) head.getItemMeta();
    skull.setOwner(player.getName());
    head.setItemMeta(skull);

    ItemMeta im = head.getItemMeta();
    im.setDisplayName(ChatColor.GREEN + player.getName());
    ArrayList<String> lore = new ArrayList<String>();
    lore.add("Voting YES");
    im.setLore(lore);
    head.setItemMeta(im);

    getChest().setItem(getNextYesSlot(), head);
    player.openInventory(getChest());
}
StaffVotes.java 文件源码 项目:DDCustomPlugin 阅读 15 收藏 0 点赞 0 评论 0
public void onPlayerJoinEvent(PlayerJoinEvent event) {
    if (event.getPlayer().hasPermission("customplugin.staffvote")) {
        for (ItemStack item : getChest().getContents()) {
            if (item != null && item.getType().equals(Material.SKULL_ITEM)) {
                SkullMeta skull = (SkullMeta) item.getItemMeta();
                if (skull.getOwner().equals(event.getPlayer().getName()))
                    return;
            }
        }
        event.getPlayer().sendMessage(ChatColor.BLUE + "STAFFVOTE: " + ChatColor.RED + "You have yet to vote!");
        Sign sign = (Sign) Bukkit.getWorld("Survival").getBlockAt(60, 71, 171).getState();
        Sign sign2 = (Sign) Bukkit.getWorld("Survival").getBlockAt(60, 71, 170).getState();

        String title = sign.getLine(1) + " " + sign.getLine(2) + " " + sign.getLine(3) + " " + sign2.getLine(1) + " " + sign2.getLine(2) + " " + sign2.getLine(3);
        event.getPlayer().sendMessage(ChatColor.GREEN + title);
    }
}
HeadCommand.java 文件源码 项目:Bytecraft 阅读 18 收藏 0 点赞 0 评论 0
public boolean handlePlayer(BytecraftPlayer player, String[] args)
{
    if(!player.getRank().canSpawnHeads()){
        player.sendMessage(getInvalidPermsMessage());
        return true;
    }


    if (args.length == 1) {
        ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
        SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
        itemMeta.setOwner(args[0]);
        itemMeta.setDisplayName(ChatColor.YELLOW + args[0] + "'s head");
        item.setItemMeta(itemMeta);
        PlayerInventory inventory = player.getInventory();
        inventory.addItem(item);
        player.sendMessage(ChatColor.YELLOW + "You received the head of "
                + args[0]);
    }
    else {
        player.sendMessage(ChatColor.RED + "Type /head <player>");
    }
    return true;
}
HeadCommand.java 文件源码 项目:tregmine 阅读 15 收藏 0 点赞 0 评论 0
@Override
public boolean handlePlayer(TregminePlayer player, String args[])
{
    if (player.getRank().canGetPlayerHead()){
        if (args.length == 1) {
            ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
            SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
            itemMeta.setOwner(args[0]);
            itemMeta.setDisplayName(ChatColor.YELLOW + args[0] + "'s head");
            item.setItemMeta(itemMeta);
            PlayerInventory inventory = player.getInventory();
            inventory.addItem(item);
            player.sendMessage(ChatColor.YELLOW + "You received the head of " + args[0]);
        } else {
            player.sendMessage(ChatColor.RED + "Type /head <player>");
        }
    } else {
        player.sendMessage(ChatColor.RED + "Only admins can use this command!");
    }
    return true;
}


问题


面经


文章

微信
公众号

扫码关注公众号