Help with changing a block to an item with ItemMeta

Discussion in 'Plugin Development' started by PluginStudios, Apr 5, 2014.

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

    PluginStudios

    Hey bukkit! I am making something called DeathManager+. This is just the start of it, and it is already bouncing errors.

    When I try to set the blocks type to the skull, it says it must be a material. Although, i cant do this because it has the meta which is making me very angry.

    Reminder: I am a noob at le coding.

    http://www.pastebin.com/NFwgGNcA

    Also, I have not used the death event and the setType method.

    Bump?

    I guess this is unfixable?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    rohan576

    PluginStudios

    First off, please don't bump more frequently than 24 hours.
    _______________________________________
    Try this: (Removed .subtract(0,1,0) because it should get the block the player is standing at. With subtract, it would get the block that they're standing on.)
    Code:java
    1. public void playerDeath(final PlayerDeathEvent e) {
    2. Bukkit.getServer().broadcastMessage("Somebody died!"); // debug
    3. if (e.getEntity() instanceof Player) {
    4. Player player = (Player) e.getEntity();
    5. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    6. public void run() {
    7. ItemStack skull = new ItemStack(397, 1, (short) 3);
    8. Material skullBlock = Material.SKULL
    9. SkullMeta meta = (SkullMeta) skull.getItemMeta();
    10.  
    11. meta.setOwner(e.getEntity().getPlayer().getName());
    12. Bukkit.getServer().broadcastMessage("Somebody dropped their head!"); // debug
    13.  
    14. e.getEntity().getPlayer().getLocation().getBlock().setType(skullBlock);
    15. e.getEntity().getPlayer().getLocation().getBlock().setMetadata(meta);
    16. player.sendMessage(ChatColor.GOLD + "You have died and dropped your head at your previous location!");
    17. }
    18.  
    19. } else { System.out.println("Error: Entity is not a player! "); }
    20. }


    Lastly, do consider setting their block location as a variable right when they die, because they might respawn, and then their head will be place where they're standing after death.
     
  3. Offline

    PluginStudios

    rohan576 that gave me a ton of errors. Literally, put it in a class. I have to change like everything?
     
Thread Status:
Not open for further replies.

Share This Page