@@ -153,16 +153,21 @@ private void runStructurePrinter() {
153153 * Build something in the queue. Structures are built one by one
154154 */
155155 private void buildStructure () {
156+ //BentoBox.getInstance().logDebug("buildStructure");
156157 // Only kick off a build if there is something to build and something isn't
157158 // already being built
158159 if (!pasting && !itemsToBuild .isEmpty ()) {
159160 // Build item
161+ //BentoBox.getInstance().logDebug("Build item");
160162 StructureRecord item = itemsToBuild .poll ();
161163 placeStructure (item );
164+ } else {
165+ //BentoBox.getInstance().logDebug("Nothing to do");
162166 }
163167 }
164168
165169 private void placeStructure (StructureRecord item ) {
170+ //BentoBox.getInstance().logDebug("Placing structure");
166171 // Set the semaphore - only paste one at a time
167172 pasting = true ;
168173 // Place the structure - this cannot be done async
@@ -226,12 +231,14 @@ public void onChunkLoad(ChunkLoadEvent e) {
226231 if (!(addon .inWorld (chunk .getWorld ()))) {
227232 return ;
228233 }
234+ //BentoBox.getInstance().logDebug(e.getEventName());
229235 Pair <Integer , Integer > chunkCoords = new Pair <Integer , Integer >(chunk .getX (), chunk .getZ ());
230236 if (pending .containsKey (chunkCoords )) {
231237 Iterator <StructureRecord > it = pending .get (chunkCoords ).iterator ();
232238 while (it .hasNext ()) {
233239 StructureRecord item = it .next ();
234240 if (item .location ().getWorld ().equals (e .getWorld ())) {
241+ //BentoBox.getInstance().logDebug("Placing structure in itemsToBuild " + item);
235242 this .itemsToBuild .add (item );
236243 it .remove ();
237244 }
@@ -240,6 +247,8 @@ public void onChunkLoad(ChunkLoadEvent e) {
240247 ToBePlacedStructures tbd = new ToBePlacedStructures ();
241248 tbd .setReadyToBuild (pending );
242249 toPlace .saveObjectAsync (tbd );
250+ } else {
251+ //BentoBox.getInstance().logDebug("Nothing to build in this chunk");
243252 }
244253 }
245254
@@ -382,23 +391,28 @@ private void place(ConfigurationSection section, Location center, Environment en
382391 int y = Integer .parseInt (coords [1 ].strip ());
383392 int z = Integer .parseInt (coords [2 ].strip ()) + center .getBlockZ ();
384393 Location location = new Location (world , x , y , z );
385-
394+ //BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
386395 readyToBuild .computeIfAbsent (new Pair <>(x >> 4 , z >> 4 ), k -> new ArrayList <>())
387396 .add (new StructureRecord (name , "minecraft:" + name , location ,
388397 rotation , mirror , noMobs ));
398+ this .itemsToBuild
399+ .add (new StructureRecord (name , "minecraft:" + name , location , rotation , mirror , noMobs ));
389400 } else {
390401 addon .logError ("Structure file syntax error: " + vector + ": " + Arrays .toString (coords ));
391402 }
392403 }
393-
404+ // Load any todo's and add the ones from this new island to the list
394405 ToBePlacedStructures tbd = this .loadToDos ();
395406 Map <Pair <Integer , Integer >, List <StructureRecord >> mergedMap = tbd .getReadyToBuild ();
396407 readyToBuild .forEach ((key , value ) -> mergedMap .merge (key , value , (list1 , list2 ) -> {
397408 list1 .addAll (list2 );
398409 return list1 ;
399410 }));
400411
401- tbd .setReadyToBuild (readyToBuild );
412+ //BentoBox.getInstance().logDebug("mergedMap size = " + mergedMap.size());
413+ //BentoBox.getInstance().logDebug("readyToBuild size = " + readyToBuild.size());
414+ // Save the list
415+ tbd .setReadyToBuild (mergedMap );
402416 toPlace .saveObjectAsync (tbd );
403417 }
404418
@@ -630,10 +644,12 @@ private static String nmsData(Block block) {
630644
631645 private ToBePlacedStructures loadToDos () {
632646 if (!toPlace .objectExists (TODO )) {
647+ //BentoBox.getInstance().logDebug("No TODO list");
633648 return new ToBePlacedStructures ();
634649 }
635650 ToBePlacedStructures list = toPlace .loadObject (TODO );
636651 if (list == null ) {
652+ //BentoBox.getInstance().logDebug("TODO list is null");
637653 return new ToBePlacedStructures ();
638654 }
639655 if (!list .getReadyToBuild ().isEmpty ()) {
0 commit comments