Skip to content

Commit

Permalink
chore: 迁移用法
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Feb 7, 2025
1 parent 02b1acd commit 60373fd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 41 deletions.
7 changes: 4 additions & 3 deletions src/main/java/me/qscbm/slimefun4/utils/NBTUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import io.github.bakedlibs.dough.reflection.ReflectionGetterMethodFunction;
import io.github.bakedlibs.dough.reflection.ReflectionUtils;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class NBTUtils {
RESOLVABLE_PROFILE_GAME_PROFILE_GETTER = ReflectionUtils.getMethod(resolvableProfile, "f");
if (RESOLVABLE_PROFILE_GAME_PROFILE_GETTER != null) {
RESOLVABLE_PROFILE_GAME_PROFILE_GETTER.setAccessible(true);
RESOLVABLE_PROFILE_GAME_PROFILE_GETTER_FUNCTION = QsReflectionUtils.createGetterFunction(RESOLVABLE_PROFILE_GAME_PROFILE_GETTER);
RESOLVABLE_PROFILE_GAME_PROFILE_GETTER_FUNCTION = ReflectionUtils.createGetterFunction(RESOLVABLE_PROFILE_GAME_PROFILE_GETTER);
}
} catch (ClassNotFoundException e) {
resolvableProfile = null;
Expand All @@ -66,12 +67,12 @@ public class NBTUtils {
PROPERTY_NAME_GETTER = ReflectionUtils.getMethod(Property.class, "getName");
if (PROPERTY_NAME_GETTER != null) {
PROPERTY_NAME_GETTER.setAccessible(true);
PROPERTY_NAME_GETTER_FUNCTION = QsReflectionUtils.createGetterFunction(PROPERTY_NAME_GETTER);
PROPERTY_NAME_GETTER_FUNCTION = ReflectionUtils.createGetterFunction(PROPERTY_NAME_GETTER);
}
PROPERTY_VALUE_GETTER = ReflectionUtils.getMethod(Property.class, "getValue");
if (PROPERTY_VALUE_GETTER != null) {
PROPERTY_VALUE_GETTER.setAccessible(true);
PROPERTY_VALUE_GETTER_FUNCTION = QsReflectionUtils.createGetterFunction(PROPERTY_VALUE_GETTER);
PROPERTY_VALUE_GETTER_FUNCTION = ReflectionUtils.createGetterFunction(PROPERTY_VALUE_GETTER);
}
}

Expand Down
27 changes: 0 additions & 27 deletions src/main/java/me/qscbm/slimefun4/utils/QsReflectionUtils.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.qscbm.slimefun4.utils;

import io.github.bakedlibs.dough.reflection.ReflectionGetterMethodFunction;
import io.github.bakedlibs.dough.reflection.ReflectionUtils;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import me.qscbm.slimefun4.utils.compatibillty.HighVersionEventsConstructor;
Expand Down Expand Up @@ -49,23 +51,23 @@ public class VersionEventsUtils {
Class.forName("org.bukkit.inventory.InventoryView")
.getMethod("getTopInventory");
TOP_INVENTORY_GETTER.setAccessible(true);
TOP_INVENTORY_GETTER_FUNCTION = QsReflectionUtils.createGetterFunction(TOP_INVENTORY_GETTER);
TOP_INVENTORY_GETTER_FUNCTION = ReflectionUtils.createGetterFunction(TOP_INVENTORY_GETTER);
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
try {
CLICKED_INVENTORY_GETTER =
Class.forName("org.bukkit.event.inventory.InventoryClickEvent")
.getMethod("getClickedInventory");
CLICKED_INVENTORY_GETTER.setAccessible(true);
CLICKED_INVENTORY_GETTER_FUNCTION = QsReflectionUtils.createGetterFunction(CLICKED_INVENTORY_GETTER);
CLICKED_INVENTORY_GETTER_FUNCTION = ReflectionUtils.createGetterFunction(CLICKED_INVENTORY_GETTER);
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
try {
EXPLOSION_RESULT_GETTER =
Class.forName("org.bukkit.event.block.BlockExplodeEvent")
.getMethod("getExplosionResult");
EXPLOSION_RESULT_GETTER.setAccessible(true);
EXPLOSION_RESULT_GETTER_FUNCTION = QsReflectionUtils.createGetterFunction(EXPLOSION_RESULT_GETTER);
EXPLOSION_RESULT_GETTER_FUNCTION = ReflectionUtils.createGetterFunction(EXPLOSION_RESULT_GETTER);
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.qscbm.slimefun4.utils.compatibillty;

import io.github.bakedlibs.dough.reflection.ReflectionUtils;
import me.qscbm.slimefun4.utils.QsReflectionUtils;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.damage.DamageSource;
Expand Down Expand Up @@ -31,7 +30,7 @@ public HighVersionEventsConstructor() {
}
Constructor<BlockExplodeEvent> blockExplodeEventConstructor = ReflectionUtils.getConstructor(BlockExplodeEvent.class, Block.class, BlockState.class, List.class, float.class, explosionResultClass);
try {
blockExplodeEventConstructorHandle = QsReflectionUtils.LOOKUP.unreflectConstructor(blockExplodeEventConstructor);
blockExplodeEventConstructorHandle = ReflectionUtils.LOOKUP.unreflectConstructor(blockExplodeEventConstructor);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 60373fd

Please sign in to comment.