Custom head spawn?

Discussion in 'Plugin Development' started by iamcion, Jul 30, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    iamcion

    Hi, im looking for the code, for when a certain command is typed, it will give them their OWN head!

    As well, as a specified player's head (arg0)


    Code:java
    1. package me.iamcion.MyHead;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.inventory.ItemStack;
    10. import org.bukkit.inventory.meta.SkullMeta;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12. import org.bukkit.Server;
    13.  
    14. public class Main
    15. {
    16. ItemStack myhead = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
    17.  
    18. public void onEnable()
    19. {
    20.  
    21. SkullMeta playerskull = (SkullMeta)this.myhead.getItemMeta();
    22.  
    23. playerskull.setOwner("TEST");
    24. this.myhead.setItemMeta(playerskull);
    25. }
    26. {
    27. SkullMeta MySkull = (SkullMeta)this.myhead.getItemMeta();
    28.  
    29. MySkull.setOwner("iamcion");
    30. this.myhead.setItemMeta(MySkull);
    31.  
    32. }
    33.  
    34. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    35. {
    36. if ((cmd.getName().equalsIgnoreCase("phead")) && (sender.hasPermission("phead.give")))
    37. {
    38. if (args.length == 1)
    39.  
    40. {
    41. getServer.getPlayer(args[0]).getInventory().addItem(new ItemStack[] { this.myhead });
    42. } else {
    43. sender.sendMessage(ChatColor.RED + "§b[PlayerHead] Player Not Online!");
    44. }
    45. }
    46. else {
    47. sender.sendMessage(ChatColor.AQUA + "§b[PlayerHead] §cPlease specify who's head you want");
    48. sender.sendMessage(ChatColor.GOLD + "EG: /phead <username>");
    49. }
    50. return true;
    51. {
    52. return false;
    53. }
    54. }
    55. }
     
  2. iamcion
    Code:java
    1. public ItemStack getHeadFromString(String string) {
    2. ItemStack itemStack = new ItemStack(Material.SKULL_ITEM);
    3. SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
    4. meta.setOwner(string);
    5. itemStack.setItemMeta(meta);
    6. return itemStack;
    7. }
     
  3. Offline

    iamcion

    Thanks.
     
Thread Status:
Not open for further replies.

Share This Page