Solved Changing the lines of a sign.

Discussion in 'Plugin Development' started by Ding1934, Jul 13, 2022.

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


    Hello, I am writing a core plugin for my minehut server. I want to make a event where if you place a sign and if it contains color codes it will translate.

    This is my current code.
        public void onSignPlace(BlockPlaceEvent event) {
            BlockState state = event.getBlockPlaced().getState();
            if (state instanceof Sign) {
                Sign sign = (Sign) state;
                String L1 = sign.getLine(0);
                String L2 = sign.getLine(1);
                String L3 = sign.getLine(2);
                String L4 = sign.getLine(3);
                sign.setLine(0, ChatColor.translateAlternateColorCodes('&', L1));
                sign.setLine(1, ChatColor.translateAlternateColorCodes('&', L2));
                sign.setLine(2, ChatColor.translateAlternateColorCodes('&', L3));
                sign.setLine(3, ChatColor.translateAlternateColorCodes('&', L4));
    How do I make this work? It leaves the sign blank in game.
    Last edited: Jul 13, 2022
  2. Offline


  3. Offline


    Thank you for telling me it's working intended now!
    KarimAKL likes this.
  4. Offline


    Also if you just want to color every line you could use a simple loop instead of repeating yourself. Example

    for(int i = 0; i < 4; i++) 
        sign.setLine(i, ChatColor.translateAlternateColorCodes('&', sign.getLine(i)));
Thread Status:
Not open for further replies.

Share This Page