diff --git a/pom.xml b/pom.xml index b67d651..e6fa1d7 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,7 @@ org.mockito mockito-core - 4.8.0 + 3.11.1 test @@ -217,7 +217,7 @@ - + org.apache.maven.plugins maven-clean-plugin @@ -236,7 +236,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.1 ${java.version} @@ -247,15 +247,62 @@ 3.0.0-M5 - --illegal-access=permit + ${argLine} + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.math=ALL-UNNAMED + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens + java.base/java.util.stream=ALL-UNNAMED + --add-opens java.base/java.text=ALL-UNNAMED + --add-opens + java.base/java.util.regex=ALL-UNNAMED + --add-opens + java.base/java.nio.channels.spi=ALL-UNNAMED + --add-opens java.base/sun.nio.ch=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens + java.base/java.util.concurrent=ALL-UNNAMED + --add-opens java.base/sun.nio.fs=ALL-UNNAMED + --add-opens java.base/sun.nio.cs=ALL-UNNAMED + --add-opens java.base/java.nio.file=ALL-UNNAMED + --add-opens + java.base/java.nio.charset=ALL-UNNAMED + --add-opens + java.base/java.lang.reflect=ALL-UNNAMED + --add-opens + java.logging/java.util.logging=ALL-UNNAMED + --add-opens java.base/java.lang.ref=ALL-UNNAMED + --add-opens java.base/java.util.jar=ALL-UNNAMED + --add-opens java.base/java.util.zip=ALL-UNNAMED - + org.apache.maven.plugins maven-jar-plugin 3.1.0 + + org.apache.maven.plugins + maven-javadoc-plugin + 3.3.0 + + false + -Xdoclint:none + + ${java.home}/bin/javadoc + + + + attach-javadocs + install + + jar + + + + org.apache.maven.plugins maven-source-plugin @@ -282,7 +329,7 @@ org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.7 true @@ -293,16 +340,21 @@ - pre-unit-test + prepare-agent prepare-agent - post-unit-test + report report + + + XML + + diff --git a/src/main/java/world/bentobox/boxed/Boxed.java b/src/main/java/world/bentobox/boxed/Boxed.java index bb6d325..352b966 100644 --- a/src/main/java/world/bentobox/boxed/Boxed.java +++ b/src/main/java/world/bentobox/boxed/Boxed.java @@ -280,7 +280,7 @@ public class Boxed extends GameModeAddon { int p = (int) (count / percent * 100); if (p % 10 == 0 && p != last) { last = p; - this.log("Storing seed chunks for " + world.getEnvironment() + " " + p + "% done"); + this.log("Pregenrating seed chunks for " + world.getName() + "'s " + world.getEnvironment() + " " + p + "% done"); } } @@ -293,10 +293,7 @@ public class Boxed extends GameModeAddon { * @return the chunkGenerator for the environment */ public AbstractBoxedChunkGenerator getChunkGenerator(Environment env) { - if (env.equals(Environment.NORMAL)) { - return chunkGenerator; - } - return netherChunkGenerator; + return env.equals(Environment.NORMAL) ? chunkGenerator : netherChunkGenerator; } /** diff --git a/src/main/java/world/bentobox/boxed/generators/chunks/AbstractBoxedChunkGenerator.java b/src/main/java/world/bentobox/boxed/generators/chunks/AbstractBoxedChunkGenerator.java index c5d6290..77d0407 100644 --- a/src/main/java/world/bentobox/boxed/generators/chunks/AbstractBoxedChunkGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/chunks/AbstractBoxedChunkGenerator.java @@ -53,12 +53,12 @@ public abstract class AbstractBoxedChunkGenerator extends ChunkGenerator { } } } - chunks.put(new Pair<>(x, z), new ChunkStore(chunk.getChunkSnapshot(), getEnts(chunk), getChests(chunk), chunkBiomes)); + chunks.put(new Pair<>(x, z), new ChunkStore(chunk.getChunkSnapshot(), getEnts(chunk), getTileEnts(chunk), chunkBiomes)); } protected abstract List getEnts(Chunk chunk); - protected abstract List getChests(Chunk chunk); + protected abstract List getTileEnts(Chunk chunk); /** * Get the chunk store for these chunk coords or null if there is none. @@ -84,13 +84,15 @@ public abstract class AbstractBoxedChunkGenerator extends ChunkGenerator { * @return mapped chunk coord */ public static int repeatCalc(int chunkCoord) { + return Math.floorMod(chunkCoord + size, size*2) - size; + /* int xx; if (chunkCoord > 0) { xx = Math.floorMod(chunkCoord + size, size*2) - size; } else { xx = Math.floorMod(chunkCoord - size, -size*2) + size; } - return xx; + return xx;*/ } /** diff --git a/src/main/java/world/bentobox/boxed/generators/chunks/BoxedBlockPopulator.java b/src/main/java/world/bentobox/boxed/generators/chunks/BoxedBlockPopulator.java index d3c98a1..811fd79 100644 --- a/src/main/java/world/bentobox/boxed/generators/chunks/BoxedBlockPopulator.java +++ b/src/main/java/world/bentobox/boxed/generators/chunks/BoxedBlockPopulator.java @@ -18,7 +18,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.util.Vector; -import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock; import world.bentobox.bentobox.blueprints.dataobjects.BlueprintCreatureSpawner; import world.bentobox.bentobox.util.Pair; @@ -53,7 +52,6 @@ public class BoxedBlockPopulator extends BlockPopulator { ChunkStore data = chunks.get(coords); // Paste entities data.bpEnts().forEach(e -> { - Location l = getLoc(world, e.relativeLoc().clone(), chunkX, chunkZ); if (limitedRegion.isInRegion(l)) { Entity ent = limitedRegion.spawnEntity(l, e.entity().getType()); @@ -62,10 +60,14 @@ public class BoxedBlockPopulator extends BlockPopulator { }); // Fill chests limitedRegion.getTileEntities().forEach(te -> { - for (ChestData cd : data.chests()) { - Location chestLoc = getLoc(world, cd.relativeLoc().clone(), chunkX, chunkZ); - if (limitedRegion.isInRegion(chestLoc) && te.getLocation().equals(chestLoc)) { - this.setBlockState(te, cd.chest()); + int teX = BoxedChunkGenerator.repeatCalc(te.getX() >> 4); + int teZ = BoxedChunkGenerator.repeatCalc(te.getZ() >> 4); + if (teX == xx && teZ == zz) { + for (ChestData cd : data.chests()) { + Location chestLoc = getLoc(world, cd.relativeLoc().clone(), chunkX, chunkZ); + if (limitedRegion.isInRegion(chestLoc) && te.getLocation().equals(chestLoc)) { + this.setBlockState(te, cd.chest()); + } } } }); @@ -118,7 +120,6 @@ public class BoxedBlockPopulator extends BlockPopulator { spawner.setDelay(s.getDelay()); spawner.setRequiredPlayerRange(s.getRequiredPlayerRange()); spawner.setSpawnRange(s.getSpawnRange()); - BentoBox.getInstance().logDebug("Set spawner at " + spawner.getLocation() + " to " + s.getSpawnedType()); spawner.update(true, false); } diff --git a/src/main/java/world/bentobox/boxed/generators/chunks/BoxedChunkGenerator.java b/src/main/java/world/bentobox/boxed/generators/chunks/BoxedChunkGenerator.java index c462e39..e4ca1f5 100644 --- a/src/main/java/world/bentobox/boxed/generators/chunks/BoxedChunkGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/chunks/BoxedChunkGenerator.java @@ -72,7 +72,7 @@ public class BoxedChunkGenerator extends AbstractBoxedChunkGenerator { } @Override - protected List getChests(Chunk chunk) { + protected List getTileEnts(Chunk chunk) { return Arrays.stream(chunk.getTileEntities()).map(t -> new ChestData(getLocInChunk(t.getLocation()), this.getBluePrintBlock(t.getBlock()))).toList(); } @@ -120,8 +120,10 @@ public class BoxedChunkGenerator extends AbstractBoxedChunkGenerator { return bpEnts; } + // Get the location in the chunk private Vector getLocInChunk(Location l) { - return new Vector(l.getBlockX() % 16, l.getBlockY(), l.getBlockZ() % 16); + // Have to use Math function because java % doesn't work correctly IMO with negatives + return new Vector(Math.floorMod(l.getBlockX(),16), l.getBlockY(), Math.floorMod(l.getBlockZ(), 16)); } diff --git a/src/main/java/world/bentobox/boxed/generators/chunks/BoxedSeedChunkGenerator.java b/src/main/java/world/bentobox/boxed/generators/chunks/BoxedSeedChunkGenerator.java index 81e40f2..6ba8dab 100644 --- a/src/main/java/world/bentobox/boxed/generators/chunks/BoxedSeedChunkGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/chunks/BoxedSeedChunkGenerator.java @@ -83,7 +83,7 @@ public class BoxedSeedChunkGenerator extends AbstractBoxedChunkGenerator { } @Override - protected List getChests(Chunk chunk) { + protected List getTileEnts(Chunk chunk) { // These won't be stored return null; } diff --git a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java index 651b4c9..d65bf1a 100644 --- a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java @@ -30,7 +30,6 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.events.island.IslandNewIslandEvent; import world.bentobox.bentobox.api.events.team.TeamJoinedEvent; import world.bentobox.bentobox.api.events.team.TeamLeaveEvent; @@ -195,8 +194,6 @@ public class AdvancementListener implements Listener { public static void giveAdv(Player player, Advancement adv) { //BentoBox.getInstance().logDebug("Give Adv " + adv.getKey() + " done status " + player.getAdvancementProgress(adv).isDone()); if (adv != null && !player.getAdvancementProgress(adv).isDone()) { - BentoBox.getInstance().logDebug("Awarding "); - //adv.getCriteria().forEach(c -> BentoBox.getInstance().logDebug("Criteria = " + c)); adv.getCriteria().forEach(player.getAdvancementProgress(adv)::awardCriteria); } }