From fcb5ae36fd0bd2d82279eec7a967a911ab237c08 Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Mon, 7 Jul 2025 00:38:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor(bukkit):=20=E5=90=88=E5=B9=B6=20Player?= =?UTF-8?q?WillDestroyInterceptor=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/injector/BlockGenerator.java | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/injector/BlockGenerator.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/injector/BlockGenerator.java index 85fdb037f..e92214714 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/injector/BlockGenerator.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/plugin/injector/BlockGenerator.java @@ -180,7 +180,7 @@ public final class BlockGenerator { .intercept(MethodDelegation.to(IsSignalSourceInterceptor.INSTANCE)) // playerWillDestroy .method(ElementMatchers.is(CoreReflections.method$Block$playerWillDestroy)) - .intercept(MethodDelegation.to(VersionHelper.isOrAbove1_20_3() ? PlayerWillDestroyInterceptor1_20_3.INSTANCE : PlayerWillDestroyInterceptor1_20.INSTANCE)); + .intercept(MethodDelegation.to(PlayerWillDestroyInterceptor.INSTANCE)); if (CoreReflections.method$BlockBehaviour$affectNeighborsAfterRemoval != null) { builder.method(ElementMatchers.is(CoreReflections.method$BlockBehaviour$affectNeighborsAfterRemoval)) .intercept(MethodDelegation.to(AffectNeighborsAfterRemovalInterceptor.INSTANCE)); @@ -629,8 +629,8 @@ public final class BlockGenerator { } } - public static class PlayerWillDestroyInterceptor1_20_3 { - public static final PlayerWillDestroyInterceptor1_20_3 INSTANCE = new PlayerWillDestroyInterceptor1_20_3(); + public static class PlayerWillDestroyInterceptor { + public static final PlayerWillDestroyInterceptor INSTANCE = new PlayerWillDestroyInterceptor(); @RuntimeType public Object intercept(@This Object thisObj, @AllArguments Object[] args, @SuperCall Callable superMethod) throws Exception { @@ -643,18 +643,4 @@ public final class BlockGenerator { } } } - - public static class PlayerWillDestroyInterceptor1_20 { - public static final PlayerWillDestroyInterceptor1_20 INSTANCE = new PlayerWillDestroyInterceptor1_20(); - - @RuntimeType - public void intercept(@This Object thisObj, @AllArguments Object[] args, @SuperCall Callable superMethod) { - ObjectHolder holder = ((DelegatingBlock) thisObj).behaviorDelegate(); - try { - holder.value().playerWillDestroy(thisObj, args, superMethod); - } catch (Exception e) { - CraftEngine.instance().logger().severe("Failed to run playerWillDestroy", e); - } - } - } }