Solved Another sign problem

Discussion in 'Plugin Development' started by KingKongC, Jan 20, 2013.

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

    KingKongC

    Okay here's my problem when i right click the sign with the code below i doesn't change the sign's text but it does send a message to the player saying "Sign Created"


    Code:java
    1. package me.kingkongcaliber.warnsign;
    2. import org.bukkit.ChatColor;
    3. import org.bukkit.Material;
    4. import org.bukkit.block.Sign;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.block.Action;
    8. import org.bukkit.event.player.PlayerInteractEvent;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10. import org.bukkit.event.Listener;
    11.  
    12. public class main extends JavaPlugin implements Listener {
    13.  
    14. public void onEnable(){
    15.  
    16. getServer().getPluginManager().registerEvents(this, this);
    17.  
    18. }
    19. public void onDisable(){
    20.  
    21. }
    22. @EventHandler
    23. public void onInteract(PlayerInteractEvent event) {
    24. Player p = event.getPlayer();
    25. if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    26. Material clickedType = event.getClickedBlock().getType(); //
    27. if(clickedType == Material.SIGN_POST || clickedType == Material.WALL_SIGN) {
    28. Sign sign = (Sign) event.getClickedBlock().getState();
    29. String[] lines = sign.getLines();
    30. if(lines[1].equalsIgnoreCase("[Kill]")){
    31.  
    32. p.sendMessage("Sign created");
    33. sign.setLine(1,"["+ChatColor.GOLD+"Kill"+ChatColor.RESET+"]");
    34. sign.update(true);
    35.  
    36. }
    37. }
    38. }
    39. }
    40.  
    41. }


    Solved

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

    ftbastler

    KingKongC Maybe you want to tell us how you solved it? Else, somebody will start a new thread about the same issue...
     
  3. Offline

    KingKongC

    Well it was a problem with my code
    Code:java
    1. sign.setLine(1,"["+ChatColor.GOLD+"Kill"+ChatColor.RESET+"]");


    i changed 1 to 0
     
Thread Status:
Not open for further replies.

Share This Page