|
17 | 17 | import net.minecraft.util.Util; |
18 | 18 | import org.jetbrains.annotations.Nullable; |
19 | 19 |
|
20 | | -import java.lang.invoke.MethodHandle; |
21 | | -import java.lang.invoke.MethodHandles; |
22 | | -import java.lang.invoke.MethodType; |
23 | 20 | import java.net.URI; |
24 | | -import java.util.*; |
| 21 | +import java.util.ArrayList; |
| 22 | +import java.util.List; |
| 23 | +import java.util.Objects; |
25 | 24 | import java.util.function.BooleanSupplier; |
26 | 25 |
|
27 | 26 | public class ClientUtils { |
28 | 27 | public static final BooleanSupplier IS_CLIENT_OP = () -> Minecraft.getInstance().player != null && Minecraft.getInstance().player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER); |
29 | 28 | public static final List<Runnable> RUN_LATER = new ArrayList<>(); |
30 | | - private static final MethodType EMPTY_METHOD_TYPE = MethodType.methodType(void.class); |
31 | | - private static final HashMap<String, Optional<MethodHandle>> staticMethodCache = new HashMap<>(); |
32 | 29 |
|
33 | 30 | public static void execClientCommand(String command, boolean printChat) { |
34 | 31 | if (!command.isEmpty() && Minecraft.getInstance().player != null) { |
@@ -103,27 +100,6 @@ public static boolean handleClick(String scheme, String path) { |
103 | 100 | execClientCommand(path, false); |
104 | 101 | return true; |
105 | 102 | } |
106 | | - case "static_method" -> { |
107 | | - return staticMethodCache.computeIfAbsent(path, k -> { |
108 | | - var s = path.split(":", 2); |
109 | | - try { |
110 | | - Class<?> cls = Class.forName(s[0]); |
111 | | - return Optional.ofNullable(MethodHandles.publicLookup().findStatic(cls, s[1], EMPTY_METHOD_TYPE)); |
112 | | - } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | |
113 | | - ArrayIndexOutOfBoundsException ex) { |
114 | | - logHandleClickFailure(scheme, path, ex); |
115 | | - return Optional.empty(); |
116 | | - } |
117 | | - }).map(handle -> { |
118 | | - try { |
119 | | - handle.invoke(); |
120 | | - return true; |
121 | | - } catch (Throwable ex) { |
122 | | - logHandleClickFailure(scheme, path, ex); |
123 | | - return false; |
124 | | - } |
125 | | - }).orElse(false); |
126 | | - } |
127 | 103 | case "custom" -> { |
128 | 104 | return trySendCustomClickEvent(path); |
129 | 105 | } |
|
0 commit comments