Merge pull request #90 from BentoBoxWorld/develop

Release 2.7.1
This commit is contained in:
tastybento 2024-07-30 22:31:58 -07:00 committed by GitHub
commit 92016ed3b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -65,7 +65,7 @@
<!-- Do not change unless you want different name for local builds. --> <!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number> <build.number>-LOCAL</build.number>
<!-- This allows to change between versions. --> <!-- This allows to change between versions. -->
<build.version>2.7.0</build.version> <build.version>2.7.1</build.version>
<sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey> <sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization> <sonar.organization>bentobox-world</sonar.organization>

View File

@ -153,16 +153,21 @@ public class NewAreaListener implements Listener {
* Build something in the queue. Structures are built one by one * Build something in the queue. Structures are built one by one
*/ */
private void buildStructure() { private void buildStructure() {
//BentoBox.getInstance().logDebug("buildStructure");
// Only kick off a build if there is something to build and something isn't // Only kick off a build if there is something to build and something isn't
// already being built // already being built
if (!pasting && !itemsToBuild.isEmpty()) { if (!pasting && !itemsToBuild.isEmpty()) {
// Build item // Build item
//BentoBox.getInstance().logDebug("Build item");
StructureRecord item = itemsToBuild.poll(); StructureRecord item = itemsToBuild.poll();
placeStructure(item); placeStructure(item);
} else {
//BentoBox.getInstance().logDebug("Nothing to do");
} }
} }
private void placeStructure(StructureRecord item) { private void placeStructure(StructureRecord item) {
//BentoBox.getInstance().logDebug("Placing structure");
// Set the semaphore - only paste one at a time // Set the semaphore - only paste one at a time
pasting = true; pasting = true;
// Place the structure - this cannot be done async // Place the structure - this cannot be done async
@ -226,12 +231,14 @@ public class NewAreaListener implements Listener {
if (!(addon.inWorld(chunk.getWorld()))) { if (!(addon.inWorld(chunk.getWorld()))) {
return; return;
} }
//BentoBox.getInstance().logDebug(e.getEventName());
Pair<Integer, Integer> chunkCoords = new Pair<Integer, Integer>(chunk.getX(), chunk.getZ()); Pair<Integer, Integer> chunkCoords = new Pair<Integer, Integer>(chunk.getX(), chunk.getZ());
if (pending.containsKey(chunkCoords)) { if (pending.containsKey(chunkCoords)) {
Iterator<StructureRecord> it = pending.get(chunkCoords).iterator(); Iterator<StructureRecord> it = pending.get(chunkCoords).iterator();
while (it.hasNext()) { while (it.hasNext()) {
StructureRecord item = it.next(); StructureRecord item = it.next();
if (item.location().getWorld().equals(e.getWorld())) { if (item.location().getWorld().equals(e.getWorld())) {
//BentoBox.getInstance().logDebug("Placing structure in itemsToBuild " + item);
this.itemsToBuild.add(item); this.itemsToBuild.add(item);
it.remove(); it.remove();
} }
@ -240,6 +247,8 @@ public class NewAreaListener implements Listener {
ToBePlacedStructures tbd = new ToBePlacedStructures(); ToBePlacedStructures tbd = new ToBePlacedStructures();
tbd.setReadyToBuild(pending); tbd.setReadyToBuild(pending);
toPlace.saveObjectAsync(tbd); toPlace.saveObjectAsync(tbd);
} else {
//BentoBox.getInstance().logDebug("Nothing to build in this chunk");
} }
} }
@ -382,15 +391,17 @@ public class NewAreaListener implements Listener {
int y = Integer.parseInt(coords[1].strip()); int y = Integer.parseInt(coords[1].strip());
int z = Integer.parseInt(coords[2].strip()) + center.getBlockZ(); int z = Integer.parseInt(coords[2].strip()) + center.getBlockZ();
Location location = new Location(world, x, y, z); Location location = new Location(world, x, y, z);
//BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>()) readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>())
.add(new StructureRecord(name, "minecraft:" + name, location, .add(new StructureRecord(name, "minecraft:" + name, location,
rotation, mirror, noMobs)); rotation, mirror, noMobs));
this.itemsToBuild
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
} else { } else {
addon.logError("Structure file syntax error: " + vector + ": " + Arrays.toString(coords)); addon.logError("Structure file syntax error: " + vector + ": " + Arrays.toString(coords));
} }
} }
// Load any todo's and add the ones from this new island to the list
ToBePlacedStructures tbd = this.loadToDos(); ToBePlacedStructures tbd = this.loadToDos();
Map<Pair<Integer, Integer>, List<StructureRecord>> mergedMap = tbd.getReadyToBuild(); Map<Pair<Integer, Integer>, List<StructureRecord>> mergedMap = tbd.getReadyToBuild();
readyToBuild.forEach((key, value) -> mergedMap.merge(key, value, (list1, list2) -> { readyToBuild.forEach((key, value) -> mergedMap.merge(key, value, (list1, list2) -> {
@ -398,7 +409,10 @@ public class NewAreaListener implements Listener {
return list1; return list1;
})); }));
tbd.setReadyToBuild(readyToBuild); //BentoBox.getInstance().logDebug("mergedMap size = " + mergedMap.size());
//BentoBox.getInstance().logDebug("readyToBuild size = " + readyToBuild.size());
// Save the list
tbd.setReadyToBuild(mergedMap);
toPlace.saveObjectAsync(tbd); toPlace.saveObjectAsync(tbd);
} }
@ -630,10 +644,12 @@ public class NewAreaListener implements Listener {
private ToBePlacedStructures loadToDos() { private ToBePlacedStructures loadToDos() {
if (!toPlace.objectExists(TODO)) { if (!toPlace.objectExists(TODO)) {
//BentoBox.getInstance().logDebug("No TODO list");
return new ToBePlacedStructures(); return new ToBePlacedStructures();
} }
ToBePlacedStructures list = toPlace.loadObject(TODO); ToBePlacedStructures list = toPlace.loadObject(TODO);
if (list == null) { if (list == null) {
//BentoBox.getInstance().logDebug("TODO list is null");
return new ToBePlacedStructures(); return new ToBePlacedStructures();
} }
if (!list.getReadyToBuild().isEmpty()) { if (!list.getReadyToBuild().isEmpty()) {