From 9ad17a61ffad266195210c85a38666d7b63d99a5 Mon Sep 17 00:00:00 2001 From: Max Demydenko Date: Tue, 9 Jul 2024 19:26:11 +0300 Subject: [PATCH 1/4] chore: rename constant and class of version to mention deobf --- .../com/demkom58/divinedrop/version/SupportedVersion.java | 4 ++-- .../{V21/V21.java => deobf/DeobfuscatedVersionV21.java} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/com/demkom58/divinedrop/version/{V21/V21.java => deobf/DeobfuscatedVersionV21.java} (84%) diff --git a/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java b/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java index fe547a8..81f9e2d 100644 --- a/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java +++ b/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java @@ -21,7 +21,7 @@ import com.demkom58.divinedrop.version.V20R1.V20R1; import com.demkom58.divinedrop.version.V20R2.V20R2; import com.demkom58.divinedrop.version.V20R3.V20R3; -import com.demkom58.divinedrop.version.V21.V21; +import com.demkom58.divinedrop.version.deobf.DeobfuscatedVersionV21; import com.demkom58.divinedrop.version.V8R3.V8R3; import com.demkom58.divinedrop.version.V8R3.V8ResourceClient; import com.demkom58.divinedrop.version.V9R1.V9R1; @@ -61,7 +61,7 @@ public enum SupportedVersion { V20R1(V20R1.class, "1.20", V13ResourceClient::new, V20R1::new), V20R2(V20R2.class, "1.20.2", V13ResourceClient::new, V20R2::new), V20R3(V20R3.class, "1.20.4", V13ResourceClient::new, V20R3::new), - V21(V21.class, "1.21", V13ResourceClient::new, V21::new), + DEOBFUSCATED_POST_V_21(DeobfuscatedVersionV21.class, "1.21", V13ResourceClient::new, DeobfuscatedVersionV21::new), ; private static final Map, SupportedVersion> CLASS_VERSION_MAP = new HashMap, SupportedVersion>() {{ diff --git a/src/main/java/com/demkom58/divinedrop/version/V21/V21.java b/src/main/java/com/demkom58/divinedrop/version/deobf/DeobfuscatedVersionV21.java similarity index 84% rename from src/main/java/com/demkom58/divinedrop/version/V21/V21.java rename to src/main/java/com/demkom58/divinedrop/version/deobf/DeobfuscatedVersionV21.java index 60955ae..57c2d39 100644 --- a/src/main/java/com/demkom58/divinedrop/version/V21/V21.java +++ b/src/main/java/com/demkom58/divinedrop/version/deobf/DeobfuscatedVersionV21.java @@ -1,4 +1,4 @@ -package com.demkom58.divinedrop.version.V21; +package com.demkom58.divinedrop.version.deobf; import com.demkom58.divinedrop.version.V13R1.V13NmsHandleNameVersion; import org.bukkit.inventory.ItemStack; @@ -7,9 +7,9 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; -public class V21 extends V13NmsHandleNameVersion { - public V21(@NotNull final ResourceClient client) throws Exception { - super(client, null, +public class DeobfuscatedVersionV21 extends V13NmsHandleNameVersion { + public DeobfuscatedVersionV21(@NotNull final ResourceClient client) throws Exception { + super(client, null, MethodHandles.lookup() .findStatic( Class.forName("org.bukkit.craftbukkit.inventory.CraftItemStack"), From 927a690b292c2edc925b865b33d7e757620d324b Mon Sep 17 00:00:00 2001 From: Max Demydenko Date: Tue, 9 Jul 2024 19:32:24 +0300 Subject: [PATCH 2/4] fix: update checker outdated condition --- src/main/java/com/demkom58/divinedrop/util/UpdateChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/demkom58/divinedrop/util/UpdateChecker.java b/src/main/java/com/demkom58/divinedrop/util/UpdateChecker.java index 3d4efa5..6589eed 100644 --- a/src/main/java/com/demkom58/divinedrop/util/UpdateChecker.java +++ b/src/main/java/com/demkom58/divinedrop/util/UpdateChecker.java @@ -58,7 +58,7 @@ public UpdateChecker(@NotNull final JavaPlugin plugin, public void checkIfOutdated(@NotNull final Consumer handler, boolean sync) { fetchLatestSupportedVersion(latest -> { - if (latest == null || currentVersion.isNewer(latest.version_number)) return; + if (latest == null || !latest.version_number.isNewer(currentVersion)) return; handler.accept(latest); }, sync); From e531395f7cc1163c27ceee326932bf8e26405bfe Mon Sep 17 00:00:00 2001 From: Max Demydenko Date: Tue, 9 Jul 2024 19:32:46 +0300 Subject: [PATCH 3/4] chore: bump version to 2.16 --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5345acc..0a014df 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: DivineDrop main: com.demkom58.divinedrop.DivineDrop description: Awesome removal of items from the ground website: https://www.spigotmc.org/members/98068/ -version: 2.15 +version: 2.16 authors: - demkom58 - GdemkomG From 751936f18f017b34ac3bc234c470ecd229887a16 Mon Sep 17 00:00:00 2001 From: Max Demydenko Date: Wed, 10 Jul 2024 02:31:02 +0300 Subject: [PATCH 4/4] fix: add obfuscated version implementation to make cores that do not remapping --- .../divinedrop/version/SupportedVersion.java | 2 ++ .../divinedrop/version/V21R1/V21R1.java | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/main/java/com/demkom58/divinedrop/version/V21R1/V21R1.java diff --git a/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java b/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java index 81f9e2d..b806cfb 100644 --- a/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java +++ b/src/main/java/com/demkom58/divinedrop/version/SupportedVersion.java @@ -21,6 +21,7 @@ import com.demkom58.divinedrop.version.V20R1.V20R1; import com.demkom58.divinedrop.version.V20R2.V20R2; import com.demkom58.divinedrop.version.V20R3.V20R3; +import com.demkom58.divinedrop.version.V21R1.V21R1; import com.demkom58.divinedrop.version.deobf.DeobfuscatedVersionV21; import com.demkom58.divinedrop.version.V8R3.V8R3; import com.demkom58.divinedrop.version.V8R3.V8ResourceClient; @@ -61,6 +62,7 @@ public enum SupportedVersion { V20R1(V20R1.class, "1.20", V13ResourceClient::new, V20R1::new), V20R2(V20R2.class, "1.20.2", V13ResourceClient::new, V20R2::new), V20R3(V20R3.class, "1.20.4", V13ResourceClient::new, V20R3::new), + V21R1(V21R1.class, "1.21", V13ResourceClient::new, V21R1::new), DEOBFUSCATED_POST_V_21(DeobfuscatedVersionV21.class, "1.21", V13ResourceClient::new, DeobfuscatedVersionV21::new), ; diff --git a/src/main/java/com/demkom58/divinedrop/version/V21R1/V21R1.java b/src/main/java/com/demkom58/divinedrop/version/V21R1/V21R1.java new file mode 100644 index 0000000..647a811 --- /dev/null +++ b/src/main/java/com/demkom58/divinedrop/version/V21R1/V21R1.java @@ -0,0 +1,33 @@ +package com.demkom58.divinedrop.version.V21R1; + +import com.demkom58.divinedrop.version.V13R1.V13NmsHandleNameVersion; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +public class V21R1 extends V13NmsHandleNameVersion { + public V21R1(@NotNull final ResourceClient client) throws Exception { + super(client, "v1_21_R1", + MethodHandles.lookup() + .findStatic( + Class.forName("org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack"), + "asNMSCopy", + MethodType.methodType(Class.forName("net.minecraft.world.item.ItemStack"), ItemStack.class) + ), + MethodHandles.lookup() + .findVirtual( + Class.forName("net.minecraft.world.item.ItemStack"), + "g", + MethodType.methodType(Class.forName("net.minecraft.world.item.Item")) + ), + MethodHandles.lookup() + .findVirtual( + Class.forName("net.minecraft.world.item.Item"), + "a", + MethodType.methodType(String.class) + ) + ); + } +}