From d27b81cb2a45d53ebe11f3591da64f81de02e351 Mon Sep 17 00:00:00 2001 From: Jonathan Boisclair Date: Wed, 25 May 2022 17:23:38 -0400 Subject: [PATCH 1/6] Bump IridiumCore to 1.6.6, switch to 3rd party m2 repo --- build.gradle.kts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 64cc516..6cddaae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,17 +14,20 @@ repositories { maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") maven("https://ci.ender.zone/plugin/repository/everything/") maven("https://jitpack.io") - maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/") maven("https://papermc.io/repo/repository/maven-public/") maven("https://repo.rosewooddev.io/repository/public/") maven("https://hub.jeff-media.com/nexus/repository/jeff-media-public/") + maven("https://moyskleytech.com/debian/m2/") + mavenLocal() mavenCentral() + //maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/") + } dependencies { // Dependencies that we want to shade in implementation("org.jetbrains:annotations:22.0.0") - implementation("com.iridium:IridiumCore:1.5.3") + implementation("com.iridium:IridiumCore:1.6.6") implementation("org.bstats:bstats-bukkit:3.0.0") implementation("com.j256.ormlite:ormlite-core:6.1") implementation("com.j256.ormlite:ormlite-jdbc:6.1") @@ -34,7 +37,7 @@ dependencies { compileOnly("org.projectlombok:lombok:1.18.22") compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT") compileOnly("net.prosavage:FactionsX:1.2") - compileOnly("com.massivecraft.massivesuper:MassiveSuper:2.14.0") + compileOnly("com.massivecraft.massivesuper:MassiveCore:2.14") compileOnly("com.massivecraft.massivesuper:Factions:2.14.0") compileOnly("com.massivecraft:Factions:1.6.9.5-U0.6.8") { exclude("com.darkblade12") From a49d6ce7e4774201ca8b530ce0df43b0316685bd Mon Sep 17 00:00:00 2001 From: Jonathan Boisclair Date: Sat, 28 May 2022 16:34:32 -0400 Subject: [PATCH 2/6] Proper serializer/deserializer for material (fool proof) --- .../chunkbusters/database/BlockData.java | 90 ++++++++++++++++++- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iridium/chunkbusters/database/BlockData.java b/src/main/java/com/iridium/chunkbusters/database/BlockData.java index 0c6c6c7..74959fc 100644 --- a/src/main/java/com/iridium/chunkbusters/database/BlockData.java +++ b/src/main/java/com/iridium/chunkbusters/database/BlockData.java @@ -8,8 +8,10 @@ import lombok.NoArgsConstructor; import org.bukkit.Bukkit; import org.bukkit.Chunk; +import org.bukkit.Material; import org.jetbrains.annotations.NotNull; +import java.io.StringReader; import java.util.Base64; @Getter @@ -45,7 +47,7 @@ public class BlockData { private String blocks; public ChunkLayer getBlocks() { - return IridiumChunkBusters.getInstance().getPersist().load(ChunkLayer.class, new String(Base64.getDecoder().decode(blocks))); + return alternateDeserializer(blocks); } public Chunk getChunk() { @@ -58,6 +60,88 @@ public BlockData(@NotNull ChunkBuster chunkBuster, @NotNull String world, int x, this.x = x; this.y = y; this.z = z; - this.blocks = new String(Base64.getEncoder().encode(IridiumChunkBusters.getInstance().getPersist().toString(blocks).getBytes())); + this.blocks = new String(Base64.getEncoder().encode(alternateSerialize(blocks).getBytes())); } -} + private ChunkLayer alternateDeserializer(String base64) + { + String ymlString = new String(Base64.getDecoder().decode(base64)); + //System.out.println(ymlString); + ChunkLayer cl = new ChunkLayer(); + //ChunkLayer cl = IridiumChunkBusters.getInstance().getPersist().load(ChunkLayer.class, ); + String[] lines = ymlString.split("\n"); + boolean isReadingBlocks = false,isReadingData=false; + int index1=0,index2=0; + + for (String line : lines) { + if(line.contains("blocks:")) + { + isReadingBlocks=true; + index1=-1; + index2=0; + continue; + } + if(line.contains("data:")) + { + isReadingBlocks=false; + isReadingData=true; + index1=0; + continue; + } + if(isReadingBlocks) + { + if(line.contains("- - ")) + { + index1++; + index2=0; + } + //System.out.println("Line {"+line+"} Reading, i1="+index1+",i2="+index2); + String substringed = line.substring(4); + Material matched = Material.getMaterial(substringed); + //System.out.println("Line {"+substringed+"} matched as "+matched); + + cl.blocks[index1][index2++]= matched; + } + if(isReadingData) + { + if(line.startsWith(" ")) + cl.data[index1++] = Base64.getDecoder().decode(line.substring(2)); + } + } + + return cl; + } + private String alternateSerialize(ChunkLayer cl) + { + //return IridiumChunkBusters.getInstance().getPersist().toString(cl); + StringBuilder sb = new StringBuilder("---\n"); + sb.append("blocks:\n"); + + for(Material[] row:cl.blocks) + { + boolean first=true; + + for(Material mat:row) + { + sb.append(first?"- ":" "); + sb.append("- "); + if(mat!=null) + sb.append(mat.name()); + else + sb.append("null"); + sb.append("\n"); + first=false; + } + } + + sb.append("data:\n"); + for(byte[] row:cl.data) + { + sb.append("- !!binary |-\n"); + sb.append(" "); + sb.append(new String(Base64.getEncoder().encode(row))); + sb.append("\n"); + } + + return sb.toString(); + } +} \ No newline at end of file From cfd149614163b74e7c82e832a2d14f1448c72426 Mon Sep 17 00:00:00 2001 From: Jonathan Boisclair Date: Sat, 28 May 2022 16:36:03 -0400 Subject: [PATCH 3/6] Partial fix to block appearing (serialize all now) --- .../iridium/chunkbusters/database/ChunkBuster.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java b/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java index 8971f8a..86d7305 100644 --- a/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java +++ b/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java @@ -11,6 +11,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.bukkit.*; +import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -114,11 +115,12 @@ private void deleteChunks(final List chunks, int minHeight) { for (int x = cx; x < cx + 16; x++) { for (int z = cz; z < cz + 16; z++) { Location location = new Location(world, x, y, z); - BlockState blockState = location.getBlock().getState(); + Block block = location.getBlock(); + BlockState blockState = block.getState(); if (IridiumChunkBusters.getInstance().getConfiguration().blacklist.contains(XMaterial.matchXMaterial(blockState.getType())) || !IridiumChunkBusters.getInstance().getSupport().canDelete(player, location) || blockState.getType().equals(Material.AIR) || chunkBusters.contains(location)) { continue; } - chunkLayer.blocks[x - cx][z - cz] = blockState.getType(); + chunkLayer.blocks[x - cx][z - cz] = block.getType(); chunkLayer.data[x - cx][z - cz] = blockState.getRawData(); IridiumChunkBusters.getInstance().getNms().deleteBlockFast(location); } @@ -149,10 +151,12 @@ public void undo() { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { if (chunkLayer.blocks[x][z] == null) continue; - BlockState blockState = chunk.getBlock(x, y, z).getState(); - if (IridiumChunkBusters.getInstance().getConfiguration().onlyRestoreWhenBlockIsAir && !blockState.getType().equals(Material.AIR)) + Block block=chunk.getBlock(x, y, z); + + if (IridiumChunkBusters.getInstance().getConfiguration().onlyRestoreWhenBlockIsAir && !block.getType().equals(Material.AIR)) continue; - blockState.setType(chunkLayer.blocks[x][z]); + BlockState blockState = block.getState(); + block.setType(chunkLayer.blocks[x][z]); blockState.setRawData(chunkLayer.data[x][z]); blockState.update(true, false); } From 4e88e3d85fb69925e8ef0695d1983b6a171c9cd6 Mon Sep 17 00:00:00 2001 From: Jonathan Boisclair Date: Sat, 28 May 2022 18:47:36 -0400 Subject: [PATCH 4/6] Fix unsupported block types --- .../com/iridium/chunkbusters/database/ChunkBuster.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java b/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java index 86d7305..5b4b7f1 100644 --- a/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java +++ b/src/main/java/com/iridium/chunkbusters/database/ChunkBuster.java @@ -155,9 +155,12 @@ public void undo() { if (IridiumChunkBusters.getInstance().getConfiguration().onlyRestoreWhenBlockIsAir && !block.getType().equals(Material.AIR)) continue; + + block.setType(chunkLayer.blocks[x][z],false); BlockState blockState = block.getState(); - block.setType(chunkLayer.blocks[x][z]); - blockState.setRawData(chunkLayer.data[x][z]); + blockState.setType(chunkLayer.blocks[x][z]); + blockState.getData().setData(chunkLayer.data[x][z]); + //blockState.setRawData(chunkLayer.data[x][z]); blockState.update(true, false); } } From f306b8061398fea752376c288151cde119aef67e Mon Sep 17 00:00:00 2001 From: Jonathan Boisclair Date: Wed, 8 Jun 2022 08:40:21 -0400 Subject: [PATCH 5/6] Update chunkbuster version and Core --- .gitignore | 3 +++ build.gradle.kts | 4 ++-- src/main/resources/plugin.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e362b83..3f94e87 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ .idea/ .gradle/ build/ +*.class +.vscode +bin \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 6cddaae..313aa96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "com.iridium" -version = "1.0.7" +version = "1.0.8" description = "IridiumChunkBusters" repositories { @@ -27,7 +27,7 @@ repositories { dependencies { // Dependencies that we want to shade in implementation("org.jetbrains:annotations:22.0.0") - implementation("com.iridium:IridiumCore:1.6.6") + implementation("com.iridium:IridiumCore:1.6.7") implementation("org.bstats:bstats-bukkit:3.0.0") implementation("com.j256.ormlite:ormlite-core:6.1") implementation("com.j256.ormlite:ormlite-jdbc:6.1") diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0b1e816..4944990 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: IridiumChunkBusters -version: 1.0.3 +version: 1.0.8 description: A plugin for removing chunks main: com.iridium.chunkbusters.IridiumChunkBusters api-version: '1.13' From 111a87de13ceab04152f58337e29a34c9e4d4ca8 Mon Sep 17 00:00:00 2001 From: Jonathan Boisclair Date: Tue, 28 Jun 2022 14:55:45 -0400 Subject: [PATCH 6/6] 1.19 support, forgot to readd the maven --- build.gradle.kts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 313aa96..b78cd13 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,8 +20,7 @@ repositories { maven("https://moyskleytech.com/debian/m2/") mavenLocal() mavenCentral() - //maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/") - + maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/") } dependencies {