3737/**
3838 * A ChangedSign represents a single side of a sign block.
3939 */
40- public class ChangedSign {
40+ public class BukkitChangedSign extends ChangedSign {
4141 private final Block block ;
4242 private final Side side ;
4343
4444 private @ Nullable Sign sign ;
4545 private Component @ Nullable [] lines ;
4646 private Component @ Nullable [] oldLines ;
4747
48- private ChangedSign (Block block , Side side , Component @ Nullable [] lines , @ Nullable CraftBookPlayer player ) {
48+ private BukkitChangedSign (Block block , Side side , Component @ Nullable [] lines , @ Nullable CraftBookPlayer player ) {
4949 this .block = block ;
5050 this .side = side ;
5151
@@ -62,6 +62,7 @@ private ChangedSign(Block block, Side side, Component @Nullable [] lines, @Nulla
6262 }
6363 }
6464
65+ @ Override
6566 public void checkPlayerVariablePermissions (CraftBookPlayer player ) {
6667 if (this .lines != null && VariableManager .instance != null ) {
6768 for (int i = 0 ; i < 4 ; i ++) {
@@ -101,34 +102,42 @@ public Material getType() {
101102 return block .getType ();
102103 }
103104
105+ @ Override
104106 public int getX () {
105107 return this .block .getX ();
106108 }
107109
110+ @ Override
108111 public int getY () {
109112 return this .block .getY ();
110113 }
111114
115+ @ Override
112116 public int getZ () {
113117 return this .block .getZ ();
114118 }
115119
120+ @ Override
116121 public Component @ Nullable [] getLines () {
117122 return this .lines ;
118123 }
119124
125+ @ Override
120126 public Component getLine (int index ) throws IndexOutOfBoundsException {
121127 return this .getLine (index , null );
122128 }
123129
130+ @ Override
124131 public Component getLine (int index , @ Nullable Player player ) throws IndexOutOfBoundsException {
125132 return ParsingUtil .parseLine (this .lines [index ], player );
126133 }
127134
135+ @ Override
128136 public Component getRawLine (int index ) throws IndexOutOfBoundsException {
129137 return this .lines [index ];
130138 }
131139
140+ @ Override
132141 public void setLine (int index , Component line ) throws IndexOutOfBoundsException {
133142 this .lines [index ] = line ;
134143 }
@@ -137,6 +146,7 @@ public void setType(Material type) {
137146 block .setType (type );
138147 }
139148
149+ @ Override
140150 public boolean update (boolean force ) {
141151 if (!hasChanged () && !force ) {
142152 return false ;
@@ -150,14 +160,17 @@ public boolean update(boolean force) {
150160 return getSign ().update (force , false );
151161 }
152162
163+ @ Override
153164 public void setLines (Component [] lines ) {
154165 this .lines = lines ;
155166 }
156167
168+ @ Override
157169 public void setOldLines (Component [] oldLines ) {
158170 this .oldLines = oldLines ;
159171 }
160172
173+ @ Override
161174 public boolean hasChanged () {
162175 for (int i = 0 ; i < 4 ; i ++) {
163176 if (!Objects .equals (this .oldLines [i ], this .lines [i ])) {
@@ -168,6 +181,7 @@ public boolean hasChanged() {
168181 return false ;
169182 }
170183
184+ @ Override
171185 public void flushLines () {
172186 this .sign = null ;
173187 this .lines = this .getSignSide ().lines ().toArray (new Component [0 ]);
@@ -179,18 +193,9 @@ public void flushLines() {
179193 System .arraycopy (this .lines , 0 , this .oldLines , 0 , this .lines .length );
180194 }
181195
182- public boolean updateSign (ChangedSign sign ) {
183- if (!equals (sign )) {
184- flushLines ();
185- return true ;
186- }
187-
188- return false ;
189- }
190-
191196 @ Override
192197 public boolean equals (Object o ) {
193- if (o instanceof ChangedSign other ) {
198+ if (o instanceof BukkitChangedSign other ) {
194199 return Objects .equals (other .getType (), getType ())
195200 && other .getSide () == getSide ()
196201 && other .getX () == getX ()
@@ -213,22 +218,22 @@ public String toString() {
213218 return Arrays .stream (this .lines ).map (PlainTextComponentSerializer .plainText ()::serialize ).collect (Collectors .joining ("|" ));
214219 }
215220
216- public static ChangedSign create (Sign sign , Side side ) {
221+ public static BukkitChangedSign create (Sign sign , Side side ) {
217222 return create (sign .getBlock (), side , sign .getSide (side ).lines ().toArray (new Component [0 ]), null );
218223 }
219224
220- public static ChangedSign create (Sign sign , Side side , @ Nullable CraftBookPlayer player ) {
225+ public static BukkitChangedSign create (Sign sign , Side side , @ Nullable CraftBookPlayer player ) {
221226 return create (sign .getBlock (), side , sign .getSide (side ).lines ().toArray (new Component [0 ]), player );
222227 }
223228
224- public static ChangedSign create (Block block , Side side ) {
229+ public static BukkitChangedSign create (Block block , Side side ) {
225230 return create (block , side , null , null );
226231 }
227232
228- public static ChangedSign create (Block block , Side side , Component @ Nullable [] lines , @ Nullable CraftBookPlayer player ) {
233+ public static BukkitChangedSign create (Block block , Side side , Component @ Nullable [] lines , @ Nullable CraftBookPlayer player ) {
229234 Preconditions .checkNotNull (block , "block" );
230235 Preconditions .checkNotNull (side , "side" );
231236
232- return new ChangedSign (block , side , lines , player );
237+ return new BukkitChangedSign (block , side , lines , player );
233238 }
234239}
0 commit comments