Skip to content

Commit

Permalink
style(fabric): mixin优化
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed Feb 21, 2024
1 parent 3a51a81 commit eef9b51
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 36 deletions.
8 changes: 4 additions & 4 deletions fabric/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ preprocess {


repositories {
mavenCentral()
maven { url = "https://maven.nova-committee.cn/releases" }
maven { url = "https://api.modrinth.com/maven" }
mavenCentral()
}

dependencies {
Expand All @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
* Version: 1.0
*/
public final class IEvents {
public static final Event<Player_Tick> PLAYER_TICK = EventFactory.createArrayBacked(Player_Tick.class, callbacks -> (world, player) -> {
for (Player_Tick callback : callbacks) {
public static final Event<PlayerTick> PLAYER_TICK = EventFactory.createArrayBacked(PlayerTick.class, callbacks -> (world, player) -> {
for (PlayerTick callback : callbacks) {
callback.onTick(world, player);
}
});

public static final Event<Player_Death> PLAYER_DEATH = EventFactory.createArrayBacked(Player_Death.class, callbacks -> (source, player) -> {
for (Player_Death callback : callbacks) {
public static final Event<PlayerDeath> PLAYER_DEATH = EventFactory.createArrayBacked(PlayerDeath.class, callbacks -> (source, player) -> {
for (PlayerDeath callback : callbacks) {
callback.onDeath(source, player);
}
});

public static final Event<Player_Change_Dimension> PLAYER_CHANGE_DIMENSION = EventFactory.createArrayBacked(Player_Change_Dimension.class, callbacks -> (world, player) -> {
for (Player_Change_Dimension callback : callbacks) {
public static final Event<PlayerChangeDimension> PLAYER_CHANGE_DIMENSION = EventFactory.createArrayBacked(PlayerChangeDimension.class, callbacks -> (world, player) -> {
for (PlayerChangeDimension callback : callbacks) {
callback.onChangeDimension(world, player);
}
});

public static final Event<Player_Dig_Speed_Calc> 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<PlayerDigSpeedCalc> 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;
Expand All @@ -46,68 +46,68 @@ public final class IEvents {
return -1;
});

public static final Event<Player_Logged_In> PLAYER_LOGGED_IN = EventFactory.createArrayBacked(Player_Logged_In.class, callbacks -> (world, player) -> {
for (Player_Logged_In callback : callbacks) {
public static final Event<PlayerLoggedIn> 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> PLAYER_LOGGED_OUT = EventFactory.createArrayBacked(Player_Logged_Out.class, callbacks -> (world, player) -> {
for (Player_Logged_Out callback : callbacks) {
public static final Event<PlayerLoggedOut> PLAYER_LOGGED_OUT = EventFactory.createArrayBacked(PlayerLoggedOut.class, callbacks -> (world, player) -> {
for (PlayerLoggedOut callback : callbacks) {
callback.onPlayerLoggedOut(world, player);
}
});

public static final Event<Player_Advancement> PLAYER_ADVANCEMENT = EventFactory.createArrayBacked(Player_Advancement.class, callbacks -> (player, advancement) -> {
for (Player_Advancement callback : callbacks) {
public static final Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createArrayBacked(PlayerAdvancement.class, callbacks -> (player, advancement) -> {
for (PlayerAdvancement callback : callbacks) {
callback.onAdvancement(player, advancement);
}
});


public static final Event<Server_Chat> SERVER_CHAT = EventFactory.createArrayBacked(Server_Chat.class, callbacks -> (player, message) -> {
for (Server_Chat callback : callbacks) {
public static final Event<ServerChat> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,7 +34,7 @@ public static void init(EventBus dispatchers) {
}

private static void GroupChatHandler(EventBus dispatchers) {
dispatchers.addListener(new SimpleEventListener<GroupMessageEvent>() {
dispatchers.addListener(new DefaultEventHandler<GroupMessageEvent>() {
@Override
public void onMessage(GroupMessageEvent event) {
if (ModConfig.INSTANCE.getCommon().getGroupIdList().contains(event.getGroupId())//判断是否是配置中的群
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fabric/wrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit eef9b51

Please sign in to comment.