Solved The method getLine(int) is undefined for the type sign

Discussion in 'Plugin Development' started by AleilDr4go, Jan 8, 2016.

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

    AleilDr4go

    Hello, im trying to do a clickable sign, but i have this error,can anyone help me?
    Code (open)

    package AleDEV;

    import org.bukkit.configuration.Configuration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Sign implements Listener{

    public static Configuration getConfig() {
    }

    HazeCOORDS plugin;

    public Sign(HazeCOORDS plugin)
    {
    this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.LOW)
    public void onSignCreate(SignChangeEvent e)
    {
    Player p = e.getPlayer();

    if(e.getLine(0).equalsIgnoreCase("Hazeinfo"))
    {
    e.setLine(0, "§c[§aINFO§c]");
    p.sendMessage("§aSign succefully created !");
    }
    }
    @EventHandler(priority = EventPriority.LOW)
    public void onPlayerInteract(PlayerInteractEvent e)
    String Info = Sign.getConfig().getString("Info");
    {
    Player p = e.getPlayer();

    if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
    {
    if(e.getClickedBlock().getState() instanceof Sign)
    {
    Sign s = (Sign) e.getClickedBlock().getState();
    if(s.getLine(0).equalsIgnoreCase("§c[§aINFO§c]"))
    {

    p.sendMessage(Info.replaceAll("&", "§"));
    }
    }
    }
    }
    }

     
  2. Offline

    Zombie_Striker

    @AleilDr4go
    1. Can you show us the error
    2. What line causes the error
    3. Did you debug?
     
  3. Offline

    AleilDr4go

    1)Line 44
    2)
    Line (open)
    if(s.getLine(0).equalsIgnoreCase("§c[§aINFO§c]"))

    3)The method getLine(int) is undefined for the type Sign
     
  4. Offline

    Zombie_Striker

    @AleilDr4go
    Are you sure you imported the right thing?
     
  5. Offline

    AleilDr4go

    Import (open)

    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    yes
     
  6. Offline

    Zombie_Striker

  7. Offline

    AleilDr4go

    i dont have to import it...
     
  8. Offline

    AdamQpzm

    Zombie_Striker likes this.
  9. Offline

    AleilDr4go

    What?
     
  10. Offline

    Zombie_Striker

  11. Offline

    AleilDr4go

    Thanks man! Solved :D

    New listener code (open)

    package AleDEV;

    import org.bukkit.block.Sign;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class SignListener implements Listener{


    private HazeCOORDS plugin;

    public SignListener(HazeCOORDS plugin)
    {
    this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.LOW)
    public void onSignCreate(SignChangeEvent e)
    {
    Player p = e.getPlayer();

    if(e.getLine(0).equalsIgnoreCase("Hazeinfo"))
    {
    e.setLine(0, "§c[§aINFO§c]");
    p.sendMessage("§aSign succefully created !");
    }
    }
    @EventHandler(priority = EventPriority.LOW)
    public void onPlayerInteract(PlayerInteractEvent e) {
    {
    Player p = e.getPlayer();

    if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
    {
    if(e.getClickedBlock().getState() instanceof Sign)
    {
    Sign s = (Sign) e.getClickedBlock().getState();
    if(s.getLine(0).equalsIgnoreCase("§c[§aINFO§c]"))
    {
    String Info = plugin.getConfig().getString("Info");

    p.sendMessage(Info.replaceAll("&", "§"));
    }
    }
    }
    }
    }
    }



    Main import (open)
    getServer().getPluginManager().registerEvents(new SignListener(this), this);
     
Thread Status:
Not open for further replies.

Share This Page