[SPIGOT-1886] Reading lines from Sign BlockState results in empty string Created: 11/Mar/16  Updated: 12/Mar/16  Resolved: 11/Mar/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Martin | MiniDigger Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: 1.9, blockstate, sign
Environment:

git-Spigot-b1c1b55-7d73fbb on windows 10 and ubuntu 14 (java 7 and 8)



 Description   

Steps to reproduce:

  • Register Listener
  • Create a sign and write something to the first line
    Expected output:
    [19:25:29 INFO]: from event: Line 1
    [19:25:29 INFO]: from blockstate: Line 1
    [19:25:29 INFO]: after update: Line 1
    

    Output:
    [19:25:29 INFO]: from event: Line 1
    [19:25:29 INFO]: from blockstate:
    [19:25:29 INFO]: after update:
    Code:

    SignTest.java
    	@EventHandler
    	public void onSignCreate(SignChangeEvent e) {
    		System.out.println("from event: " + e.getLine(0));
    		Sign s = ((Sign) e.getBlock().getState());
    		System.out.println("from blockstate:" + s.getLine(0));
    		s.update(true);
    		System.out.println("after update:" + s.getLine(0));
    	}
    


 Comments   
Comment by Faris Rehman [ 12/Mar/16 ]

Why wouldn't you just use e.getLine(0) instead...

Comment by Martin | MiniDigger [ 12/Mar/16 ]

Ah ok thank you. If I delay e.getBlock().getState().getLine(0) by a few ticks it works.
Thank you for your help

Comment by Matthew Steglinski [ 11/Mar/16 ]

This is intended behavior, the signs block state lines are only modified after SignChangeEvent executes and is not cancelled. The empty strings are as such because the sign is newly created and has nothing on them. SignChangeEvent#getLines returns what the lines will be set to if the event is not cancelled.

Comment by Martin | MiniDigger [ 11/Mar/16 ]

If I had the permission I would change the formatting but now you have to roll with that...

Generated at Tue Apr 22 05:44:22 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.