22
33import java .util .ArrayList ;
44import java .util .List ;
5+
56import org .bukkit .Location ;
67import org .bukkit .block .Block ;
78import org .bukkit .block .BlockFace ;
@@ -24,48 +25,48 @@ public enum DisplayMode {
2425 }
2526
2627 public static final int LineWidth = 15 ;
27-
28+
2829 private final Type type ;
2930 private final DisplayMode display ;
30-
31+
3132 private final StringBuffer textBuffer = new StringBuffer ();
3233
3334 private String [] lines = new String [] { "" , "" , "" , "" };
3435 private int scrollPos = 0 ;
3536 private final List <Location > signList ;
36-
37+
3738 public SignWriter (DisplayMode displayMode , Type type , List <Location > signList ) {
3839 this .type = type ;
3940 this .display = displayMode ;
4041 this .signList = signList ;
4142 }
42-
43+
4344 public DisplayMode getDisplayMode () {
4445 return display ;
4546 }
46-
47+
4748 public String [] getLines () { return lines ; }
48-
49- public void setLines (String [] lines ) {
49+
50+ public void setLines (String [] lines ) {
5051 this .lines = lines ;
5152 }
52-
53+
5354 public String getText () {
5455 return textBuffer .toString ();
5556 }
56-
57+
5758 public void setText (String text ) {
5859 textBuffer .setLength (0 );
5960 textBuffer .append (text .toString ());
60-
61+
6162 if (display ==DisplayMode .scroll )
6263 prepScrollLines ();
6364 else prepWrapLines ();
6465 updateSigns ();
6566 }
66-
67+
6768 List <Location > getSigns () { return signList ; }
68-
69+
6970 public void write (String text ) {
7071 if (display ==DisplayMode .add ) {
7172 add (text );
@@ -79,22 +80,22 @@ public void write(String text) {
7980 add (text );
8081 prepScrollLines ();
8182 }
82-
83+
8384 updateSigns ();
8485 }
85-
86+
8687 public void write (boolean [] bits , int start , int length ) {
8788 write (convertBits (bits , start , length ));
8889 }
89-
90+
9091 public void clear () {
9192 textBuffer .setLength (0 );
9293 scrollPos = 0 ;
9394 lines [0 ] = "" ;
9495 lines [1 ] = "" ;
9596 lines [2 ] = "" ;
9697 lines [3 ] = "" ;
97- updateSigns ();
98+ updateSigns ();
9899 }
99100
100101 public void scroll (int amount ) {
@@ -105,9 +106,9 @@ public void scroll(int amount) {
105106
106107 prepScrollLines ();
107108
108- updateSigns ();
109+ updateSigns ();
109110 }
110-
111+
111112 private void add (String text ) {
112113 if (type ==Type .ascii || textBuffer .length ()==0 ) {
113114 textBuffer .append (text );
@@ -123,9 +124,9 @@ private void updateSigns() {
123124 s .setLine (2 , lines [2 ]);
124125 s .setLine (3 , lines [3 ]);
125126 s .update ();
126- }
127+ }
127128 }
128-
129+
129130 private void prepScrollLines () {
130131 String window ;
131132
@@ -142,7 +143,7 @@ private void prepScrollLines() {
142143 lines [2 ] = "" ;
143144 lines [3 ] = "" ;
144145 }
145-
146+
146147 private void prepWrapLines () {
147148 if (textBuffer .length ()>LineWidth *3 ) {
148149 String line4 = textBuffer .substring (LineWidth *3 );
@@ -160,7 +161,7 @@ private void prepWrapLines() {
160161 } else if (textBuffer .length ()>LineWidth ) {
161162 lines [0 ] = textBuffer .substring (0 ,LineWidth );
162163 lines [1 ] = textBuffer .substring (LineWidth );
163- lines [2 ] = "" ;
164+ lines [2 ] = "" ;
164165 lines [3 ] = "" ;
165166 } else {
166167 lines [0 ] = textBuffer .toString ();
@@ -169,7 +170,7 @@ private void prepWrapLines() {
169170 lines [3 ] = "" ;
170171 }
171172 }
172-
173+
173174 private String convertBits (boolean [] bits , int start , int length ) {
174175 String text = null ;
175176
@@ -191,7 +192,7 @@ private String convertBits(boolean[] bits, int start, int length) {
191192
192193 return text ;
193194 }
194-
195+
195196 public static SignWriter getSignWriter (DisplayMode mode , Type type , Location ... aroundBlocks ) {
196197 List <Location > signs = new ArrayList <>();
197198
@@ -209,10 +210,10 @@ public static SignWriter getSignWriter(DisplayMode mode, Type type, Location...
209210 if (checkBlock (i , east )) { signs .add (east ); }
210211 if (checkBlock (i , up )) { signs .add (up ); }
211212 }
212-
213- return new SignWriter (mode , type , signs );
213+
214+ return new SignWriter (mode , type , signs );
214215 }
215-
216+
216217 private static boolean checkBlock (Block i , Location s ) {
217218 // TODO: Check whether this method loads the chunk or not.
218219 Block sign = s .getBlock ();
@@ -223,5 +224,5 @@ private static boolean checkBlock(Block i, Location s) {
223224
224225 } else return false ;
225226 }
226-
227+
227228}
0 commit comments