Custom Sign code not working!

Discussion in 'Plugin Development' started by ksbdude, Dec 28, 2013.

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

    ksbdude

    My Join signs for my PVP plugin wont work. Idk why? Any ideas?

    Code:java
    1.  
    2. @EventHandler
    3. public void signPlace(SignChangeEvent e) {
    4. if(e.getLine(0).equalsIgnoreCase("pvp")) {
    5. BlockState sign = ((Block) e).getState();
    6. e.setLine(0, ChatColor.GRAY + "[" + ChatColor.BLUE + "PVP" + ChatColor.GRAY + "]");
    7. e.setLine(1, "Click to Join");
    8. sign.update(true);
    9. }
    10. }
    11.  
    12. @EventHandler
    13. public boolean signInteract(PlayerInteractEvent e) {
    14. if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    15. Block block = e.getClickedBlock();
    16. Player p = e.getPlayer();
    17. if(block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
    18. Sign sign = (Sign) e.getClickedBlock().getState();
    19. if(sign.getLine(0).equalsIgnoreCase(ChatColor.GRAY + "[" + ChatColor.BLUE + "PVP" + ChatColor.GRAY + "]")) {
    20. if(sign.getLine(1).equalsIgnoreCase("Click to Join")){
    21. //do stuff
    22.  
     
  2. Offline

    xTigerRebornx

    ksbdude You are trying to cast your entire event into a block, which is why the sign creation probably isn't working.
     
    JRL1004 likes this.
  3. Offline

    JRL1004

    Wow, first time I read this I completely missed that! Anyway, ksbdude , do what Tiger pointed out (it should be e.getBlock() or something similar) and make sure you are registering your events in your onEnable()
     
  4. Offline

    ksbdude

    JRL1004 Ive tried to put events in the onEnable but i get errors saying not needed etc
     
  5. Offline

    xTigerRebornx

    JRL1004 I find it pretty funny when people do that (And I see it very often too, which worries me sometimes)
     
  6. Offline

    ksbdude

Thread Status:
Not open for further replies.

Share This Page