mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-01-20 20:51:27 +01:00
Fix bug with spawners not being set.
This commit is contained in:
parent
40ecdbdba6
commit
36162fe293
64
pom.xml
64
pom.xml
@ -150,7 +150,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>4.8.0</version>
|
||||
<version>3.11.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -236,7 +236,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>${java.version}</release>
|
||||
</configuration>
|
||||
@ -247,7 +247,34 @@
|
||||
<version>3.0.0-M5</version>
|
||||
<configuration>
|
||||
<argLine>
|
||||
--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
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@ -256,6 +283,26 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
<additionalJOption>-Xdoclint:none</additionalJOption>
|
||||
<!-- To compile with Java 11, this tag may be required -->
|
||||
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
@ -282,7 +329,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.3</version>
|
||||
<version>0.8.7</version>
|
||||
<configuration>
|
||||
<append>true</append>
|
||||
<excludes>
|
||||
@ -293,16 +340,21 @@
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>pre-unit-test</id>
|
||||
<id>prepare-agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>post-unit-test</id>
|
||||
<id>report</id>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<formats>
|
||||
<format>XML</format>
|
||||
</formats>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<EntityData> getEnts(Chunk chunk);
|
||||
|
||||
protected abstract List<ChestData> getChests(Chunk chunk);
|
||||
protected abstract List<ChestData> 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;*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,12 +60,16 @@ public class BoxedBlockPopulator extends BlockPopulator {
|
||||
});
|
||||
// Fill chests
|
||||
limitedRegion.getTileEntities().forEach(te -> {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class BoxedChunkGenerator extends AbstractBoxedChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ChestData> getChests(Chunk chunk) {
|
||||
protected List<ChestData> 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));
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class BoxedSeedChunkGenerator extends AbstractBoxedChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ChestData> getChests(Chunk chunk) {
|
||||
protected List<ChestData> getTileEnts(Chunk chunk) {
|
||||
// These won't be stored
|
||||
return null;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user