Skip to content

Commit

Permalink
Merge pull request #56 from demkom58/1.21-update
Browse files Browse the repository at this point in the history
1.21 update fixes
  • Loading branch information
demkom58 authored Jul 9, 2024
2 parents 5c39465 + 751936f commit 593b1b0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public UpdateChecker(@NotNull final JavaPlugin plugin,

public void checkIfOutdated(@NotNull final Consumer<Version> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
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.V21R1.V21R1;
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;
Expand Down Expand Up @@ -61,7 +62,8 @@ 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),
V21R1(V21R1.class, "1.21", V13ResourceClient::new, V21R1::new),
DEOBFUSCATED_POST_V_21(DeobfuscatedVersionV21.class, "1.21", V13ResourceClient::new, DeobfuscatedVersionV21::new),
;

private static final Map<Class<? extends Version>, SupportedVersion> CLASS_VERSION_MAP = new HashMap<Class<? extends Version>, SupportedVersion>() {{
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/demkom58/divinedrop/version/V21R1/V21R1.java
Original file line number Diff line number Diff line change
@@ -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)
)
);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 593b1b0

Please sign in to comment.