Skip to content

Commit f7747a3

Browse files
authored
Merge pull request #2713 from BentoBoxWorld/develop
Release 3.7.1
2 parents d6f7b95 + 8693eec commit f7747a3

File tree

11 files changed

+302
-122
lines changed

11 files changed

+302
-122
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<!-- Do not change unless you want different name for local builds. -->
7676
<build.number>-LOCAL</build.number>
7777
<!-- This allows to change between versions. -->
78-
<build.version>3.7.0</build.version>
78+
<build.version>3.7.1</build.version>
7979
<sonar.organization>bentobox-world</sonar.organization>
8080
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
8181
<server.jars>${project.basedir}/lib</server.jars>

src/main/java/world/bentobox/bentobox/api/commands/admin/purge/AdminPurgeRegionsCommand.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ private void findIslands(World world, int days) {
336336
// Display to the user
337337
uniqueIslands.forEach(this::displayIsland);
338338

339+
// Display empty regions
340+
deleteableRegions.entrySet().stream()
341+
.filter(e -> e.getValue().isEmpty())
342+
.forEach(e -> displayEmptyRegion(e.getKey()));
343+
339344
if (deleteableRegions.isEmpty()) {
340345
Bukkit.getScheduler().runTask(getPlugin(), () -> user.sendMessage("commands.admin.purge.none-found"));
341346
} else {
@@ -367,6 +372,10 @@ private void displayIsland(Island island) {
367372
+ " will be deleted");
368373
}
369374

375+
private void displayEmptyRegion(Pair<Integer, Integer> region) {
376+
getPlugin().log("Empty region at r." + region.x + "." + region.z + " in world " + getWorld().getName() + " will be deleted (no islands)");
377+
}
378+
370379
/**
371380
* Formats a millisecond timestamp into a human-readable string
372381
* using the system's local time zone.
@@ -551,9 +560,8 @@ private Map<Pair<Integer, Integer>, Set<String>> mapIslandsToRegions(
551560
}
552561
}
553562

554-
if (!ids.isEmpty()) {
555-
regionToIslands.put(region, ids);
556-
}
563+
// Always add the region, even if ids is empty
564+
regionToIslands.put(region, ids);
557565
}
558566

559567
return regionToIslands;

src/main/java/world/bentobox/bentobox/managers/AddonsManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ public void loadAddons() {
147147
return;
148148
}
149149
Arrays.stream(Objects.requireNonNull(f.listFiles()))
150-
.filter(x -> !x.isDirectory() && x.getName().endsWith(".jar")).forEach(this::loadAddon);
150+
.filter(x -> !x.isDirectory() && x.getName().endsWith(".jar")
151+
&& !x.getName().startsWith("._")
152+
).forEach(this::loadAddon);
151153
plugin.log("Loaded " + getLoadedAddons().size() + " addons.");
152154

153155
if (!getLoadedAddons().isEmpty()) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package world.bentobox.bentobox.nms;
2+
3+
import java.lang.reflect.Field;
4+
import java.lang.reflect.Method;
5+
6+
import org.bukkit.block.Block;
7+
8+
import net.minecraft.nbt.NBTTagCompound;
9+
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
10+
import net.minecraft.world.level.block.entity.TileEntity;
11+
import world.bentobox.bentobox.BentoBox;
12+
13+
public abstract class AbstractMetaData {
14+
15+
public abstract String nmsData(Block block);
16+
17+
protected String getData(TileEntity te, String method, String field) {
18+
try {
19+
// Check if the method 'j' exists
20+
Method updatePacketMethod = te.getClass().getDeclaredMethod(method);
21+
if (updatePacketMethod != null) {
22+
// Invoke the method to get the PacketPlayOutTileEntityData object
23+
updatePacketMethod.setAccessible(true);
24+
Object object = updatePacketMethod.invoke(te);
25+
PacketPlayOutTileEntityData packet = (PacketPlayOutTileEntityData) object;
26+
//if (object instanceof PacketPlayOutTileEntityData packet) {
27+
// Access the private field for the NBTTagCompound getter in PacketPlayOutTileEntityData
28+
Field fieldC = packet.getClass().getDeclaredField(field);
29+
fieldC.setAccessible(true);
30+
NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet);
31+
32+
return nbtTag.toString(); // This will show what you want
33+
//} else {
34+
// throw new ClassNotFoundException(
35+
// object.getClass().getCanonicalName() + " is not a PacketPlayOutTileEntityData");
36+
//}
37+
}
38+
} catch (Exception e) {
39+
System.out.println("The method '" + method + "' does not exist in the TileEntity class.");
40+
e.printStackTrace();
41+
}
42+
return "";
43+
44+
}
45+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package world.bentobox.bentobox.nms.fallback;
2+
3+
import org.bukkit.block.Block;
4+
5+
import world.bentobox.bentobox.nms.AbstractMetaData;
6+
7+
/**
8+
* Fallback
9+
*/
10+
public class GetMetaData extends AbstractMetaData {
11+
12+
@Override
13+
public String nmsData(Block block) {
14+
return ""; // We cannot read it if we have no NMS
15+
}
16+
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package world.bentobox.bentobox.nms.v1_21_4_R0_1_SNAPSHOT;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R3.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.bentobox.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+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package world.bentobox.bentobox.nms.v1_21_5_R0_1_SNAPSHOT;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R4.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.bentobox.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+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package world.bentobox.bentobox.nms.v1_21_6_R0_1_SNAPSHOT;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.bentobox.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+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package world.bentobox.bentobox.nms.v1_21_7_R0_1_SNAPSHOT;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.bentobox.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+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package world.bentobox.bentobox.nms.v1_21_8_R0_1_SNAPSHOT;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.bentobox.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+
22+
}

0 commit comments

Comments
 (0)