Skip to content

Commit 6a3b5bb

Browse files
authored
Merge pull request #2697 from BentoBoxWorld/develop
Release 3.5.0
2 parents 6b24624 + 222428d commit 6a3b5bb

File tree

5 files changed

+113
-5
lines changed

5 files changed

+113
-5
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
<postgresql.version>42.2.18</postgresql.version>
6161
<hikaricp.version>5.0.1</hikaricp.version>
6262
<!-- More visible way to change dependency versions -->
63-
<spigot.version>1.21.5-R0.1-SNAPSHOT</spigot.version>
63+
<spigot.version>1.21.6-R0.1-SNAPSHOT</spigot.version>
6464
<!-- Might differ from the last Spigot release for short periods
6565
of time -->
66-
<paper.version>1.21.5-R0.1-SNAPSHOT</paper.version>
66+
<paper.version>1.21.6-R0.1-SNAPSHOT</paper.version>
6767
<bstats.version>3.0.0</bstats.version>
6868
<vault.version>1.7.1</vault.version>
6969
<placeholderapi.version>2.10.9</placeholderapi.version>
@@ -74,7 +74,7 @@
7474
<!-- Do not change unless you want different name for local builds. -->
7575
<build.number>-LOCAL</build.number>
7676
<!-- This allows to change between versions. -->
77-
<build.version>3.4.1</build.version>
77+
<build.version>3.5.0</build.version>
7878
<sonar.organization>bentobox-world</sonar.organization>
7979
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
8080
<server.jars>${project.basedir}/lib</server.jars>

src/main/java/world/bentobox/bentobox/api/user/User.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,11 @@ private String replaceVars(String reference, String[] variables) {
562562
if (player != null) {
563563
reference = plugin.getPlaceholdersManager().replacePlaceholders(player, reference);
564564
}
565-
565+
// Validate variables array length
566+
if (variables.length % 2 != 0) {
567+
throw new IllegalArgumentException(
568+
"Variable replacements must be in pairs (key, value), but got odd number: " + variables.length);
569+
}
566570
// Then replace variables
567571
if (variables.length > 1) {
568572
for (int i = 0; i < variables.length; i += 2) {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package world.bentobox.bentobox.nms.v1_21_6_R0_1_SNAPSHOT;
2+
3+
import java.util.concurrent.CompletableFuture;
4+
5+
import org.bukkit.Location;
6+
import org.bukkit.block.Block;
7+
import org.bukkit.block.data.BlockData;
8+
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
9+
import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData;
10+
11+
import net.minecraft.core.BlockPosition;
12+
import net.minecraft.world.level.block.state.IBlockData;
13+
import net.minecraft.world.level.chunk.Chunk;
14+
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
15+
import world.bentobox.bentobox.database.objects.Island;
16+
import world.bentobox.bentobox.nms.PasteHandler;
17+
import world.bentobox.bentobox.util.DefaultPasteUtil;
18+
import world.bentobox.bentobox.util.Util;
19+
20+
public class PasteHandlerImpl implements PasteHandler {
21+
22+
protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState();
23+
24+
/**
25+
* Set the block to the location
26+
*
27+
* @param island - island
28+
* @param location - location
29+
* @param bpBlock - blueprint block
30+
*/
31+
@Override
32+
public CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
33+
return Util.getChunkAtAsync(location).thenRun(() -> {
34+
Block block = setBlock(location, DefaultPasteUtil.createBlockData(bpBlock));
35+
DefaultPasteUtil.setBlockState(island, block, bpBlock);
36+
// Set biome
37+
if (bpBlock.getBiome() != null) {
38+
block.setBiome(bpBlock.getBiome());
39+
}
40+
});
41+
}
42+
43+
@Override
44+
public Block setBlock(Location location, BlockData bd) {
45+
Block block = location.getBlock();
46+
// Set the block data - default is AIR
47+
CraftBlockData craft = (CraftBlockData) bd;
48+
net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
49+
Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4);
50+
BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
51+
// Setting the block to air before setting to another state prevents some console errors
52+
// If the block is a naturally generated tile entity that needs filling, e.g., a chest, then this kind of pasting can cause console errors due to race condition
53+
// so the try's are there to try and catch the errors.
54+
try {
55+
nmsChunk.a(bp, AIR, 0);
56+
} catch (Exception e) {
57+
e.printStackTrace();
58+
// Ignore
59+
}
60+
try {
61+
nmsChunk.a(bp, craft.getState(), 0);
62+
} catch (Exception e) {
63+
e.printStackTrace();
64+
// Ignore
65+
}
66+
try {
67+
block.setBlockData(bd, false);
68+
} catch (Exception e) {
69+
e.printStackTrace();
70+
// Ignore
71+
}
72+
return block;
73+
}
74+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package world.bentobox.bentobox.nms.v1_21_6_R0_1_SNAPSHOT;
2+
3+
import org.bukkit.block.data.BlockData;
4+
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
5+
import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.World;
9+
import net.minecraft.world.level.chunk.Chunk;
10+
import world.bentobox.bentobox.nms.CopyWorldRegenerator;
11+
12+
public class WorldRegeneratorImpl extends CopyWorldRegenerator {
13+
14+
@Override
15+
public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData,
16+
boolean applyPhysics) {
17+
CraftBlockData craft = (CraftBlockData) blockData;
18+
World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle();
19+
Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ());
20+
BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z);
21+
// Setting the block to air before setting to another state prevents some console errors
22+
nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics ? 1 : 0);
23+
nmsChunk.a(bp, craft.getState(), applyPhysics ? 1 : 0);
24+
}
25+
26+
}

src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ public enum ServerVersion {
268268
/**
269269
* @since 3.3.3
270270
*/
271-
V1_21_5(Compatibility.COMPATIBLE),;
271+
V1_21_5(Compatibility.COMPATIBLE),
272+
/**
273+
* @since 3.5.0
274+
*/
275+
V1_21_6(Compatibility.COMPATIBLE),;
272276

273277
private final Compatibility compatibility;
274278

0 commit comments

Comments
 (0)