Solved Customized signs on player death

Discussion in 'Plugin Development' started by theunknownme, Jul 2, 2015.

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

    theunknownme

    Hello, I am not able to find how to create customized signs on player's death.
    This is what I've done so far.
    Code:
    @EventHandler
    private void onPlayerDeath(PlayerDeathEvent event){
    player p = (Player) event.getEntity
    
    loc.getBlock().setType(Material.SIGN_POST);
    ?.setLine(1, "text");
    ?.setLine(2, "retext");
    ?.setLine(3, "reretext");
    ?.setLine(4, "rereretext");
    }
    }
     
  2. Offline

    Ruptur

    @theunknownme
    You need to get the block state of the block and cast it to sign
    Code:
    Block block = p.getLocation().getBlock();
    block.setType(Material.Sign);
    
    Sign sign = (Sign) block.getState();
    
    sign.setLine(line, text);
    
     
  3. Offline

    theunknownme

    Thank you, I will check later if it works.
     
  4. Material.SIGN is the item. He probably wants SIGN_POST or WALL_SIGN
     
  5. Offline

    lilian58660

    Make sure your import is bukkit.block.sign not bukkit.material.sign
     
  6. Offline

    theunknownme

    Hummm, it does not work though... when I kill myself (suicide) A sign does pop up, the only problem is that the sign stays blank, and another sign (as an item) pops up... but I get no error in my server console... I even tried writing a console message in the same event as a player dies and it worked, bu why does it not work when trying to edit a sign? Help me please :'(

    P.S. the plugin is in 1.8.3

    This is the full code of my listener plugin-:
    Code:
    import java.util.logging.Logger;
    
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    
    public class Listeners implements Listener {
       
        public final Logger logger = Logger.getLogger("Minecraft");
       
        @EventHandler
        private void onPlayerDeath(PlayerDeathEvent event){
            Player p = (Player)event.getEntity();
            Block b = p.getLocation().getBlock();
            b.setType(Material.SIGN_POST);
            if (!b.getType().equals(Material.SIGN_POST))
                return;
            Sign sign = (Sign)b.getState();
            sign.setLine(1, "Test");
            sign.setLine(2, "reTest");
            sign.setLine(3, "rereTest");
            sign.setLine(4, "rerTest");
        }
    }
     
  7. sign.update() at the end
     
  8. Offline

    theunknownme

    Ok @FisheyLP I'll try!

    EDIT: Still nothing appears...
     
    Last edited: Jul 3, 2015
  9. Offline

    theunknownme

    Not needed, the thread is now solved! Thanks to a stranger on bukkit.fr!
     
Thread Status:
Not open for further replies.

Share This Page