Solved Can't change sign line

Discussion in 'Plugin Development' started by sgavster, Feb 24, 2016.

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

    sgavster

    I'm working on a plugin and I can't change the sign line, this is my code:


    Code:
    public static void updateSign() {
            World snow1 = Bukkit.getServer().getWorld("MiniGames");
            List<Player> players = snow1.getPlayers();
            Integer size = players.size();
            int sign = Main.getMain().getConfig().getInt("signnumber") + 1;
            for (int currentSign = 1; currentSign < sign; currentSign++) {
                int x = Main.getMain().getConfig()
                        .getInt("signs." + currentSign + ".x");
                int y = Main.getMain().getConfig()
                        .getInt("signs." + currentSign + ".y");
                int z = Main.getMain().getConfig()
                        .getInt("signs." + currentSign + ".z");
                String world = Main.getMain().getConfig()
                        .getString("signs." + currentSign + ".worldsign");
                if (world == null) {
                    continue;
                }
                Block block = Bukkit.getWorld(world).getBlockAt(x, y, z);
                block.getChunk().load();
                BlockState state = block.getState();
                if ((state instanceof Sign)) {
                    Sign s = (Sign) state;
                    s.setLine(0, "ยง4[Paintball]");
                    s.setLine(1, changeState());
                    s.setLine(2, Main.getMain().getConfig().getInt("playersingame")
                            + " players");
                    s.setLine(3,"Map: "+ Main.getMain().getConfig().getString("currentarena") == null ? "None": Main.getMain().getConfig().getString("currentarena"));
                    block.getChunk().load();
                    s.update(true);
                }
            }
        }
    But on s.setLine and s.update it says
    I can't figure it out for the life of me.. Thanks for any help.
     
  2. Maybe you imported the wrong sign class (nms or cb).
     
  3. Offline

    sgavster

    @FisheyLP My Imports:
    Imports (open)

    import java.util.List;

    import me.sgavster.quadularmc.paintball.Main.Main;
    import me.sgavster.quadularmc.paintball.Util.State;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockState;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.SignChangeEvent;

    If I try to add import org.bukkit.block.Sign it's an 'unused' import
     
  4. Offline

    CapsizeTheLevi


    This is likely bad practice, but just for kicks, where you call
    Code:
    if ((state instanceof Sign)) {
        Sign s = (Sign) state;
    
    }
    try making it:

    Code:
    if ((state instanceof Sign)) {
        org.bukkit.block.Sign s = (Sign) state;
    
    }
    It might be trying to find the other sign in that instance, so for now, use that to force the import.
     
  5. Offline

    Xerox262

    @sgavster What is your class called that this method is in? Is it called sign? If so then that is why.
     
    sgavster likes this.
  6. Offline

    sgavster

    @Xerox262 You're a life saver! Thank you!
     
    Last edited: Feb 24, 2016
Thread Status:
Not open for further replies.

Share This Page