From eef9b51878a9d1b3c3a237c86e8828349fd1a511 Mon Sep 17 00:00:00 2001 From: cnlimiter Date: Wed, 21 Feb 2024 11:52:55 +0800 Subject: [PATCH] =?UTF-8?q?style(fabric):=20mixin=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fabric/common.gradle | 8 +-- fabric/gradle.properties | 2 +- .../mods/mcbot/init/callbacks/IEvents.java | 52 +++++++++---------- .../mods/mcbot/init/event/IBotEvent.java | 3 +- .../mods/mcbot/init/event/IPlayerEvent.java | 4 +- fabric/wrapper/build.gradle | 4 +- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/fabric/common.gradle b/fabric/common.gradle index faf9d081..75d91cd8 100644 --- a/fabric/common.gradle +++ b/fabric/common.gradle @@ -10,9 +10,9 @@ preprocess { repositories { - mavenCentral() maven { url = "https://maven.nova-committee.cn/releases" } maven { url = "https://api.modrinth.com/maven" } + mavenCentral() } dependencies { @@ -21,10 +21,10 @@ dependencies { modImplementation ("net.fabricmc:fabric-loader:${project.loader_version}") modImplementation ("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") - api include ("cn.evole.bot:OneBot-Client:${project.onebot_client_version}") - api include ("cn.evole.config:AtomConfig-Toml:${project.toml_version}") + implementation include ("cn.evole.bot:OneBot-Client:${project.onebot_client_version}"){transitive = false} + implementation include ("cn.evole.config:AtomConfig-Toml:${project.toml_version}"){transitive = false} if (mcVersion == 11605) include ("org.slf4j:slf4j-api:2.0.7") - if (mcVersion == 12101) modCompileOnly ("maven.modrinth:vanish:1.5.2") + if (mcVersion == 12001) modCompileOnly ("maven.modrinth:vanish:1.5.2-1.20.1") compileOnly ("org.projectlombok:lombok:1.18.24") annotationProcessor ("org.projectlombok:lombok:1.18.24") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index e2ee0ec4..79897a48 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -11,5 +11,5 @@ archives_base_name=McBot-fabric minecraft_version=1.20.1 loader_version=0.14.21 fabric_version=0.83.1+1.20.1 -onebot_client_version=0.3.8 +onebot_client_version=0.3.9 toml_version=0.1.5 diff --git a/fabric/src/main/java/cn/evole/mods/mcbot/init/callbacks/IEvents.java b/fabric/src/main/java/cn/evole/mods/mcbot/init/callbacks/IEvents.java index 441ff648..63ae479e 100644 --- a/fabric/src/main/java/cn/evole/mods/mcbot/init/callbacks/IEvents.java +++ b/fabric/src/main/java/cn/evole/mods/mcbot/init/callbacks/IEvents.java @@ -17,26 +17,26 @@ * Version: 1.0 */ public final class IEvents { - public static final Event PLAYER_TICK = EventFactory.createArrayBacked(Player_Tick.class, callbacks -> (world, player) -> { - for (Player_Tick callback : callbacks) { + public static final Event PLAYER_TICK = EventFactory.createArrayBacked(PlayerTick.class, callbacks -> (world, player) -> { + for (PlayerTick callback : callbacks) { callback.onTick(world, player); } }); - public static final Event PLAYER_DEATH = EventFactory.createArrayBacked(Player_Death.class, callbacks -> (source, player) -> { - for (Player_Death callback : callbacks) { + public static final Event PLAYER_DEATH = EventFactory.createArrayBacked(PlayerDeath.class, callbacks -> (source, player) -> { + for (PlayerDeath callback : callbacks) { callback.onDeath(source, player); } }); - public static final Event PLAYER_CHANGE_DIMENSION = EventFactory.createArrayBacked(Player_Change_Dimension.class, callbacks -> (world, player) -> { - for (Player_Change_Dimension callback : callbacks) { + public static final Event PLAYER_CHANGE_DIMENSION = EventFactory.createArrayBacked(PlayerChangeDimension.class, callbacks -> (world, player) -> { + for (PlayerChangeDimension callback : callbacks) { callback.onChangeDimension(world, player); } }); - public static final Event ON_PLAYER_DIG_SPEED_CALC = EventFactory.createArrayBacked(Player_Dig_Speed_Calc.class, callbacks -> (world, player, digSpeed, state) -> { - for (Player_Dig_Speed_Calc callback : callbacks) { + public static final Event ON_PLAYER_DIG_SPEED_CALC = EventFactory.createArrayBacked(PlayerDigSpeedCalc.class, callbacks -> (world, player, digSpeed, state) -> { + for (PlayerDigSpeedCalc callback : callbacks) { float newSpeed = callback.onDigSpeedCalc(world, player, digSpeed, state); if (newSpeed != digSpeed) { return newSpeed; @@ -46,68 +46,68 @@ public final class IEvents { return -1; }); - public static final Event PLAYER_LOGGED_IN = EventFactory.createArrayBacked(Player_Logged_In.class, callbacks -> (world, player) -> { - for (Player_Logged_In callback : callbacks) { + public static final Event PLAYER_LOGGED_IN = EventFactory.createArrayBacked(PlayerLoggedIn.class, callbacks -> (world, player) -> { + for (PlayerLoggedIn callback : callbacks) { callback.onPlayerLoggedIn(world, player); } }); - public static final Event PLAYER_LOGGED_OUT = EventFactory.createArrayBacked(Player_Logged_Out.class, callbacks -> (world, player) -> { - for (Player_Logged_Out callback : callbacks) { + public static final Event PLAYER_LOGGED_OUT = EventFactory.createArrayBacked(PlayerLoggedOut.class, callbacks -> (world, player) -> { + for (PlayerLoggedOut callback : callbacks) { callback.onPlayerLoggedOut(world, player); } }); - public static final Event PLAYER_ADVANCEMENT = EventFactory.createArrayBacked(Player_Advancement.class, callbacks -> (player, advancement) -> { - for (Player_Advancement callback : callbacks) { + public static final Event PLAYER_ADVANCEMENT = EventFactory.createArrayBacked(PlayerAdvancement.class, callbacks -> (player, advancement) -> { + for (PlayerAdvancement callback : callbacks) { callback.onAdvancement(player, advancement); } }); - public static final Event SERVER_CHAT = EventFactory.createArrayBacked(Server_Chat.class, callbacks -> (player, message) -> { - for (Server_Chat callback : callbacks) { + public static final Event SERVER_CHAT = EventFactory.createArrayBacked(ServerChat.class, callbacks -> (player, message) -> { + for (ServerChat callback : callbacks) { callback.onChat(player, message); } }); @FunctionalInterface - public interface Player_Advancement { + public interface PlayerAdvancement { void onAdvancement(Player player, Advancement advancement); } @FunctionalInterface - public interface Player_Tick { + public interface PlayerTick { void onTick(ServerLevel world, ServerPlayer player); } @FunctionalInterface - public interface Player_Death { + public interface PlayerDeath { void onDeath(DamageSource source, ServerPlayer player); } @FunctionalInterface - public interface Player_Change_Dimension { + public interface PlayerChangeDimension { void onChangeDimension(ServerLevel world, ServerPlayer player); } @FunctionalInterface - public interface Player_Dig_Speed_Calc { + public interface PlayerDigSpeedCalc { float onDigSpeedCalc(Level world, Player player, float digSpeed, BlockState state); } @FunctionalInterface - public interface Player_Logged_In { - void onPlayerLoggedIn(Level world, Player player); + public interface PlayerLoggedIn { + void onPlayerLoggedIn(Level world, ServerPlayer player); } @FunctionalInterface - public interface Player_Logged_Out { - void onPlayerLoggedOut(Level world, Player player); + public interface PlayerLoggedOut { + void onPlayerLoggedOut(Level world, ServerPlayer player); } @FunctionalInterface - public interface Server_Chat { + public interface ServerChat { void onChat(ServerPlayer player, String message); } } diff --git a/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IBotEvent.java b/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IBotEvent.java index ccea8c75..a722e861 100644 --- a/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IBotEvent.java +++ b/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IBotEvent.java @@ -5,6 +5,7 @@ import cn.evole.mods.mcbot.cmds.CmdApi; import cn.evole.mods.mcbot.init.config.ModConfig; import cn.evole.mods.mcbot.util.onebot.CQUtils; +import cn.evole.onebot.client.handler.DefaultEventHandler; import cn.evole.onebot.client.handler.EventBus; import cn.evole.onebot.client.listener.SimpleEventListener; import cn.evole.onebot.sdk.event.message.GroupMessageEvent; @@ -33,7 +34,7 @@ public static void init(EventBus dispatchers) { } private static void GroupChatHandler(EventBus dispatchers) { - dispatchers.addListener(new SimpleEventListener() { + dispatchers.addListener(new DefaultEventHandler() { @Override public void onMessage(GroupMessageEvent event) { if (ModConfig.INSTANCE.getCommon().getGroupIdList().contains(event.getGroupId())//判断是否是配置中的群 diff --git a/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IPlayerEvent.java b/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IPlayerEvent.java index 1f381355..4e02c625 100644 --- a/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IPlayerEvent.java +++ b/fabric/src/main/java/cn/evole/mods/mcbot/init/event/IPlayerEvent.java @@ -23,13 +23,13 @@ * Version: 1.0 */ public class IPlayerEvent { - public static void loggedIn(Level world, Player player) { + public static void loggedIn(Level world, ServerPlayer player) { if (ModConfig.INSTANCE.getStatus().isSJoinEnable() && ModConfig.INSTANCE.getStatus().isSEnable()) { val msg = player.getDisplayName().getString() + " 加入了服务器"; send(msg); } } - public static void loggedOut(Level world, Player player) { + public static void loggedOut(Level world, ServerPlayer player) { if (ModConfig.INSTANCE.getStatus().isSLeaveEnable() && ModConfig.INSTANCE.getStatus().isSEnable()) { val msg = player.getDisplayName().getString() + " 离开了服务器"; send(msg); diff --git a/fabric/wrapper/build.gradle b/fabric/wrapper/build.gradle index b4dabdb0..307861e1 100644 --- a/fabric/wrapper/build.gradle +++ b/fabric/wrapper/build.gradle @@ -20,8 +20,8 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - api("cn.evole.bot:OneBot-Client:${project.onebot_client_version}") - api("cn.evole.config:AtomConfig-Toml:${project.toml_version}") + implementation("cn.evole.bot:OneBot-Client:${project.onebot_client_version}"){transitive = false} + implementation("cn.evole.config:AtomConfig-Toml:${project.toml_version}"){transitive = false} compileOnly "org.projectlombok:lombok:1.18.24" annotationProcessor "org.projectlombok:lombok:1.18.24"