Skip to content

Commit c493619

Browse files
authored
Merge pull request #2700 from BentoBoxWorld/develop
Release 3.6.0
2 parents 6a3b5bb + 03cbe16 commit c493619

File tree

5 files changed

+111
-4
lines changed

5 files changed

+111
-4
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<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.6-R0.1-SNAPSHOT</paper.version>
66+
<paper.version>1.21.7-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.5.0</build.version>
77+
<build.version>3.6.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/managers/IslandsManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,10 @@ private CompletableFuture<Boolean> homeTeleportAsync(@NonNull World world, @NonN
10791079
// Try to fix this teleport location and teleport the player if possible
10801080
new SafeSpotTeleport.Builder(plugin).entity(player).island(island).homeName(name)
10811081
.thenRun(() -> teleported(world, user, name, newIsland, island))
1082-
.ifFail(() -> goingHome.remove(user.getUniqueId())).buildFuture().thenAccept(result::complete);
1082+
.ifFail(() -> {
1083+
plugin.logError(user.getName() + " could not be teleported to home because a safe spot could not be found on island " + island.getCenter());
1084+
goingHome.remove(user.getUniqueId());
1085+
}).buildFuture().thenAccept(result::complete);
10831086
return;
10841087
}
10851088
Util.teleportAsync(Objects.requireNonNull(player), home).thenAccept(b -> {
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_7_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_7_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
@@ -272,7 +272,11 @@ public enum ServerVersion {
272272
/**
273273
* @since 3.5.0
274274
*/
275-
V1_21_6(Compatibility.COMPATIBLE),;
275+
V1_21_6(Compatibility.COMPATIBLE),
276+
/**
277+
* @since 3.6.0
278+
*/
279+
V1_21_7(Compatibility.COMPATIBLE),;
276280

277281
private final Compatibility compatibility;
278282

0 commit comments

Comments
 (0)