Merge pull request #102 from BentoBoxWorld/develop

Fixes for 1.21.3
This commit is contained in:
tastybento 2024-11-23 10:57:30 -08:00 committed by GitHub
commit a0e9fa943c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 58 additions and 110 deletions

39
pom.xml
View File

@ -55,6 +55,7 @@
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<paper.version>1.21.3-R0.1-SNAPSHOT</paper.version>
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
@ -115,6 +116,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>bentoboxworld</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
@ -172,13 +177,6 @@
<scope>provided</scope>
</dependency>
<!-- Spigot NMS. Used for chunk deletion and pasting. -->
<dependency>
<groupId>org.spigotmc....</groupId>
<artifactId>spigot</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
@ -191,24 +189,6 @@
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc.</groupId>
<artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc..</groupId>
<artifactId>spigot</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc...</groupId>
<artifactId>spigot</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@ -321,7 +301,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.4.1</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -153,21 +153,16 @@ public class NewAreaListener implements Listener {
* Build something in the queue. Structures are built one by one
*/
private void buildStructure() {
//BentoBox.getInstance().logDebug("buildStructure");
// Only kick off a build if there is something to build and something isn't
// already being built
if (!pasting && !itemsToBuild.isEmpty()) {
// Build item
//BentoBox.getInstance().logDebug("Build item");
StructureRecord item = itemsToBuild.poll();
placeStructure(item);
} else {
//BentoBox.getInstance().logDebug("Nothing to do");
}
}
private void placeStructure(StructureRecord item) {
//BentoBox.getInstance().logDebug("Placing structure");
// Set the semaphore - only paste one at a time
pasting = true;
// Place the structure - this cannot be done async
@ -231,14 +226,13 @@ public class NewAreaListener implements Listener {
if (!(addon.inWorld(chunk.getWorld()))) {
return;
}
//BentoBox.getInstance().logDebug(e.getEventName());
Pair<Integer, Integer> chunkCoords = new Pair<Integer, Integer>(chunk.getX(), chunk.getZ());
if (pending.containsKey(chunkCoords)) {
Iterator<StructureRecord> it = pending.get(chunkCoords).iterator();
while (it.hasNext()) {
StructureRecord item = it.next();
if (item.location().getWorld().equals(e.getWorld())) {
//BentoBox.getInstance().logDebug("Placing structure in itemsToBuild " + item);
// Placing structure in itemsToBuild
this.itemsToBuild.add(item);
it.remove();
}
@ -247,8 +241,6 @@ public class NewAreaListener implements Listener {
ToBePlacedStructures tbd = new ToBePlacedStructures();
tbd.setReadyToBuild(pending);
toPlace.saveObjectAsync(tbd);
} else {
//BentoBox.getInstance().logDebug("Nothing to build in this chunk");
}
}
@ -394,10 +386,9 @@ public class NewAreaListener implements Listener {
int y = Integer.parseInt(coords[1].strip());
int z = Integer.parseInt(coords[2].strip()) + center.getBlockZ();
Location location = new Location(world, x, y, z);
//BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
// Structure will be placed at location
readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>())
.add(new StructureRecord(name, "minecraft:" + name, location,
rotation, mirror, noMobs));
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
this.itemsToBuild
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
} else {
@ -412,8 +403,6 @@ public class NewAreaListener implements Listener {
return list1;
}));
//BentoBox.getInstance().logDebug("mergedMap size = " + mergedMap.size());
//BentoBox.getInstance().logDebug("readyToBuild size = " + readyToBuild.size());
// Save the list
tbd.setReadyToBuild(mergedMap);
toPlace.saveObjectAsync(tbd);
@ -508,6 +497,7 @@ public class NewAreaListener implements Listener {
}
private static void processJigsaw(Block b, StructureRotation structureRotation, boolean pasteMobs) {
try {
String data = nmsData(b);
if (data.isEmpty()) {
return;
@ -519,6 +509,9 @@ public class NewAreaListener implements Listener {
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
spawnMob(b, bjb);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void spawnMob(Block b, BoxedJigsawBlock bjb) {
@ -549,17 +542,12 @@ public class NewAreaListener implements Listener {
} else if (bjb.getPool().contains("villagers")) {
type = EntityType.VILLAGER;
}
// if (type == null) {
// BentoBox.getInstance().logDebug(bjb.getPool());
// }
// Spawn it
if (type != null) {
Entity e = b.getWorld().spawnEntity(b.getRelative(BlockFace.UP).getLocation(), type);
if (e != null) {
e.setPersistent(true);
}
// BentoBox.getInstance().logDebug("Spawned a " + type + " at " +
// b.getRelative(BlockFace.UP).getLocation());
}
}
@ -646,12 +634,10 @@ public class NewAreaListener implements Listener {
private ToBePlacedStructures loadToDos() {
if (!toPlace.objectExists(TODO)) {
//BentoBox.getInstance().logDebug("No TODO list");
return new ToBePlacedStructures();
}
ToBePlacedStructures list = toPlace.loadObject(TODO);
if (list == null) {
//BentoBox.getInstance().logDebug("TODO list is null");
return new ToBePlacedStructures();
}
if (!list.getReadyToBuild().isEmpty()) {

View File

@ -8,10 +8,8 @@ import org.bukkit.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
import net.minecraft.world.level.block.entity.TileEntity;
import world.bentobox.bentobox.BentoBox;
/**
*
*/
public abstract class AbstractMetaData {
public abstract String nmsData(Block block);

View File

@ -1,21 +0,0 @@
package world.bentobox.boxed.nms.v1_20_4_R0_1_SNAPSHOT;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.block.entity.TileEntity;
import world.bentobox.boxed.nms.AbstractMetaData;
public class GetMetaData extends AbstractMetaData {
@Override
public String nmsData(Block block) {
Location w = block.getLocation();
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
return getData(te, "j", "c");
}
}

View File

@ -1,20 +0,0 @@
package world.bentobox.boxed.nms.v1_20_6_R0_1_SNAPSHOT;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_20_R4.CraftWorld;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.block.entity.TileEntity;
import world.bentobox.boxed.nms.AbstractMetaData;
public class GetMetaData extends AbstractMetaData {
@Override
public String nmsData(Block block) {
Location w = block.getLocation();
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
return getData(te, "au_", "tag");
}
}

View File

@ -1,5 +1,22 @@
package world.bentobox.boxed.nms.v1_21_3_R0_1_SNAPSHOT;
public class GetMetaData extends world.bentobox.boxed.nms.v1_21_R0_1_SNAPSHOT.GetMetaData {
// Identical to 1.21
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.block.entity.TileEntity;
import world.bentobox.boxed.nms.AbstractMetaData;
public class GetMetaData extends AbstractMetaData {
@Override
public String nmsData(Block block) {
Location w = block.getLocation();
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
// for 1.13+ (we have use WorldServer)
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
return getData(te, "getUpdatePacket", "tag");
}
}

View File

@ -24,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNull;
public final class ServerMocks {
@SuppressWarnings({ "deprecation", "unchecked" })
public static @NonNull Server newServer() {
Server mock = mock(Server.class);
@ -66,7 +67,7 @@ public final class ServerMocks {
doReturn(key).when(keyed).getKey();
return keyed;
});
}).when(registry).get(notNull());
}).when(registry).get((NamespacedKey) notNull());
return registry;
})).when(mock).getRegistry(notNull());