3434import org .bukkit .generator .LimitedRegion ;
3535import org .checkerframework .checker .nullness .qual .NonNull ;
3636
37+ import java .util .Objects ;
38+
3739/**
3840 * Wraps a {@link LimitedRegion} inside a {@link com.plotsquared.core.queue.QueueCoordinator} so it can be written to.
3941 *
@@ -44,7 +46,6 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
4446 private static final Logger LOGGER = LogManager .getLogger ("PlotSquared/" + LimitedRegionWrapperQueue .class .getSimpleName ());
4547
4648 private final LimitedRegion limitedRegion ;
47- private boolean useOtherRestoreTagMethod = false ;
4849
4950 /**
5051 * @since 6.9.0
@@ -64,20 +65,11 @@ public boolean setBlock(final int x, final int y, final int z, @NonNull final Ba
6465 boolean result = setBlock (x , y , z , id .toImmutableState ());
6566 if (result && id .hasNbtData ()) {
6667 CompoundTag tag = id .getNbtData ();
67- StateWrapper sw = new StateWrapper (tag );
6868 try {
69- if (useOtherRestoreTagMethod && getWorld () != null ) {
70- sw .restoreTag (getWorld ().getName (), x , y , z );
71- } else {
72- sw .restoreTag (limitedRegion .getBlockState (x , y , z ).getBlock ());
73- }
69+ StateWrapper .INSTANCE .restore (limitedRegion .getBlockState (x , y , z ).getBlock (), Objects .requireNonNull (tag ));
7470 } catch (IllegalArgumentException e ) {
7571 LOGGER .error ("Error attempting to populate tile entity into the world at location {},{},{}" , x , y , z , e );
7672 return false ;
77- } catch (IllegalStateException e ) {
78- useOtherRestoreTagMethod = true ;
79- LOGGER .warn ("IllegalStateException attempting to populate tile entity into the world at location {},{},{}. " +
80- "Possibly on <=1.17.1, switching to secondary method." , x , y , z , e );
8173 }
8274 }
8375 return result ;
@@ -113,9 +105,8 @@ public boolean setEntity(@NonNull final Entity entity) {
113105
114106 @ Override
115107 public boolean setTile (final int x , final int y , final int z , @ NonNull final CompoundTag tag ) {
116- StateWrapper sw = new StateWrapper (tag );
117108 try {
118- return sw . restoreTag (limitedRegion .getBlockState (x , y , z ).getBlock ());
109+ return StateWrapper . INSTANCE . restore (limitedRegion .getBlockState (x , y , z ).getBlock (), tag );
119110 } catch (IllegalArgumentException e ) {
120111 LOGGER .error ("Error attempting to populate tile entity into the world at location {},{},{}" , x , y , z , e );
121112 return false ;
0 commit comments