diff --git a/pom.xml b/pom.xml
index 772fa0b..062688b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,7 @@
2.0.9
1.21.3-R0.1-SNAPSHOT
+ 1.21.3-R0.1-SNAPSHOT
2.7.1-SNAPSHOT
${build.version}-SNAPSHOT
@@ -111,10 +112,14 @@
-
+
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots
+
+ papermc
+ https://repo.papermc.io/repository/maven-public/
+
bentoboxworld
https://repo.codemc.org/repository/bentoboxworld/
@@ -172,14 +177,7 @@
provided
-
-
- org.spigotmc....
- spigot
- 1.20.6-R0.1-SNAPSHOT
- provided
-
-
+
org.spigotmc
spigot
${spigot.version}
@@ -191,24 +189,6 @@
1.21.1-R0.1-SNAPSHOT
provided
-
- org.spigotmc.
- spigot
- 1.20.4-R0.1-SNAPSHOT
- provided
-
-
- org.spigotmc..
- spigot
- 1.20.2-R0.1-SNAPSHOT
- provided
-
-
- org.spigotmc...
- spigot
- 1.20.1-R0.1-SNAPSHOT
- provided
-
@@ -318,10 +298,17 @@
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.1.0
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.4.1
+
+
+
+ spigot
+
+
+
org.apache.maven.plugins
diff --git a/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java b/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java
index 9a99a49..2ac8399 100644
--- a/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java
+++ b/src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java
@@ -153,21 +153,16 @@ private void runStructurePrinter() {
* 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 void onChunkLoad(ChunkLoadEvent e) {
if (!(addon.inWorld(chunk.getWorld()))) {
return;
}
- //BentoBox.getInstance().logDebug(e.getEventName());
Pair chunkCoords = new Pair(chunk.getX(), chunk.getZ());
if (pending.containsKey(chunkCoords)) {
Iterator 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 void onChunkLoad(ChunkLoadEvent e) {
ToBePlacedStructures tbd = new ToBePlacedStructures();
tbd.setReadyToBuild(pending);
toPlace.saveObjectAsync(tbd);
- } else {
- //BentoBox.getInstance().logDebug("Nothing to build in this chunk");
}
}
@@ -394,10 +386,9 @@ private void place(ConfigurationSection section, Location center, Environment en
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 @@ private void place(ConfigurationSection section, Location center, Environment en
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,16 +497,20 @@ private static void processStructureBlock(Block b) {
}
private static void processJigsaw(Block b, StructureRotation structureRotation, boolean pasteMobs) {
- String data = nmsData(b);
- if (data.isEmpty()) {
- return;
- }
- BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
- String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
- BlockData bd = Bukkit.createBlockData(finalState);
- b.setBlockData(bd);
- if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
- spawnMob(b, bjb);
+ try {
+ String data = nmsData(b);
+ if (data.isEmpty()) {
+ return;
+ }
+ BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
+ String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
+ BlockData bd = Bukkit.createBlockData(finalState);
+ b.setBlockData(bd);
+ if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
+ spawnMob(b, bjb);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
@@ -549,17 +542,12 @@ private static void spawnMob(Block b, BoxedJigsawBlock bjb) {
} 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 @@ private static String nmsData(Block block) {
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()) {
diff --git a/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java b/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java
index 94f7576..81906cb 100644
--- a/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java
+++ b/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java
@@ -8,10 +8,8 @@
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);
@@ -30,7 +28,7 @@ protected String getData(TileEntity te, String method, String field) {
Field fieldC = packet.getClass().getDeclaredField(field);
fieldC.setAccessible(true);
NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet);
-
+
return nbtTag.toString(); // This will show what you want
//} else {
// throw new ClassNotFoundException(
diff --git a/src/main/java/world/bentobox/boxed/nms/v1_20_4_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/boxed/nms/v1_20_4_R0_1_SNAPSHOT/GetMetaData.java
deleted file mode 100644
index 639598a..0000000
--- a/src/main/java/world/bentobox/boxed/nms/v1_20_4_R0_1_SNAPSHOT/GetMetaData.java
+++ /dev/null
@@ -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");
- }
-}
\ No newline at end of file
diff --git a/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java
deleted file mode 100644
index 2855074..0000000
--- a/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java
+++ /dev/null
@@ -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");
- }
-}
\ No newline at end of file
diff --git a/src/main/java/world/bentobox/boxed/nms/v1_21_3_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/boxed/nms/v1_21_3_R0_1_SNAPSHOT/GetMetaData.java
index 0cf1131..c0df15e 100644
--- a/src/main/java/world/bentobox/boxed/nms/v1_21_3_R0_1_SNAPSHOT/GetMetaData.java
+++ b/src/main/java/world/bentobox/boxed/nms/v1_21_3_R0_1_SNAPSHOT/GetMetaData.java
@@ -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");
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/world/bentobox/boxed/mocks/ServerMocks.java b/src/test/java/world/bentobox/boxed/mocks/ServerMocks.java
index a4f2f40..9533491 100644
--- a/src/test/java/world/bentobox/boxed/mocks/ServerMocks.java
+++ b/src/test/java/world/bentobox/boxed/mocks/ServerMocks.java
@@ -24,6 +24,7 @@
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());