Skip to content

Commit a0e9fa9

Browse files
authored
Merge pull request #102 from BentoBoxWorld/develop
Fixes for 1.21.3
2 parents 091c767 + 14dee15 commit a0e9fa9

File tree

7 files changed

+58
-110
lines changed

7 files changed

+58
-110
lines changed

pom.xml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<powermock.version>2.0.9</powermock.version>
5656
<!-- More visible way how to change dependency versions -->
5757
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
58+
<paper.version>1.21.3-R0.1-SNAPSHOT</paper.version>
5859
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
5960
<!-- Revision variable removes warning about dynamic version -->
6061
<revision>${build.version}-SNAPSHOT</revision>
@@ -111,10 +112,14 @@
111112
</profiles>
112113

113114
<repositories>
114-
<repository>
115+
<repository>
115116
<id>spigot-repo</id>
116117
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
117118
</repository>
119+
<repository>
120+
<id>papermc</id>
121+
<url>https://repo.papermc.io/repository/maven-public/</url>
122+
</repository>
118123
<repository>
119124
<id>bentoboxworld</id>
120125
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
@@ -172,14 +177,7 @@
172177
<scope>provided</scope>
173178
</dependency>
174179
<!-- Spigot NMS. Used for chunk deletion and pasting. -->
175-
176-
<dependency>
177-
<groupId>org.spigotmc....</groupId>
178-
<artifactId>spigot</artifactId>
179-
<version>1.20.6-R0.1-SNAPSHOT</version>
180-
<scope>provided</scope>
181-
</dependency>
182-
<dependency>
180+
<dependency>
183181
<groupId>org.spigotmc</groupId>
184182
<artifactId>spigot</artifactId>
185183
<version>${spigot.version}</version>
@@ -191,24 +189,6 @@
191189
<version>1.21.1-R0.1-SNAPSHOT</version>
192190
<scope>provided</scope>
193191
</dependency>
194-
<dependency>
195-
<groupId>org.spigotmc.</groupId>
196-
<artifactId>spigot</artifactId>
197-
<version>1.20.4-R0.1-SNAPSHOT</version>
198-
<scope>provided</scope>
199-
</dependency>
200-
<dependency>
201-
<groupId>org.spigotmc..</groupId>
202-
<artifactId>spigot</artifactId>
203-
<version>1.20.2-R0.1-SNAPSHOT</version>
204-
<scope>provided</scope>
205-
</dependency>
206-
<dependency>
207-
<groupId>org.spigotmc...</groupId>
208-
<artifactId>spigot</artifactId>
209-
<version>1.20.1-R0.1-SNAPSHOT</version>
210-
<scope>provided</scope>
211-
</dependency>
212192
</dependencies>
213193

214194
<build>
@@ -318,10 +298,17 @@
318298
</argLine>
319299
</configuration>
320300
</plugin>
321-
<plugin>
322-
<groupId>org.apache.maven.plugins</groupId>
323-
<artifactId>maven-jar-plugin</artifactId>
324-
<version>3.1.0</version>
301+
<plugin>
302+
<groupId>org.apache.maven.plugins</groupId>
303+
<artifactId>maven-jar-plugin</artifactId>
304+
<version>3.4.1</version>
305+
<configuration>
306+
<archive>
307+
<manifestEntries>
308+
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
309+
</manifestEntries>
310+
</archive>
311+
</configuration>
325312
</plugin>
326313
<plugin>
327314
<groupId>org.apache.maven.plugins</groupId>

src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,16 @@ private void runStructurePrinter() {
153153
* Build something in the queue. Structures are built one by one
154154
*/
155155
private void buildStructure() {
156-
//BentoBox.getInstance().logDebug("buildStructure");
157156
// Only kick off a build if there is something to build and something isn't
158157
// already being built
159158
if (!pasting && !itemsToBuild.isEmpty()) {
160159
// Build item
161-
//BentoBox.getInstance().logDebug("Build item");
162160
StructureRecord item = itemsToBuild.poll();
163161
placeStructure(item);
164-
} else {
165-
//BentoBox.getInstance().logDebug("Nothing to do");
166162
}
167163
}
168164

169165
private void placeStructure(StructureRecord item) {
170-
//BentoBox.getInstance().logDebug("Placing structure");
171166
// Set the semaphore - only paste one at a time
172167
pasting = true;
173168
// Place the structure - this cannot be done async
@@ -231,14 +226,13 @@ public void onChunkLoad(ChunkLoadEvent e) {
231226
if (!(addon.inWorld(chunk.getWorld()))) {
232227
return;
233228
}
234-
//BentoBox.getInstance().logDebug(e.getEventName());
235229
Pair<Integer, Integer> chunkCoords = new Pair<Integer, Integer>(chunk.getX(), chunk.getZ());
236230
if (pending.containsKey(chunkCoords)) {
237231
Iterator<StructureRecord> it = pending.get(chunkCoords).iterator();
238232
while (it.hasNext()) {
239233
StructureRecord item = it.next();
240234
if (item.location().getWorld().equals(e.getWorld())) {
241-
//BentoBox.getInstance().logDebug("Placing structure in itemsToBuild " + item);
235+
// Placing structure in itemsToBuild
242236
this.itemsToBuild.add(item);
243237
it.remove();
244238
}
@@ -247,8 +241,6 @@ public void onChunkLoad(ChunkLoadEvent e) {
247241
ToBePlacedStructures tbd = new ToBePlacedStructures();
248242
tbd.setReadyToBuild(pending);
249243
toPlace.saveObjectAsync(tbd);
250-
} else {
251-
//BentoBox.getInstance().logDebug("Nothing to build in this chunk");
252244
}
253245
}
254246

@@ -394,10 +386,9 @@ private void place(ConfigurationSection section, Location center, Environment en
394386
int y = Integer.parseInt(coords[1].strip());
395387
int z = Integer.parseInt(coords[2].strip()) + center.getBlockZ();
396388
Location location = new Location(world, x, y, z);
397-
//BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
389+
// Structure will be placed at location
398390
readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>())
399-
.add(new StructureRecord(name, "minecraft:" + name, location,
400-
rotation, mirror, noMobs));
391+
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
401392
this.itemsToBuild
402393
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
403394
} else {
@@ -412,8 +403,6 @@ private void place(ConfigurationSection section, Location center, Environment en
412403
return list1;
413404
}));
414405

415-
//BentoBox.getInstance().logDebug("mergedMap size = " + mergedMap.size());
416-
//BentoBox.getInstance().logDebug("readyToBuild size = " + readyToBuild.size());
417406
// Save the list
418407
tbd.setReadyToBuild(mergedMap);
419408
toPlace.saveObjectAsync(tbd);
@@ -508,16 +497,20 @@ private static void processStructureBlock(Block b) {
508497
}
509498

510499
private static void processJigsaw(Block b, StructureRotation structureRotation, boolean pasteMobs) {
511-
String data = nmsData(b);
512-
if (data.isEmpty()) {
513-
return;
514-
}
515-
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
516-
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
517-
BlockData bd = Bukkit.createBlockData(finalState);
518-
b.setBlockData(bd);
519-
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
520-
spawnMob(b, bjb);
500+
try {
501+
String data = nmsData(b);
502+
if (data.isEmpty()) {
503+
return;
504+
}
505+
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
506+
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
507+
BlockData bd = Bukkit.createBlockData(finalState);
508+
b.setBlockData(bd);
509+
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
510+
spawnMob(b, bjb);
511+
}
512+
} catch (Exception e) {
513+
e.printStackTrace();
521514
}
522515
}
523516

@@ -549,17 +542,12 @@ private static void spawnMob(Block b, BoxedJigsawBlock bjb) {
549542
} else if (bjb.getPool().contains("villagers")) {
550543
type = EntityType.VILLAGER;
551544
}
552-
// if (type == null) {
553-
// BentoBox.getInstance().logDebug(bjb.getPool());
554-
// }
555545
// Spawn it
556546
if (type != null) {
557547
Entity e = b.getWorld().spawnEntity(b.getRelative(BlockFace.UP).getLocation(), type);
558548
if (e != null) {
559549
e.setPersistent(true);
560550
}
561-
// BentoBox.getInstance().logDebug("Spawned a " + type + " at " +
562-
// b.getRelative(BlockFace.UP).getLocation());
563551
}
564552
}
565553

@@ -646,12 +634,10 @@ private static String nmsData(Block block) {
646634

647635
private ToBePlacedStructures loadToDos() {
648636
if (!toPlace.objectExists(TODO)) {
649-
//BentoBox.getInstance().logDebug("No TODO list");
650637
return new ToBePlacedStructures();
651638
}
652639
ToBePlacedStructures list = toPlace.loadObject(TODO);
653640
if (list == null) {
654-
//BentoBox.getInstance().logDebug("TODO list is null");
655641
return new ToBePlacedStructures();
656642
}
657643
if (!list.getReadyToBuild().isEmpty()) {

src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import net.minecraft.nbt.NBTTagCompound;
99
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
1010
import net.minecraft.world.level.block.entity.TileEntity;
11+
import world.bentobox.bentobox.BentoBox;
1112

12-
/**
13-
*
14-
*/
1513
public abstract class AbstractMetaData {
1614

1715
public abstract String nmsData(Block block);
@@ -30,7 +28,7 @@ protected String getData(TileEntity te, String method, String field) {
3028
Field fieldC = packet.getClass().getDeclaredField(field);
3129
fieldC.setAccessible(true);
3230
NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet);
33-
31+
3432
return nbtTag.toString(); // This will show what you want
3533
//} else {
3634
// throw new ClassNotFoundException(

src/main/java/world/bentobox/boxed/nms/v1_20_4_R0_1_SNAPSHOT/GetMetaData.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
package world.bentobox.boxed.nms.v1_21_3_R0_1_SNAPSHOT;
22

3-
public class GetMetaData extends world.bentobox.boxed.nms.v1_21_R0_1_SNAPSHOT.GetMetaData {
4-
// Identical to 1.21
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.boxed.nms.AbstractMetaData;
10+
11+
public class GetMetaData extends AbstractMetaData {
12+
13+
@Override
14+
public String nmsData(Block block) {
15+
Location w = block.getLocation();
16+
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
17+
// for 1.13+ (we have use WorldServer)
18+
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
19+
return getData(te, "getUpdatePacket", "tag");
20+
}
21+
522
}

src/test/java/world/bentobox/boxed/mocks/ServerMocks.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
public final class ServerMocks {
2626

27+
@SuppressWarnings({ "deprecation", "unchecked" })
2728
public static @NonNull Server newServer() {
2829
Server mock = mock(Server.class);
2930

@@ -66,7 +67,7 @@ public final class ServerMocks {
6667
doReturn(key).when(keyed).getKey();
6768
return keyed;
6869
});
69-
}).when(registry).get(notNull());
70+
}).when(registry).get((NamespacedKey) notNull());
7071
return registry;
7172
})).when(mock).getRegistry(notNull());
7273

0 commit comments

Comments
 (0)