context) {
20 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
21 | execute(context, false);
22 | return Command.SINGLE_SUCCESS;
23 | }
24 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricAdvancementCriterionEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.event.fabric.dto.advancement.FabricAdvancement;
4 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
5 |
6 | public class FabricAdvancementCriterionEvent extends BasePlayerAdvancementEvent {
7 |
8 | public FabricAdvancementCriterionEvent(FabricServerPlayer player, FabricAdvancement advancement) {
9 | super("FabricAdvancementCriterionEvent", player, advancement);
10 | }
11 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricServerCommandMessageEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BaseCommandEvent;
4 |
5 | public class FabricServerCommandMessageEvent extends BaseCommandEvent {
6 | public FabricServerCommandMessageEvent(String messageId, FabricServerPlayer player, String message) {
7 | super("ServerCommandMessageEvent", messageId, player, message);
8 | }
9 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricServerLivingEntityAfterDeathEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerDeathEvent;
4 |
5 | public class FabricServerLivingEntityAfterDeathEvent extends BasePlayerDeathEvent {
6 |
7 | public FabricServerLivingEntityAfterDeathEvent(String messageId, FabricServerPlayer player, String message) {
8 | super("ServerLivingEntityAfterDeathEvent", messageId, player, message);
9 | }
10 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricServerMessageEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerChatEvent;
4 |
5 | public class FabricServerMessageEvent extends BasePlayerChatEvent {
6 | public FabricServerMessageEvent(String messageId, FabricServerPlayer player, String message) {
7 | super("ServerMessageEvent", messageId, player, message);
8 | }
9 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricServerPlayConnectionDisconnectEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerQuitEvent;
4 |
5 | public class FabricServerPlayConnectionDisconnectEvent extends BasePlayerQuitEvent {
6 | public FabricServerPlayConnectionDisconnectEvent(FabricServerPlayer player) {
7 | super("ServerPlayConnectionDisconnectEvent", player);
8 | }
9 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricServerPlayConnectionJoinEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerJoinEvent;
4 |
5 | public class FabricServerPlayConnectionJoinEvent extends BasePlayerJoinEvent {
6 | public FabricServerPlayConnectionJoinEvent(FabricServerPlayer player) {
7 | super("ServerPlayConnectionJoinEvent", player);
8 | }
9 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/FabricServerPlayer.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayer;
4 | import com.google.gson.annotations.SerializedName;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 |
10 | @Data
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @EqualsAndHashCode(callSuper = true)
14 | public class FabricServerPlayer extends BasePlayer {
15 |
16 | private String ip;
17 | @SerializedName("display_name")
18 | private String displayName;
19 | @SerializedName("movement_speed")
20 | private float movementSpeed;
21 |
22 | @SerializedName("block_x")
23 | private int blockX;
24 | @SerializedName("block_y")
25 | private int blockY;
26 | @SerializedName("block_z")
27 | private int blockZ;
28 |
29 | @SerializedName("is_creative")
30 | private boolean isCreative;
31 | @SerializedName("is_spectator")
32 | private boolean isSpectator;
33 | @SerializedName("is_sneaking")
34 | private boolean isSneaking;
35 | @SerializedName("is_sleeping")
36 | private boolean isSleeping;
37 | @SerializedName("is_climbing")
38 | private boolean isClimbing;
39 | @SerializedName("is_swimming")
40 | private boolean isSwimming;
41 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/dto/advancement/AdvancementDisplayDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class AdvancementDisplayDTO {
11 | /**
12 | * Original type: net.minecraft.text.Text
13 | * getString()
14 | */
15 | private String title;
16 |
17 | /**
18 | * Original type: net.minecraft.text.Text
19 | * getString()
20 | */
21 | private String description;
22 |
23 | private ItemStackDTO icon;
24 |
25 | /**
26 | * Original type: Optional <net.minecraft.util.Identifier>
27 | * toString()
28 | */
29 | private String background;
30 |
31 | /**
32 | * Original type: net.minecraft.advancements.AdvancementFrame
33 | * getToastText().toString()
34 | */
35 | private String frame;
36 |
37 | private Boolean showToast;
38 |
39 | private Boolean announceToChat;
40 |
41 | private Boolean hidden;
42 |
43 | private Float x;
44 |
45 | private Float y;
46 | }
47 |
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/dto/advancement/AdvancementRewardsDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.util.List;
8 |
9 | @Data
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class AdvancementRewardsDTO {
13 |
14 | private Integer experience;
15 |
16 | /**
17 | * Original type: net.minecraft.world.level.storage.loot.LootTable
18 | *
19 | * getLootTableId().toString()
20 | */
21 | private List loot;
22 |
23 | /**
24 | * Original type: List <net.minecraft.resources.Identifier>
25 | *
26 | * toString()
27 | */
28 | private List recipes;
29 | }
30 |
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/dto/advancement/FabricAdvancement.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric.dto.advancement;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.NoArgsConstructor;
8 |
9 | // IF <= fabric-1.20.1
10 | //import com.google.gson.JsonElement;
11 | // END IF
12 |
13 | @Data
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | @EqualsAndHashCode(callSuper = true)
17 | public class FabricAdvancement extends BasePlayerAdvancementEvent.BaseAdvancement {
18 |
19 | private String id;
20 |
21 | /**
22 | * Original type: net.minecraft.util.Identifier
23 | * toString()
24 | */
25 | private String parent;
26 |
27 | /**
28 | * Original type: Optional < net.minecraft.advancement.net.minecraft.advancement.AdvancementDisplay >
29 | */
30 |
31 | private AdvancementDisplayDTO display;
32 |
33 | // IF <= fabric-1.20.1
34 | // /**
35 | // * Original type: JsonElement
36 | // * toJson()
37 | // * version < 1.20.1
38 | // */
39 | // private JsonElement rewards;
40 | // ELSE
41 | // /**
42 | // * Original type: net.minecraft.advancement.net.minecraft.advancement
43 | // * version > 1.20.1
44 | // */
45 | // private AdvancementRewardsDTO rewards;
46 | // END IF
47 | private Boolean sendsTelemetryEvent;
48 |
49 | /**
50 | * Original type: net.minecraft.text.Text
51 | * getString()
52 | */
53 | private String name;
54 |
55 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/event/fabric/dto/advancement/ItemStackDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class ItemStackDTO {
11 | private int count;
12 |
13 | /**
14 | * Original type: net.minecraft.text.Text
15 | *
16 | * getString()
17 | */
18 | private String name;
19 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/handle/HandleCommandReturnMessageImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle;
2 |
3 | import com.github.theword.queqiao.tool.constant.BaseConstant;
4 | import com.github.theword.queqiao.tool.handle.HandleCommandReturnMessageService;
5 | import com.mojang.brigadier.context.CommandContext;
6 | import net.minecraft.server.command.ServerCommandSource;
7 | import net.minecraft.server.network.ServerPlayerEntity;
8 | import net.minecraft.text.Text;
9 |
10 | public class HandleCommandReturnMessageImpl implements HandleCommandReturnMessageService {
11 |
12 | /**
13 | * @param object 命令返回者
14 | * @param message 返回消息
15 | */
16 | @Override
17 | @SuppressWarnings("unchecked")
18 | public void handleCommandReturnMessage(Object object, String message) {
19 | CommandContext context = (CommandContext) object;
20 | if (context.getSource().getEntity() instanceof ServerPlayerEntity)
21 | // IF >= fabric-1.20
22 | // context.getSource().sendFeedback(() -> Text.of(message), false);
23 | // ELSE
24 | // context.getSource().sendFeedback(Text.of(message), false);
25 | // END IF
26 | }
27 |
28 | /**
29 | * 判断发送者是否有权执行命令
30 | * MOD端中无权限节点,权限等级为2
31 | *
32 | * @param object 命令返回者
33 | * @param node 权限节点
34 | * @return boolean 是否有权限
35 | */
36 | @Override
37 | @SuppressWarnings("unchecked")
38 | public boolean hasPermission(Object object, String node) {
39 | CommandContext context = (CommandContext) object;
40 | if (context.getSource().hasPermissionLevel(BaseConstant.MOD_PERMISSION_LEVEL)) return true;
41 | handleCommandReturnMessage(object, "你没有权限执行此命令");
42 | return false;
43 | }
44 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/mixin/AdvancementMixin.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.mixin;
2 |
3 | import com.github.theword.queqiao.event.fabric.FabricAdvancementCriterionEvent;
4 | import com.github.theword.queqiao.event.fabric.dto.advancement.FabricAdvancement;
5 | // IF < fabric-1.20.4
6 | //import net.minecraft.advancement.Advancement;
7 | // ELSE
8 | //import net.minecraft.advancement.AdvancementEntry;
9 | // END IF
10 | import net.minecraft.advancement.PlayerAdvancementTracker;
11 | import net.minecraft.server.network.ServerPlayerEntity;
12 | import org.spongepowered.asm.mixin.Mixin;
13 | import org.spongepowered.asm.mixin.Shadow;
14 | import org.spongepowered.asm.mixin.injection.At;
15 | import org.spongepowered.asm.mixin.injection.Inject;
16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
17 |
18 | import static com.github.theword.queqiao.tool.utils.Tool.config;
19 | import static com.github.theword.queqiao.tool.utils.Tool.sendWebsocketMessage;
20 | import static com.github.theword.queqiao.utils.FabricTool.getFabricAdvancement;
21 | import static com.github.theword.queqiao.utils.FabricTool.getFabricPlayer;
22 |
23 | @Mixin(PlayerAdvancementTracker.class)
24 | public abstract class AdvancementMixin {
25 |
26 | @Shadow
27 | private ServerPlayerEntity owner;
28 |
29 | @Inject(method = "grantCriterion", at = @At("TAIL"))
30 | // IF < fabric-1.20.4
31 | // private void onGrantCriterion(Advancement advancement, String criterionName, CallbackInfoReturnable cir) {
32 | // if (!config.getSubscribeEvent().isPlayerAdvancement()) return;
33 | // FabricAdvancement fabricAdvancement = getFabricAdvancement(advancement);
34 | // ELSE
35 | // private void onGrantCriterion(AdvancementEntry advancementEntry, String criterionName, CallbackInfoReturnable cir) {
36 | // if (!config.getSubscribeEvent().isPlayerAdvancement()) return;
37 | // FabricAdvancement fabricAdvancement = getFabricAdvancement(advancementEntry.value());
38 | // fabricAdvancement.setId(advancementEntry.id().toString());
39 | // END IF
40 | FabricAdvancementCriterionEvent fabricAdvancementCriterionEvent = new FabricAdvancementCriterionEvent(getFabricPlayer(owner), fabricAdvancement);
41 | sendWebsocketMessage(fabricAdvancementCriterionEvent);
42 | }
43 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/mixin/PlayerManagerMixin.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.mixin;
2 |
3 | import com.github.theword.queqiao.event.fabric.FabricServerPlayConnectionJoinEvent;
4 |
5 | import net.minecraft.network.ClientConnection;
6 | import net.minecraft.server.PlayerManager;
7 |
8 | // IF >= fabric-1.20.4
9 | //import net.minecraft.server.network.ConnectedClientData;
10 | // END IF
11 | import net.minecraft.server.network.ServerPlayerEntity;
12 | import org.spongepowered.asm.mixin.Mixin;
13 | import org.spongepowered.asm.mixin.injection.At;
14 | import org.spongepowered.asm.mixin.injection.Inject;
15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16 |
17 | import static com.github.theword.queqiao.utils.FabricTool.getFabricPlayer;
18 | import static com.github.theword.queqiao.tool.utils.Tool.config;
19 | import static com.github.theword.queqiao.tool.utils.Tool.sendWebsocketMessage;
20 |
21 | @Mixin(PlayerManager.class)
22 | public class PlayerManagerMixin {
23 |
24 | @Inject(method = "onPlayerConnect", at = @At("TAIL"))
25 | // IF >= fabric-1.20.4
26 | // private void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) {
27 | // ELSE
28 | // private void onPlayerJoin(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
29 | // END IF
30 | if (!config.getSubscribeEvent().isPlayerJoin()) return;
31 |
32 | FabricServerPlayConnectionJoinEvent event = new FabricServerPlayConnectionJoinEvent(getFabricPlayer(player));
33 | sendWebsocketMessage(event);
34 | }
35 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/mixin/ServerPlayNetworkHandlerMixin.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.mixin;
2 |
3 | import com.github.theword.queqiao.event.fabric.FabricServerCommandMessageEvent;
4 | import com.github.theword.queqiao.event.fabric.FabricServerMessageEvent;
5 | import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
6 | // IF > fabric-1.18.2
7 | //import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket;
8 | // END IF
9 | import net.minecraft.server.network.ServerPlayNetworkHandler;
10 | import net.minecraft.server.network.ServerPlayerEntity;
11 | import org.spongepowered.asm.mixin.Mixin;
12 | import org.spongepowered.asm.mixin.Shadow;
13 | import org.spongepowered.asm.mixin.injection.At;
14 | import org.spongepowered.asm.mixin.injection.Inject;
15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16 |
17 | import java.util.Objects;
18 |
19 | import static com.github.theword.queqiao.tool.utils.Tool.*;
20 | import static com.github.theword.queqiao.utils.FabricTool.getFabricPlayer;
21 |
22 | @Mixin(ServerPlayNetworkHandler.class)
23 | public class ServerPlayNetworkHandlerMixin {
24 | @Shadow
25 | public ServerPlayerEntity player;
26 |
27 | // IF > fabric-1.16.5
28 | // @Inject(method = "onChatMessage", at = @At("HEAD"))
29 | // ELSE
30 | // @Inject(method = "onGameMessage", at = @At("HEAD"))
31 | // END IF
32 | private void onChatMessage(ChatMessageC2SPacket packet, CallbackInfo info) {
33 | // IF > fabric-1.18.2
34 | // String message = packet.chatMessage();
35 | // ELSE IF fabric-1.18.2
36 | // String message = packet.getChatMessage();
37 | // ELSE
38 | // String message = packet.getChatMessage();
39 | // END IF
40 |
41 | if (message.startsWith("/")) return;
42 | if (!config.getSubscribeEvent().isPlayerChat()) return;
43 |
44 | FabricServerMessageEvent event = new FabricServerMessageEvent("", getFabricPlayer(player), message);
45 | sendWebsocketMessage(event);
46 | }
47 |
48 | // IF > fabric-1.18.2
49 | // @Inject(method = "onCommandExecution", at = @At("HEAD"))
50 | // private void onCommandExecution(CommandExecutionC2SPacket packet, CallbackInfo ci) {
51 | // String input = packet.command();
52 | // ELSE IF fabric-1.18.2
53 | // @Inject(method = "executeCommand", at = @At("HEAD"))
54 | // private void executeCommand(String input, CallbackInfo ci) {
55 | // ELSE
56 | // @Inject(method = "executeCommand", at = @At("HEAD"))
57 | // private void executeCommand(String input, CallbackInfo ci) {
58 | // END IF
59 | if (!config.getSubscribeEvent().isPlayerCommand()) return;
60 |
61 | String registerOrLoginCommand = isRegisterOrLoginCommand(input);
62 |
63 | if (registerOrLoginCommand.isEmpty()) return;
64 |
65 | FabricServerCommandMessageEvent event = new FabricServerCommandMessageEvent("", getFabricPlayer(Objects.requireNonNull(player)), registerOrLoginCommand);
66 | sendWebsocketMessage(event);
67 | }
68 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/java/com/github/theword/queqiao/mixin/ServerPlayerEntityMixin.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.mixin;
2 |
3 | import com.github.theword.queqiao.event.fabric.FabricServerLivingEntityAfterDeathEvent;
4 | import com.github.theword.queqiao.event.fabric.FabricServerPlayConnectionDisconnectEvent;
5 | import net.minecraft.entity.damage.DamageSource;
6 | import net.minecraft.server.network.ServerPlayerEntity;
7 | import org.spongepowered.asm.mixin.Mixin;
8 | import org.spongepowered.asm.mixin.injection.At;
9 | import org.spongepowered.asm.mixin.injection.Inject;
10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11 |
12 | import static com.github.theword.queqiao.utils.FabricTool.getFabricPlayer;
13 | import static com.github.theword.queqiao.tool.utils.Tool.config;
14 | import static com.github.theword.queqiao.tool.utils.Tool.sendWebsocketMessage;
15 |
16 | @Mixin(ServerPlayerEntity.class)
17 | public abstract class ServerPlayerEntityMixin {
18 |
19 | @Inject(method = "onDeath", at = @At("HEAD"))
20 | public void onDeath(DamageSource source, CallbackInfo ci) {
21 | if (!config.getSubscribeEvent().isPlayerDeath()) return;
22 |
23 | ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
24 | String message = player.getDamageTracker().getDeathMessage().getString();
25 | FabricServerLivingEntityAfterDeathEvent event = new FabricServerLivingEntityAfterDeathEvent("", getFabricPlayer(player), message);
26 | sendWebsocketMessage(event);
27 | }
28 |
29 | @Inject(method = "onDisconnect", at = @At("HEAD"))
30 | public void onDisconnected(CallbackInfo ci) {
31 | if (!config.getSubscribeEvent().isPlayerQuit()) return;
32 |
33 | ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
34 | FabricServerPlayConnectionDisconnectEvent event = new FabricServerPlayConnectionDisconnectEvent(getFabricPlayer(player));
35 | sendWebsocketMessage(event);
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "queqiao",
4 | "version": "${version}",
5 | "name": "QueQiao",
6 | "description": "",
7 | "authors": [],
8 | "contact": {},
9 | "license": "MIT",
10 | "icon": "logo.png",
11 | "environment": "server",
12 | "entrypoints": {
13 | "main": [
14 | "com.github.theword.queqiao.QueQiao"
15 | ]
16 | },
17 | "mixins": [
18 | "queqiao.mixins.json"
19 | ],
20 | "depends": {
21 | "fabricloader": ">=${loader_version}",
22 | "fabric": "*",
23 | "minecraft": "${minecraft_version}"
24 | }
25 | }
--------------------------------------------------------------------------------
/fabric/origin/src/main/resources/queqiao.mixins.json5:
--------------------------------------------------------------------------------
1 | // ONEWAY
2 | // RENAME queqiao.mixins.json
3 | {
4 | "required": true,
5 | "package": "com.github.theword.queqiao.mixin",
6 | // IF >= fabric-1.20.5
7 | // "compatibilityLevel": "JAVA_21",
8 | // ELSE IF > fabric-1.16.5
9 | // "compatibilityLevel": "JAVA_17",
10 | // ELSE
11 | // "compatibilityLevel": "JAVA_8",
12 | // END IF
13 | "mixins": [
14 | "AdvancementMixin",
15 | "PlayerManagerMixin",
16 | "ServerPlayerEntityMixin",
17 | "ServerPlayNetworkHandlerMixin"
18 | ],
19 | "injectors": {
20 | "defaultRequire": 1
21 | },
22 | "client": [
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/fabric/origin/src/test/java/com/github/theword/queqiao/utils/ParseJsonToEventImplTest.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils;
2 |
3 | import com.github.theword.queqiao.tool.response.Response;
4 | import com.google.gson.JsonElement;
5 | import com.google.gson.JsonParser;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import java.io.FileNotFoundException;
9 | import java.io.FileReader;
10 |
11 | import static com.github.theword.queqiao.tool.utils.TestUtils.testParseJsonMessage;
12 | import static com.github.theword.queqiao.tool.utils.Tool.logger;
13 | import static org.slf4j.LoggerFactory.getLogger;
14 |
15 | class ParseJsonToEventImplTest {
16 |
17 | ParseJsonToEventImpl parseJsonToEventImpl = new ParseJsonToEventImpl();
18 |
19 | // IF < fabric-1.20.4
20 | // @Test
21 | // void parseMessage() throws FileNotFoundException {
22 | // FileReader reader = new FileReader("../../test_messages.json");
23 | // IF <= fabric-1.16.5
24 | // JsonElement testMessageJsonElement = new JsonParser().parse(reader);
25 | // ELSE
26 | // JsonElement testMessageJsonElement = JsonParser.parseReader(reader);
27 | // END IF
28 | // logger = getLogger(getClass());
29 | //
30 | // if (!testMessageJsonElement.isJsonArray()) {
31 | // logger.warn("jsonElement is not json array");
32 | // return;
33 | // }
34 | //
35 | // logger.info("Testing messages");
36 | //
37 | // for (JsonElement message : testMessageJsonElement.getAsJsonArray()) {
38 | // logger.info("============================================");
39 | // Response response = testParseJsonMessage(message.getAsString(), parseJsonToEventImpl);
40 | // logger.info("response = " + response);
41 | // }
42 | // }
43 | // END IF
44 |
45 | }
--------------------------------------------------------------------------------
/forge/forge-1.16.5/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/forge/forge-1.18.2/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/forge/forge-1.19.2/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/forge/forge-1.20.1/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/forge/forge-1.21/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/forge/origin/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx3G
2 | org.gradle.daemon=false
3 | # Mod Properties
4 | mod_id=queqiao
5 | mod_name=QueQiao
6 | mod_license=MIT
7 | mod_group_id=com.github.theword.queqiao
8 | mod_authors=17TheWord
9 | mod_description=Connect to nonebot2.
10 | # Lib Properties
11 | lombok_version=1.18.30
12 | snakeyaml_version=2.2
13 | junit_jupiter_version=5.11.4
14 | java_websocket_version=1.5.3
15 | maven_repository_url=https://maven.pkg.github.com/17TheWord/QueQiaoTool
16 | # JDK Version
17 | # IF <= forge-1.16.5
18 | #java_version=8
19 | # ELSE IF >= forge-1.20.5
20 | #java_version=21
21 | # ELSE
22 | #java_version=17
23 | # END IF
24 | # Forge Properties
25 | mapping_channel=official
26 | # IF forge-1.16.5
27 | #minecraft_version=1.16.5
28 | #mapping_version=1.16.5
29 | #forge_version_range=[36,)
30 | #minecraft_version_range=[1.16.5,1.17)
31 | #forge_version=36.2.34
32 | #slf4j_version=1.7.25
33 | # ELSE IF forge-1.18.2
34 | #minecraft_version=1.18.2
35 | #forge_version=40.2.0
36 | #forge_version_range=[40,)
37 | #minecraft_version_range=[1.18.2,1.19)
38 | # ELSE IF forge-1.19.2
39 | #minecraft_version=1.19.2
40 | #forge_version=43.3.0
41 | #forge_version_range=[43,)
42 | #minecraft_version_range=[1.19.2,1.20)
43 | # ELSE IF forge-1.20.1
44 | #minecraft_version=1.20.1
45 | #forge_version=47.2.20
46 | #forge_version_range=[47,)
47 | #minecraft_version_range=[1.20.1,1.21)
48 | # ELSE IF forge-1.21
49 | #minecraft_version=1.21
50 | #forge_version=51.0.17
51 | #forge_version_range=[51,)
52 | #minecraft_version_range=[1.21,1.22)
53 | # END IF
--------------------------------------------------------------------------------
/forge/origin/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | maven {
5 | name = 'MinecraftForge'
6 | url = 'https://maven.minecraftforge.net/'
7 | }
8 | }
9 | }
10 |
11 | plugins {
12 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
13 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/QueQiao.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | import com.github.theword.queqiao.handle.HandleApiImpl;
4 | import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl;
5 | import com.github.theword.queqiao.tool.constant.BaseConstant;
6 | import com.github.theword.queqiao.tool.constant.ServerTypeConstant;
7 | import net.minecraft.server.MinecraftServer;
8 | import net.minecraftforge.api.distmarker.Dist;
9 | import net.minecraftforge.api.distmarker.OnlyIn;
10 | import net.minecraftforge.common.MinecraftForge;
11 | import net.minecraftforge.eventbus.api.SubscribeEvent;
12 | import net.minecraftforge.fml.common.Mod;
13 |
14 | import static com.github.theword.queqiao.tool.utils.Tool.initTool;
15 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
16 |
17 |
18 | @Mod(BaseConstant.MOD_ID)
19 | public class QueQiao {
20 | public static MinecraftServer minecraftServer;
21 |
22 | public QueQiao() {
23 | MinecraftForge.EVENT_BUS.register(this);
24 | MinecraftForge.EVENT_BUS.register(new EventProcessor());
25 | }
26 |
27 | @OnlyIn(Dist.DEDICATED_SERVER)
28 | @SubscribeEvent
29 | // IF > forge-1.16.5
30 | // public void onServerStarted(net.minecraftforge.event.server.ServerStartingEvent event) {
31 | // ELSE
32 | // public void onServerStarted(net.minecraftforge.fml.event.server.FMLServerStartingEvent event) {
33 | // END IF
34 | minecraftServer = event.getServer();
35 | initTool(true, minecraftServer.getServerVersion(), ServerTypeConstant.FORGE, new HandleApiImpl(), new HandleCommandReturnMessageImpl());
36 | websocketManager.startWebsocketOnServerStart();
37 | }
38 |
39 | @OnlyIn(Dist.DEDICATED_SERVER)
40 | @SubscribeEvent
41 | // IF > forge-1.16.5
42 | // public void onServerStopping(net.minecraftforge.event.server.ServerStoppingEvent event) {
43 | // ELSE
44 | // public void onServerStopping(net.minecraftforge.fml.event.server.FMLServerStoppingEvent event) {
45 | // END IF
46 | websocketManager.stopWebsocketByServerClose();
47 | }
48 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/CommandExecutor.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
4 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
5 | import com.github.theword.queqiao.command.subCommand.client.ReconnectAllCommand;
6 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
7 | import com.github.theword.queqiao.tool.constant.BaseConstant;
8 | import com.mojang.brigadier.Command;
9 | // IF > forge-1.16.5
10 | //import net.minecraft.commands.Commands;
11 | // ELSE
12 | //import net.minecraft.command.Commands;
13 | // END IF
14 | import net.minecraftforge.event.RegisterCommandsEvent;
15 | import net.minecraftforge.eventbus.api.SubscribeEvent;
16 | import net.minecraftforge.fml.common.Mod;
17 | import net.minecraftforge.server.command.ConfigCommand;
18 |
19 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
20 |
21 |
22 | @Mod.EventBusSubscriber(modid = BaseConstant.MOD_ID)
23 | public class CommandExecutor {
24 |
25 | @SubscribeEvent
26 | public static void registerCommands(RegisterCommandsEvent event) {
27 | event.getDispatcher().register(
28 | Commands.literal(BaseConstant.COMMAND_HEADER)
29 | .requires(source -> source.hasPermission(2))
30 | .executes(context -> new HelpCommand().onCommand(context))
31 | .then(Commands.literal("help")
32 | .executes(context -> new HelpCommand().onCommand(context))
33 | )
34 | .then(Commands.literal("reload")
35 | .executes(context -> new ReloadCommand().onCommand(context))
36 | )
37 | .then(Commands.literal("client")
38 | .then(Commands.literal("reconnect")
39 | .executes(context -> new ReconnectCommand().onCommand(context))
40 | .then(Commands.literal("all")
41 | .executes(context -> new ReconnectAllCommand().onCommand(context)))
42 | )
43 | ).then(Commands.literal("server")
44 | .executes(context -> {
45 | // TODO Websocket Server Command
46 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "Server command is not supported");
47 | return Command.SINGLE_SUCCESS;
48 | })
49 | )
50 | );
51 | ConfigCommand.register(event.getDispatcher());
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/CommandManager.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
4 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
5 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
6 | import lombok.Getter;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | @Getter
12 | public class CommandManager {
13 |
14 | private final List subCommandList = new ArrayList<>();
15 |
16 | public CommandManager() {
17 | subCommandList.add(new HelpCommand());
18 | subCommandList.add(new ReloadCommand());
19 | subCommandList.add(new ReconnectCommand());
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/ForgeSubCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.mojang.brigadier.context.CommandContext;
4 |
5 | public interface ForgeSubCommand {
6 |
7 | String getName();
8 |
9 | String getDescription();
10 |
11 | String getUsage();
12 |
13 | // IF > forge-1.16.5
14 | // int onCommand(CommandContext context);
15 | // ELSE
16 | // int onCommand(CommandContext context);
17 | // END IF
18 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/HelpCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.CommandManager;
4 | import com.github.theword.queqiao.command.ForgeSubCommand;
5 | import com.github.theword.queqiao.tool.command.subCommand.HelpCommandAbstract;
6 | import com.mojang.brigadier.Command;
7 | import com.mojang.brigadier.context.CommandContext;
8 |
9 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
10 |
11 |
12 | public class HelpCommand extends HelpCommandAbstract implements ForgeSubCommand {
13 |
14 | @Override
15 | // IF > forge-1.16.5
16 | // public int onCommand(CommandContext context) {
17 | // ELSE
18 | // public int onCommand(CommandContext context) {
19 | // END IF
20 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
21 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "-------------------");
22 | for (ForgeSubCommand forgeSubCommand : new CommandManager().getSubCommandList()) {
23 | handleCommandReturnMessageService.handleCommandReturnMessage(context, forgeSubCommand.getUsage() + "---" + forgeSubCommand.getDescription());
24 | }
25 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "-------------------");
26 | return Command.SINGLE_SUCCESS;
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.ForgeSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.ReloadCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 |
8 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
9 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
10 |
11 |
12 | public class ReloadCommand extends ReloadCommandAbstract implements ForgeSubCommand {
13 |
14 | @Override
15 | // IF > forge-1.16.5
16 | // public int onCommand(CommandContext context) {
17 | // ELSE
18 | // public int onCommand(CommandContext context) {
19 | // END IF
20 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
21 | execute(context, true);
22 | return Command.SINGLE_SUCCESS;
23 | }
24 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectAllCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.ForgeSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 |
8 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
9 |
10 |
11 | public class ReconnectAllCommand extends ReconnectCommandAbstract implements ForgeSubCommand {
12 |
13 | @Override
14 | // IF > forge-1.16.5
15 | // public int onCommand(CommandContext context) {
16 | // ELSE
17 | // public int onCommand(CommandContext context) {
18 | // END IF
19 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
20 | execute(context, true);
21 | return Command.SINGLE_SUCCESS;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.ForgeSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 |
8 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
9 |
10 |
11 | public class ReconnectCommand extends ReconnectCommandAbstract implements ForgeSubCommand {
12 |
13 | @Override
14 | // IF > forge-1.16.5
15 | // public int onCommand(CommandContext context) {
16 | // ELSE
17 | // public int onCommand(CommandContext context) {
18 | // END IF
19 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
20 | execute(context, false);
21 | return Command.SINGLE_SUCCESS;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgeAdvancementEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.event.forge.dto.advancement.ForgeAdvancement;
4 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
5 |
6 | public class ForgeAdvancementEvent extends BasePlayerAdvancementEvent {
7 | public ForgeAdvancementEvent(ForgeServerPlayer player, ForgeAdvancement advancement) {
8 | super("ForgeAdvancementEvent", player, advancement);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgeCommandEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BaseCommandEvent;
4 |
5 | public class ForgeCommandEvent extends BaseCommandEvent {
6 | public ForgeCommandEvent(String messageId, ForgeServerPlayer player, String command) {
7 | super("CommandEvent", messageId, player, command);
8 | }
9 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgePlayerDeathEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerDeathEvent;
4 |
5 | public class ForgePlayerDeathEvent extends BasePlayerDeathEvent {
6 |
7 | public ForgePlayerDeathEvent(String messageId, ForgeServerPlayer player, String message) {
8 | super("PlayerDeathEvent", messageId, player, message);
9 | }
10 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgePlayerLoggedInEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerJoinEvent;
4 |
5 | public final class ForgePlayerLoggedInEvent extends BasePlayerJoinEvent {
6 | public ForgePlayerLoggedInEvent(ForgeServerPlayer player) {
7 | super("PlayerLoggedInEvent", player);
8 | }
9 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgePlayerLoggedOutEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerQuitEvent;
4 |
5 | public final class ForgePlayerLoggedOutEvent extends BasePlayerQuitEvent {
6 | public ForgePlayerLoggedOutEvent(ForgeServerPlayer player) {
7 | super("PlayerLoggedOutEvent", player);
8 | }
9 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgeServerChatEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerChatEvent;
4 |
5 | public final class ForgeServerChatEvent extends BasePlayerChatEvent {
6 | public ForgeServerChatEvent(String messageId, ForgeServerPlayer player, String message) {
7 | super("ServerChatEvent", messageId, player, message);
8 | }
9 |
10 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/ForgeServerPlayer.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayer;
4 | import com.google.gson.annotations.SerializedName;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 |
10 | @Data
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @EqualsAndHashCode(callSuper = true)
14 | public class ForgeServerPlayer extends BasePlayer {
15 |
16 | @SerializedName("display_name")
17 | private String displayName;
18 |
19 | @SerializedName("ip_address")
20 | private String ipAddress;
21 |
22 | private float speed;
23 | @SerializedName("flying_speed")
24 | private float flyingSpeed;
25 |
26 | @SerializedName("is_flying")
27 | private boolean isFlying;
28 |
29 | @SerializedName("is_swimming")
30 | private boolean isSwimming;
31 | @SerializedName("is_sleeping")
32 | private boolean isSleeping;
33 | @SerializedName("is_blocking")
34 | private boolean isBlocking;
35 |
36 | @SerializedName("game_mode")
37 | private String gameMode;
38 |
39 | @SerializedName("block_x")
40 | private int blockX;
41 | @SerializedName("block_y")
42 | private int blockY;
43 | @SerializedName("block_z")
44 | private int blockZ;
45 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/dto/advancement/AdvancementRewardsDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.fabric.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.util.List;
8 |
9 | @Data
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class AdvancementRewardsDTO {
13 |
14 | private Integer experience;
15 |
16 | /**
17 | * Original type: net.minecraft.world.level.storage.loot.LootTable
18 | *
19 | * getLootTableId().toString()
20 | */
21 | private List loot;
22 |
23 | /**
24 | * Original type: List <net.minecraft.resources.Identifier>
25 | *
26 | * toString()
27 | */
28 | private List recipes;
29 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/dto/advancement/DisplayInfoDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class DisplayInfoDTO {
11 | /**
12 | * Original type: net.minecraft.network.chat.Component
13 | * toString()
14 | */
15 | private String title;
16 |
17 | /**
18 | * Original type: net.minecraft.network.chat.Component
19 | * toString()
20 | */
21 | private String description;
22 | private ItemStackDTO icon;
23 |
24 | /**
25 | * Original type: net.minecraft.util.ResourceLocation
26 | * toString()
27 | */
28 | private String background;
29 | /**
30 | * Original type: net.minecraft.advancements.FrameType
31 | * getName()
32 | */
33 | private String frame;
34 | private Boolean showToast;
35 | private Boolean announceToChat;
36 | private Boolean hidden;
37 | private Float x;
38 | private Float y;
39 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/dto/advancement/ForgeAdvancement.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge.dto.advancement;
2 |
3 | import com.github.theword.queqiao.event.fabric.dto.advancement.AdvancementRewardsDTO;
4 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 |
10 | // IF < forge-1.21
11 | //import com.google.gson.JsonElement;
12 | // END IF
13 |
14 | @Data
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | @EqualsAndHashCode(callSuper = true)
18 | public class ForgeAdvancement extends BasePlayerAdvancementEvent.BaseAdvancement {
19 |
20 | /**
21 | * Original type: net.minecraft.advancements.Advancement
22 | * getId().toString()
23 | */
24 | private String parent;
25 |
26 | private DisplayInfoDTO display;
27 |
28 | // IF < forge-1.21
29 | // /**
30 | // * Original type: net.minecraft.util.ResourceLocation
31 | // * toString()
32 | // * version < 1.21
33 | // */
34 | // private String id;
35 | // /**
36 | // * Original type: net.minecraft.advancements.AdvancementRewards
37 | // * serializeToJson()
38 | // * version < 1.21
39 | // */
40 | // private JsonElement rewards;
41 | // /**
42 | // * Original type: net.minecraft.network.chat.Component
43 | // * toString()
44 | // * version < 1.21
45 | // */
46 | // private String chatComponent;
47 | // ELSE
48 | // /**
49 | // * Original type: net.minecraft.network.chat.Component
50 | // * getString()
51 | // * version > 1.21
52 | // */
53 | // private String name;
54 | // /**
55 | // * Original type: net.minecraft.advancements.AdvancementRewards
56 | // * serializeToJson()
57 | // * version > 1.21
58 | // */
59 | // private AdvancementRewardsDTO rewards;
60 | // END IF
61 |
62 |
63 | private Boolean sendsTelemetryEvent;
64 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/event/forge/dto/advancement/ItemStackDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.forge.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class ItemStackDTO {
11 | private int count;
12 | private int popTime;
13 | /**
14 | * Original type: net.minecraft.item.Item
15 | *
16 | * toString()
17 | */
18 | private String item;
19 |
20 | /**
21 | * Original type: net.minecraft.network.chat.Component
22 | * getString()
23 | */
24 | private String displayName;
25 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/java/com/github/theword/queqiao/handle/HandleCommandReturnMessageImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle;
2 |
3 | import com.github.theword.queqiao.tool.constant.BaseConstant;
4 | import com.github.theword.queqiao.tool.handle.HandleCommandReturnMessageService;
5 | import com.mojang.brigadier.context.CommandContext;
6 | // IF >= forge-1.21
7 | //import net.minecraft.network.chat.contents.PlainTextContents.LiteralContents;
8 | // ELSE IF >= forge-1.19
9 | //import net.minecraft.network.chat.contents.LiteralContents;
10 | // END IF
11 | // IF >= forge-1.18
12 | // END IF
13 |
14 | public class HandleCommandReturnMessageImpl implements HandleCommandReturnMessageService {
15 |
16 | @Override
17 | @SuppressWarnings("unchecked")
18 | public void handleCommandReturnMessage(Object object, String message) {
19 | // IF > forge-1.16.5
20 | // CommandContext context = (CommandContext) object;
21 | // END IF
22 | // IF >= forge-1.19
23 | // context.getSource().sendSystemMessage(net.minecraft.network.chat.MutableComponent.create(new LiteralContents(message)));
24 | // ELSE IF >= forge-1.18
25 | // context.getSource().sendSuccess(new net.minecraft.network.chat.TextComponent(message), false);
26 | // ELSE
27 | // CommandContext context = (CommandContext) object;
28 | // context.getSource().sendSuccess(new net.minecraft.util.text.StringTextComponent(message), false);
29 | // END IF
30 | }
31 |
32 | /**
33 | * 判断发送者是否有权执行命令
34 | * MOD端中无权限节点,权限等级为2
35 | *
36 | * @param object 命令返回者
37 | * @param node 权限节点
38 | * @return boolean 是否有权限
39 | */
40 | @Override
41 | @SuppressWarnings("unchecked")
42 | public boolean hasPermission(Object object, String node) {
43 | // IF > forge-1.16.5
44 | // CommandContext context = (CommandContext) object;
45 | // ELSE
46 | // CommandContext context = (CommandContext) object;
47 | // END IF
48 | if (context.getSource().hasPermission(BaseConstant.MOD_PERMISSION_LEVEL)) return true;
49 | handleCommandReturnMessage(object, "您没有权限执行此命令");
50 | return false;
51 | }
52 | }
--------------------------------------------------------------------------------
/forge/origin/src/main/resources/META-INF/mods.toml:
--------------------------------------------------------------------------------
1 | modLoader = "javafml" #mandatory
2 | loaderVersion = "${forge_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
3 | license = "${mod_license}"
4 | [[mods]] #mandatory
5 | modId = "${mod_id}" #mandatory
6 | version = "${mod_version}" #mandatory
7 | displayName = "${mod_name}" #mandatory
8 | authors = "${mod_authors}" #optional
9 | description = '''${mod_description}'''
10 | [[dependencies."${mod_id}"]] #optional
11 | modId = "forge" #mandatory
12 | mandatory = true #mandatory
13 | versionRange = "${forge_version_range}" #mandatory
14 | ordering = "NONE"
15 | side = "BOTH"# Here's another dependency
16 | [[dependencies."${mod_id}"]]
17 | modId = "minecraft"
18 | mandatory = true
19 | versionRange = "${minecraft_version_range}"
20 | ordering = "NONE"
21 | side = "BOTH"
22 |
--------------------------------------------------------------------------------
/forge/origin/src/main/resources/pack.mcmeta.json5:
--------------------------------------------------------------------------------
1 | // ONEWAY
2 | // RENAME pack.mcmeta
3 | {
4 | "pack": {
5 | "description": "queqiao resources",
6 | // IF forge-1.16.5
7 | // "pack_format": 6,
8 | // "_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods."
9 | // ELSE IF forge-1.18.2
10 | // "pack_format": 9,
11 | // "forge:resource_pack_format": 8,
12 | // "forge:data_pack_format": 9
13 | // ELSE IF forge-1.19.2
14 | // "pack_format": 10,
15 | // "forge:resource_pack_format": 9,
16 | // "forge:data_pack_format": 10
17 | // ELSE IF forge-1.20.1
18 | // "pack_format": 12,
19 | // "forge:server_data_pack_format": 12
20 | // ELSE IF forge-1.21
21 | // "pack_format": 15,
22 | // "forge:server_data_pack_format": 12
23 | // END IF
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/forge/origin/src/test/java/com/github/theword/queqiao/utils/ParseJsonToEventImplTest.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils;
2 |
3 | import com.github.theword.queqiao.tool.response.Response;
4 | import com.google.gson.JsonElement;
5 | import com.google.gson.JsonParser;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import java.io.FileNotFoundException;
9 | import java.io.FileReader;
10 |
11 | import static com.github.theword.queqiao.tool.utils.TestUtils.testParseJsonMessage;
12 | import static com.github.theword.queqiao.tool.utils.Tool.logger;
13 | import static org.slf4j.LoggerFactory.getLogger;
14 |
15 | class ParseJsonToEventImplTest {
16 | ParseJsonToEventImpl parseJsonToEventImpl = new ParseJsonToEventImpl();
17 |
18 | @Test
19 | void parseMessage() throws FileNotFoundException {
20 | FileReader reader = new FileReader("../../test_messages.json");
21 | // IF <= forge-1.16.5
22 | // JsonElement testMessageJsonElement = new JsonParser().parse(reader);
23 | // ELSE
24 | // JsonElement testMessageJsonElement = JsonParser.parseReader(reader);
25 | // END IF
26 | logger = getLogger(getClass());
27 |
28 | if (!testMessageJsonElement.isJsonArray()) {
29 | logger.warn("jsonElement is not json array");
30 | return;
31 | }
32 |
33 | logger.info("Testing messages");
34 |
35 | for (JsonElement message : testMessageJsonElement.getAsJsonArray()) {
36 | logger.info("============================================");
37 | Response response = testParseJsonMessage(message.getAsString(), parseJsonToEventImpl);
38 | logger.info("response = " + response);
39 | }
40 |
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/init.ps1:
--------------------------------------------------------------------------------
1 | $file = Get-ChildItem -Path "tool" -Filter "ModMultiVersionTool*.jar" | Select-Object -First 1
2 |
3 | if ($file) {
4 | java -jar $file.FullName
5 | } else {
6 | Write-Output "can't find ModMultiVersionTool.jar"
7 | }
8 |
--------------------------------------------------------------------------------
/init.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | file=$(find tool -name "ModMultiVersionTool*.jar" | head -n 1)
4 |
5 | if [ -n "$file" ]; then
6 | java -jar "$file"
7 | else
8 | echo "can't find ModMultiVersionTool.jar"
9 | fi
10 |
--------------------------------------------------------------------------------
/matrix.ps1:
--------------------------------------------------------------------------------
1 | param (
2 | [string[]]$paths
3 | )
4 |
5 | $allFolderObjects = @()
6 |
7 | foreach ($path in $paths) {
8 | $folders = Get-ChildItem -Path $path -Directory
9 | $filteredFolders = $folders | Where-Object { $_.Name -ne "origin" }
10 |
11 | $folderObjects = $filteredFolders | ForEach-Object {
12 | [PSCustomObject]@{
13 | "mc-version" = $_.Name.Replace("$path-", "")
14 | "mc-loader" = $path
15 | }
16 | }
17 |
18 | $allFolderObjects += $folderObjects
19 | }
20 |
21 | $json = [PSCustomObject]@{
22 | "config" = $allFolderObjects
23 | } | ConvertTo-Json -Compress
24 |
25 | Write-Output "::set-output name=matrix::$json"
26 |
--------------------------------------------------------------------------------
/matrix.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | while [[ $# -gt 0 ]]; do
4 | case $1 in
5 | -path)
6 | IFS=',' read -r -a paths <<< "$2"
7 | shift 2
8 | ;;
9 | *)
10 | echo "Unknown option: $1"
11 | exit 1
12 | ;;
13 | esac
14 | done
15 |
16 | # 用于存储所有文件夹的数组
17 | allFolderObjects=()
18 |
19 | # 遍历每个路径
20 | for path in "${paths[@]}"; do
21 | # 获取指定路径下的文件夹
22 | folders=$(find "$path" -mindepth 1 -maxdepth 1 -type d)
23 |
24 | # 过滤掉名为 "origin" 的文件夹
25 | for folder in $folders; do
26 | folderName=$(basename "$folder")
27 | if [[ "$folderName" != "origin" ]]; then
28 | # 提取 mc-version 和 mc-loader 信息
29 | mcVersion="${folderName//$path-/}"
30 | mcLoader="$path"
31 | supportVersionFile="$mcLoader/$mcLoader-$mcVersion/support_version.txt"
32 | if [[ -f "$supportVersionFile" ]]; then
33 | supportVersion=$(cat "$supportVersionFile")
34 | else
35 | supportVersion="$mcVersion"
36 | fi
37 |
38 | if [ "$mcLoader" == "fabric" ]; then
39 | publishLoaders="fabric quilt"
40 | else
41 | publishLoaders="$mcLoader"
42 | fi
43 | allFolderObjects+=("{\"mc-version\": \"$mcVersion\", \"mc-loader\": \"$mcLoader\", \"publish-loaders\": \"$publishLoaders\", \"publish-version\": \"$supportVersion\"}")
44 | fi
45 | done
46 | done
47 |
48 | # 创建 JSON 格式的输出
49 | json=$(printf "{\"config\":[%s]}" "$(IFS=,; echo "${allFolderObjects[*]}")")
50 |
51 | # 输出最终的 JSON 结果
52 | echo "matrix=$json" >> $GITHUB_OUTPUT
53 |
--------------------------------------------------------------------------------
/minecraft/minecraft-origin/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/minecraft/origin/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.github.johnrengelman.shadow' version '8.1.1'
3 | id 'org.jetbrains.kotlin.jvm' version "${kotlin_version}"
4 | }
5 |
6 | def getVersionFromFile(String fileName) {
7 | def versionFile = file(fileName)
8 | if (versionFile.exists()) {
9 | return versionFile.text.trim()
10 | } else {
11 | throw new Exception("File not found: ${versionFile.absolutePath}") as Throwable
12 | }
13 | }
14 |
15 | def tool_version = getVersionFromFile('../../tool_version.txt')
16 |
17 | def mod_version = getVersionFromFile('../../version.txt')
18 |
19 | group = mod_group_id
20 | version = mod_version
21 |
22 | repositories {
23 | mavenLocal()
24 | mavenCentral()
25 | maven {
26 | url = uri(maven_repository_url)
27 | credentials {
28 | username = System.getenv("USERNAME")
29 | password = System.getenv("PACKAGE_READ_ONLY_TOKEN")
30 | }
31 | }
32 | }
33 |
34 | dependencies {
35 | implementation "com.github.theword.queqiao:queqiao-tool:${tool_version}"
36 | implementation "commons-io:commons-io:${project.commons_io_version}"
37 | implementation "org.slf4j:slf4j-simple:${slf4j_version}"
38 | implementation "com.google.code.gson:gson:${gson_version}"
39 | implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
40 |
41 | testImplementation 'org.jetbrains.kotlin:kotlin-test'
42 | }
43 |
44 | test {
45 | useJUnitPlatform()
46 | testLogging {
47 | events "passed", "skipped", "failed"
48 | }
49 | }
50 |
51 | kotlin {
52 | jvmToolchain(8)
53 | }
54 |
55 | shadowJar {
56 | archiveBaseName.set("${mod_name}-minecraft+origin")
57 | archiveClassifier.set("")
58 | destinationDirectory.set(file("../../QueQiao-jar/${version}"))
59 | manifest {
60 | attributes(
61 | 'Main-Class': 'com.github.theword.queqiao.QueQiao' // 替换为你的主类路径
62 | )
63 | }
64 | dependencies {
65 | include(dependency("com.github.theword.queqiao:queqiao-tool:${tool_version}"))
66 | include(dependency("org.java-websocket:Java-WebSocket:${java_websocket_version}"))
67 | include(dependency("org.yaml:snakeyaml:${snakeyaml_version}"))
68 | include(dependency("org.slf4j:slf4j-api:${slf4j_version}"))
69 | include(dependency("org.slf4j:slf4j-simple:${slf4j_version}"))
70 | include(dependency("com.google.code.gson:gson:${gson_version}"))
71 | include(dependency("commons-io:commons-io:${commons_io_version}"))
72 | include(dependency("org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"))
73 | }
74 | mergeServiceFiles()
75 | }
76 |
77 | tasks.build {
78 | dependsOn shadowJar
79 | }
--------------------------------------------------------------------------------
/minecraft/origin/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin.code.style=official
2 | org.gradle.jvmargs=-Xmx3G
3 | org.gradle.daemon=false
4 | # Mod Properties
5 | mod_id=queqiao
6 | mod_name=QueQiao
7 | mod_license=MIT
8 | mod_group_id=com.github.theword.queqiao
9 | mod_authors=17TheWord
10 | mod_description=Connect to nonebot2.
11 | # Lib Properties
12 | gson_version=2.10.1
13 | slf4j_version=1.7.36
14 | kotlin_version=2.0.21
15 | snakeyaml_version=2.2
16 | lombok_version=1.18.30
17 | commons_io_version=2.15.1
18 | java_websocket_version=1.5.3
19 | jetbrains_annotations_version=24.0.0
20 | maven_repository_url=https://maven.pkg.github.com/17TheWord/QueQiaoTool
--------------------------------------------------------------------------------
/minecraft/origin/settings.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
3 | }
4 | rootProject.name = 'minecraft-origin'
5 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/EventProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao
2 |
3 | import com.github.theword.queqiao.event.minecraft.MinecraftPlayer
4 | import com.github.theword.queqiao.event.minecraft.MinecraftPlayerChatEvent
5 | import com.github.theword.queqiao.event.minecraft.MinecraftPlayerJoinEvent
6 | import com.github.theword.queqiao.event.minecraft.MinecraftPlayerQuitEvent
7 | import com.github.theword.queqiao.tool.utils.Tool
8 |
9 | class EventProcessor {
10 | /**
11 | * 监听玩家聊天
12 | */
13 | fun onPlayerChat(playerName: String, message: String) {
14 | if (!Tool.config.subscribeEvent.isPlayerChat) return
15 | val player = MinecraftPlayer(playerName)
16 | val event = MinecraftPlayerChatEvent("", player, message)
17 | Tool.sendWebsocketMessage(event)
18 | }
19 |
20 |
21 | /**
22 | * 监听玩家加入事件
23 | */
24 | fun onPlayerJoin(playerName: String) {
25 | if (!Tool.config.subscribeEvent.isPlayerJoin) return
26 | val player = MinecraftPlayer(playerName)
27 | val event = MinecraftPlayerJoinEvent(player)
28 | Tool.sendWebsocketMessage(event)
29 | }
30 |
31 | /**
32 | * 监听玩家离开事件
33 | */
34 | fun onPlayerQuit(playerName: String) {
35 | if (!Tool.config.subscribeEvent.isPlayerQuit) return
36 | val player = MinecraftPlayer(playerName)
37 | val event = MinecraftPlayerQuitEvent(player)
38 | Tool.sendWebsocketMessage(event)
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/QueQiao.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao
2 |
3 | import com.github.theword.queqiao.config.Config
4 | import com.github.theword.queqiao.handle.HandleApiImpl
5 | import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl
6 | import com.github.theword.queqiao.tool.constant.BaseConstant
7 | import com.github.theword.queqiao.tool.constant.ServerTypeConstant
8 | import com.github.theword.queqiao.tool.utils.Tool.*
9 | import com.github.theword.queqiao.utils.FileWatcher
10 | import com.github.theword.queqiao.utils.LineProcessor
11 |
12 | object QueQiao {
13 | @JvmStatic
14 | fun main(args: Array) {
15 | initTool(
16 | true,
17 | BaseConstant.UNKNOWN,
18 | ServerTypeConstant.ORIGIN,
19 | HandleApiImpl(),
20 | HandleCommandReturnMessageImpl()
21 | )
22 | websocketManager.startWebsocketOnServerStart()
23 | val config = Config()
24 | FileWatcher.fileListen(config.logPath, LineProcessor(config, EventProcessor()))
25 | }
26 | }
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/config/Config.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.config
2 |
3 | import com.github.theword.queqiao.tool.config.CommonConfig
4 | import com.github.theword.queqiao.tool.utils.Tool.logger
5 |
6 |
7 | class Config : CommonConfig() {
8 | var logPath: String = ".\\logs\\latest.log"
9 | var chatRegexSet: Set = emptySet()
10 | var joinRegexSet: Set = emptySet()
11 | var quitRegexSet: Set = emptySet()
12 |
13 | init {
14 | readConfigFile("", "regex.yml")
15 | }
16 |
17 | override fun loadConfigValues(configMap: Map) {
18 | logPath = configMap["log_path"] as String? ?: "./logs/latest.log"
19 | chatRegexSet = convertToRegexConfigSet(configMap, "chat_regex")
20 | joinRegexSet = convertToRegexConfigSet(configMap, "join_regex")
21 | quitRegexSet = convertToRegexConfigSet(configMap, "quit_regex")
22 | }
23 |
24 | private fun convertToRegexConfigSet(configMap: Map, key: String): Set {
25 | val value = configMap[key]
26 | if (value !is List<*>) {
27 | logger.warn("配置项 {} 不是列表类型,将使用空集合。", key)
28 | return emptySet()
29 | }
30 | return value.mapNotNull { item ->
31 | if (item is Map<*, *>) {
32 | val regex = item["regex"] as? String
33 | val playerGroup = item["player_group"] as? Int
34 | val messageGroup = item["message_group"] as? Int
35 | if (regex != null && playerGroup != null) {
36 | RegexConfig(regex, playerGroup, messageGroup)
37 | } else {
38 | logger.warn("配置项 {} 中包含无效的 Map,将跳过该值。", key)
39 | null
40 | }
41 | } else {
42 | logger.warn("配置项 {} 中包含非Map类型,将跳过该值。", key)
43 | null
44 | }
45 | }.toSet()
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/config/RegexConfig.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.config
2 |
3 | import java.util.regex.Pattern
4 |
5 | class RegexConfig(
6 | regex: String,
7 | val playerGroup: Int,
8 | val messageGroup: Int?
9 | ) {
10 | val pattern: Pattern = Pattern.compile(regex)
11 | }
12 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/event/minecraft/MinecraftPlayer.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.minecraft
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayer
4 |
5 | data class MinecraftPlayer(private val nickname: String) : BasePlayer(nickname, null)
6 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/event/minecraft/MinecraftPlayerChatEvent.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.minecraft
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerChatEvent
4 |
5 | data class MinecraftPlayerChatEvent(
6 | private val messageId: String = "", private val player: MinecraftPlayer, private val message: String
7 | ) : BasePlayerChatEvent("MinecraftPlayerChatEvent", messageId, player, message)
8 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/event/minecraft/MinecraftPlayerJoinEvent.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.minecraft
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerJoinEvent
4 |
5 | data class MinecraftPlayerJoinEvent(
6 | private val player: MinecraftPlayer
7 | ) : BasePlayerJoinEvent("MinecraftPlayerJoinEvent", player)
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/event/minecraft/MinecraftPlayerQuitEvent.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.minecraft
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerQuitEvent
4 |
5 | data class MinecraftPlayerQuitEvent(
6 | private val player: MinecraftPlayer
7 | ) : BasePlayerQuitEvent("MinecraftPlayerQuitEvent", player)
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/handle/HandleApiImpl.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle
2 |
3 | import com.github.theword.queqiao.tool.handle.HandleApiService
4 | import com.github.theword.queqiao.tool.payload.MessageSegment
5 | import com.github.theword.queqiao.tool.payload.TitlePayload
6 | import com.github.theword.queqiao.tool.response.PrivateMessageResponse
7 | import java.util.UUID
8 |
9 |
10 | class HandleApiImpl : HandleApiService {
11 | override fun handleBroadcastMessage(list: List) {
12 | }
13 |
14 | override fun handleSendTitleMessage(titlePayload: TitlePayload) {
15 | }
16 |
17 | override fun handleSendActionBarMessage(list: List) {
18 | }
19 |
20 | override fun handleSendPrivateMessage(s: String, uuid: UUID, list: List): PrivateMessageResponse {
21 | return PrivateMessageResponse.of(null, "该接口不可用")
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/handle/HandleCommandReturnMessageImpl.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle
2 |
3 | import com.github.theword.queqiao.tool.handle.HandleCommandReturnMessageService
4 |
5 | class HandleCommandReturnMessageImpl : HandleCommandReturnMessageService {
6 | override fun handleCommandReturnMessage(o: Any, s: String) {
7 | }
8 |
9 | override fun hasPermission(o: Any, s: String): Boolean {
10 | return false
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/kotlin/com/github/theword/queqiao/utils/LineProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils
2 |
3 | import com.github.theword.queqiao.EventProcessor
4 | import com.github.theword.queqiao.config.Config
5 | import com.github.theword.queqiao.tool.utils.Tool.logger
6 | import com.github.theword.queqiao.tool.utils.Tool.config
7 |
8 | class LineProcessor(private val regexConfig: Config, private val eventProcessor: EventProcessor) {
9 |
10 | fun processLine(line: String) {
11 | logger.debug("LogWatcher: $line")
12 | if (config.subscribeEvent.isPlayerChat)
13 | regexConfig.chatRegexSet.forEach { chatConfig ->
14 | val chatMatcher = chatConfig.pattern.matcher(line)
15 | if (chatMatcher.find()) {
16 | val playerName = chatMatcher.group(chatConfig.playerGroup)
17 | val message = chatMatcher.group(chatConfig.messageGroup!!)
18 | if (message != null && message.isNotEmpty()) {
19 | logger.info("[Chat] $playerName: $message")
20 | eventProcessor.onPlayerChat(playerName, message)
21 | }
22 | return
23 | }
24 | }
25 |
26 | if (config.subscribeEvent.isPlayerJoin)
27 | regexConfig.joinRegexSet.forEach { joinConfig ->
28 | val joinMatcher = joinConfig.pattern.matcher(line)
29 | if (joinMatcher.find()) {
30 | logger.info("[Join] $line")
31 | val playerName = joinMatcher.group(joinConfig.playerGroup)
32 | eventProcessor.onPlayerJoin(playerName)
33 | return
34 | }
35 | }
36 |
37 | if (config.subscribeEvent.isPlayerQuit)
38 | regexConfig.quitRegexSet.forEach { quitConfig ->
39 | val quitMatcher = quitConfig.pattern.matcher(line)
40 | if (quitMatcher.find()) {
41 | logger.info("[Quit] $line")
42 | val playerName = quitMatcher.group(quitConfig.playerGroup)
43 | eventProcessor.onPlayerQuit(playerName)
44 | return
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/minecraft/origin/src/main/resources/regex.yml:
--------------------------------------------------------------------------------
1 | log_path: ".\\logs\\latest.log"
2 |
3 | # 以下正则均为原版示例
4 |
5 | chat_regex:
6 | - regex: "(.*)]:(.*)<(.*)> (.*)"
7 | player_group: 3
8 | message_group: 4
9 |
10 | join_regex:
11 | - regex: "Server thread/INFO]: (.*) joined the game"
12 | player_group: 1
13 |
14 | quit_regex:
15 | - regex: "Server thread/INFO]: (.*) left the game"
16 | player_group: 1
17 |
--------------------------------------------------------------------------------
/neoforge/neoforge-1.21.1/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/neoforge/origin/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx3G
2 | org.gradle.daemon=true
3 | org.gradle.parallel=true
4 | org.gradle.caching=true
5 | org.gradle.configuration-cache=true
6 | minecraft_version=1.21.1
7 | minecraft_version_range=[1.21.1,1.22)
8 | neo_version=21.1.117
9 | neo_version_range=[21,)
10 | loader_version_range=[4,)
11 | parchment_minecraft_version=1.21.1
12 | parchment_mappings_version=2024.11.17
13 | # Mod Properties
14 | mod_id=queqiao
15 | mod_name=QueQiao
16 | mod_license=MIT
17 | mod_group_id=com.github.theword.queqiao
18 | mod_authors=17TheWord
19 | mod_description=A server plugin/mod that distributes Minecraft server player events in JSON format via Websocket.
20 | # JDK Version
21 | java_version=21
22 | # Lib Properties
23 | gson_version=2.10.1
24 | slf4j_version=1.7.36
25 | lombok_version=1.18.30
26 | snakeyaml_version=2.2
27 | junit_jupiter_version=5.11.4
28 | java_websocket_version=1.5.3
29 | maven_repository_url=https://maven.pkg.github.com/17TheWord/QueQiaoTool
--------------------------------------------------------------------------------
/neoforge/origin/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | mavenLocal()
4 | gradlePluginPortal()
5 | maven { url = 'https://maven.neoforged.net/releases' }
6 | }
7 | }
8 |
9 | plugins {
10 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
11 | }
12 |
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/Queqiao.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | import com.github.theword.queqiao.handle.HandleApiImpl;
4 | import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl;
5 | import com.github.theword.queqiao.tool.constant.BaseConstant;
6 | import com.github.theword.queqiao.tool.constant.ServerTypeConstant;
7 | import net.minecraft.server.MinecraftServer;
8 | import net.neoforged.bus.api.SubscribeEvent;
9 | import net.neoforged.fml.common.Mod;
10 | import net.neoforged.neoforge.common.NeoForge;
11 | import net.neoforged.neoforge.event.server.ServerStartingEvent;
12 | import net.neoforged.neoforge.event.server.ServerStoppingEvent;
13 |
14 | import static com.github.theword.queqiao.tool.utils.Tool.initTool;
15 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
16 |
17 | @Mod(BaseConstant.MOD_ID)
18 | public class Queqiao {
19 | public static MinecraftServer minecraftServer;
20 |
21 | public Queqiao() {
22 | NeoForge.EVENT_BUS.register(this);
23 | NeoForge.EVENT_BUS.register(new EventProcessor());
24 | }
25 |
26 | @SubscribeEvent
27 | public void onServerStarting(ServerStartingEvent event) {
28 | minecraftServer = event.getServer();
29 | initTool(true, minecraftServer.getServerVersion(), ServerTypeConstant.NEOFORGE, new HandleApiImpl(), new HandleCommandReturnMessageImpl());
30 | websocketManager.startWebsocketOnServerStart();
31 | }
32 |
33 | @SubscribeEvent
34 | public void onServerStopping(ServerStoppingEvent event) {
35 | websocketManager.stopWebsocketByServerClose();
36 | }
37 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/CommandExecutor.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 |
4 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
5 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
6 | import com.github.theword.queqiao.command.subCommand.client.ReconnectAllCommand;
7 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
8 | import com.github.theword.queqiao.tool.constant.BaseConstant;
9 | import com.mojang.brigadier.Command;
10 | import net.minecraft.commands.Commands;
11 | import net.neoforged.bus.api.SubscribeEvent;
12 | import net.neoforged.fml.common.EventBusSubscriber;
13 | import net.neoforged.neoforge.event.RegisterCommandsEvent;
14 | import net.neoforged.neoforge.server.command.ConfigCommand;
15 |
16 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
17 |
18 | @EventBusSubscriber(modid = BaseConstant.MOD_ID)
19 | public class CommandExecutor {
20 |
21 | @SubscribeEvent
22 | public static void onCommandRegister(RegisterCommandsEvent event) {
23 | event.getDispatcher().register(
24 | Commands.literal(BaseConstant.COMMAND_HEADER)
25 | .requires(source -> source.hasPermission(2))
26 | .executes(context -> new HelpCommand().onCommand(context))
27 | .then(Commands.literal("help")
28 | .executes(context -> new HelpCommand().onCommand(context))
29 | )
30 | .then(Commands.literal("reload")
31 | .executes(context -> new ReloadCommand().onCommand(context))
32 | )
33 | .then(Commands.literal("client")
34 | .then(Commands.literal("reconnect")
35 | .executes(context -> new ReconnectCommand().onCommand(context))
36 | .then(Commands.literal("all")
37 | .executes(context -> new ReconnectAllCommand().onCommand(context)))
38 | )
39 | ).then(Commands.literal("server")
40 | .executes(context -> {
41 | // TODO Websocket Server Command
42 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "Server command is not supported");
43 | return Command.SINGLE_SUCCESS;
44 | })
45 | )
46 | );
47 | ConfigCommand.register(event.getDispatcher());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/CommandManager.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
4 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
5 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
6 | import lombok.Getter;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | @Getter
12 | public class CommandManager {
13 |
14 | private final List subCommandList = new ArrayList<>();
15 |
16 | public CommandManager() {
17 | subCommandList.add(new HelpCommand());
18 | subCommandList.add(new ReloadCommand());
19 | subCommandList.add(new ReconnectCommand());
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/NeoForgeSubCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.mojang.brigadier.context.CommandContext;
4 | import net.minecraft.commands.CommandSourceStack;
5 |
6 | public interface NeoForgeSubCommand {
7 |
8 | String getName();
9 | String getDescription();
10 | String getUsage();
11 |
12 | int onCommand(CommandContext context);
13 | }
14 |
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/HelpCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.CommandManager;
4 | import com.github.theword.queqiao.command.NeoForgeSubCommand;
5 | import com.github.theword.queqiao.tool.command.subCommand.HelpCommandAbstract;
6 | import com.mojang.brigadier.Command;
7 | import com.mojang.brigadier.context.CommandContext;
8 |
9 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
10 |
11 |
12 | public class HelpCommand extends HelpCommandAbstract implements NeoForgeSubCommand {
13 |
14 | @Override
15 | public int onCommand(CommandContext context) {
16 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
17 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "-------------------");
18 | for (NeoForgeSubCommand forgeSubCommand : new CommandManager().getSubCommandList()) {
19 | handleCommandReturnMessageService.handleCommandReturnMessage(context, forgeSubCommand.getUsage() + "---" + forgeSubCommand.getDescription());
20 | }
21 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "-------------------");
22 | return Command.SINGLE_SUCCESS;
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.NeoForgeSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.ReloadCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 |
8 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
9 |
10 |
11 | public class ReloadCommand extends ReloadCommandAbstract implements NeoForgeSubCommand {
12 |
13 | @Override
14 | public int onCommand(CommandContext context) {
15 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
16 | execute(context, true);
17 | return Command.SINGLE_SUCCESS;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectAllCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.NeoForgeSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 |
8 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
9 |
10 |
11 | public class ReconnectAllCommand extends ReconnectCommandAbstract implements NeoForgeSubCommand {
12 |
13 | @Override
14 | public int onCommand(CommandContext context) {
15 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
16 | execute(context, true);
17 | return Command.SINGLE_SUCCESS;
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.NeoForgeSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 |
8 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
9 |
10 |
11 | public class ReconnectCommand extends ReconnectCommandAbstract implements NeoForgeSubCommand {
12 |
13 | @Override
14 | public int onCommand(CommandContext context) {
15 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
16 | execute(context, false);
17 | return Command.SINGLE_SUCCESS;
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgeAdvancementEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.event.neoforge.dto.advancement.NeoForgeAdvancement;
4 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
5 |
6 | public class NeoForgeAdvancementEvent extends BasePlayerAdvancementEvent {
7 | public NeoForgeAdvancementEvent(NeoForgeServerPlayer player, NeoForgeAdvancement advancement) {
8 | super("NeoForgeAdvancementEvent", player, advancement);
9 | }
10 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgeCommandEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BaseCommandEvent;
4 |
5 | public class NeoForgeCommandEvent extends BaseCommandEvent {
6 | public NeoForgeCommandEvent(String messageId, NeoForgeServerPlayer player, String command) {
7 | super("NeoCommandEvent", messageId, player, command);
8 | }
9 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgePlayerDeathEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerDeathEvent;
4 |
5 | public class NeoForgePlayerDeathEvent extends BasePlayerDeathEvent {
6 |
7 | public NeoForgePlayerDeathEvent(String messageId, NeoForgeServerPlayer player, String message) {
8 | super("NeoPlayerDeathEvent", messageId, player, message);
9 | }
10 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgePlayerLoggedInEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerJoinEvent;
4 |
5 | public final class NeoForgePlayerLoggedInEvent extends BasePlayerJoinEvent {
6 | public NeoForgePlayerLoggedInEvent(NeoForgeServerPlayer player) {
7 | super("NeoPlayerLoggedInEvent", player);
8 | }
9 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgePlayerLoggedOutEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerQuitEvent;
4 |
5 | public final class NeoForgePlayerLoggedOutEvent extends BasePlayerQuitEvent {
6 | public NeoForgePlayerLoggedOutEvent(NeoForgeServerPlayer player) {
7 | super("NeoPlayerLoggedOutEvent", player);
8 | }
9 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgeServerChatEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerChatEvent;
4 |
5 | public final class NeoForgeServerChatEvent extends BasePlayerChatEvent {
6 | public NeoForgeServerChatEvent(String messageId, NeoForgeServerPlayer player, String message) {
7 | super("NeoServerChatEvent", messageId, player, message);
8 | }
9 |
10 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/NeoForgeServerPlayer.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayer;
4 | import com.google.gson.annotations.SerializedName;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 |
10 | @Data
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @EqualsAndHashCode(callSuper = true)
14 | public class NeoForgeServerPlayer extends BasePlayer {
15 |
16 | @SerializedName("display_name")
17 | private String displayName;
18 |
19 | @SerializedName("ip_address")
20 | private String ipAddress;
21 |
22 | private float speed;
23 | @SerializedName("flying_speed")
24 | private float flyingSpeed;
25 |
26 | @SerializedName("is_flying")
27 | private boolean isFlying;
28 |
29 | @SerializedName("is_swimming")
30 | private boolean isSwimming;
31 | @SerializedName("is_sleeping")
32 | private boolean isSleeping;
33 | @SerializedName("is_blocking")
34 | private boolean isBlocking;
35 |
36 | @SerializedName("game_mode")
37 | private String gameMode;
38 |
39 | @SerializedName("block_x")
40 | private int blockX;
41 | @SerializedName("block_y")
42 | private int blockY;
43 | @SerializedName("block_z")
44 | private int blockZ;
45 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/dto/advancement/AdvancementRewardsDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.util.List;
8 |
9 | @Data
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class AdvancementRewardsDTO {
13 |
14 | private Integer experience;
15 |
16 | /**
17 | * Original type: net.minecraft.world.level.storage.loot.LootTable
18 | *
19 | * getLootTableId().toString()
20 | */
21 | private List loot;
22 |
23 | /**
24 | * Original type: net.minecraft.resources.ResourceLocation
25 | *
26 | * toString()
27 | */
28 | private List recipes;
29 | }
30 |
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/dto/advancement/DisplayInfoDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class DisplayInfoDTO {
11 |
12 | /**
13 | * Original type: net.minecraft.network.chat.Component
14 | * toString()
15 | */
16 | private String title;
17 |
18 | /**
19 | * Original type: net.minecraft.network.chat.Component
20 | * toString()
21 | */
22 | private String description;
23 |
24 | private ItemStackDTO icon;
25 |
26 | /**
27 | * Original type: net.minecraft.util.ResourceLocation
28 | * toString()
29 | */
30 | private String background;
31 |
32 | /**
33 | * Original type: net.minecraft.advancements.FrameType
34 | * getName()
35 | */
36 | private String frame;
37 |
38 | private Boolean showToast;
39 |
40 | private Boolean announceToChat;
41 |
42 | private Boolean hidden;
43 |
44 | private Float x;
45 |
46 | private Float y;
47 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/dto/advancement/ItemStackDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class ItemStackDTO {
11 | private int count;
12 | private int popTime;
13 |
14 | /**
15 | * Original type: net.minecraft.item.Item
16 | *
17 | * toString()
18 | */
19 | private String item;
20 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/event/neoforge/dto/advancement/NeoForgeAdvancement.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.neoforge.dto.advancement;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.NoArgsConstructor;
8 |
9 |
10 | @Data
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @EqualsAndHashCode(callSuper = true)
14 | public class NeoForgeAdvancement extends BasePlayerAdvancementEvent.BaseAdvancement {
15 | /**
16 | * Original type: net.minecraft.resources.ResourceLocation
17 | * toString()
18 | */
19 | private String parent;
20 |
21 | private DisplayInfoDTO display;
22 |
23 | /**
24 | * Original type: net.minecraft.advancements.AdvancementRewards
25 | * serializeToJson()
26 | */
27 | private AdvancementRewardsDTO rewards;
28 |
29 | /**
30 | * Original type: net.minecraft.util.ResourceLocation
31 | * toString()
32 | */
33 | private String name;
34 |
35 | private Boolean sendsTelemetryEvent;
36 | }
37 |
--------------------------------------------------------------------------------
/neoforge/origin/src/main/java/com/github/theword/queqiao/handle/HandleCommandReturnMessageImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle;
2 |
3 | import com.github.theword.queqiao.tool.constant.BaseConstant;
4 | import com.github.theword.queqiao.tool.handle.HandleCommandReturnMessageService;
5 | import com.mojang.brigadier.context.CommandContext;
6 | import net.minecraft.network.chat.contents.PlainTextContents;
7 |
8 | public class HandleCommandReturnMessageImpl implements HandleCommandReturnMessageService {
9 |
10 | @Override
11 | @SuppressWarnings("unchecked")
12 | public void handleCommandReturnMessage(Object object, String message) {
13 | CommandContext context = (CommandContext) object;
14 | context.getSource().sendSystemMessage(net.minecraft.network.chat.MutableComponent.create(new PlainTextContents.LiteralContents(message)));
15 | }
16 |
17 | /**
18 | * 判断发送者是否有权执行命令
19 | * MOD端中无权限节点,权限等级为2
20 | *
21 | * @param object 命令返回者
22 | * @param node 权限节点
23 | * @return boolean 是否有权限
24 | */
25 | @Override
26 | @SuppressWarnings("unchecked")
27 | public boolean hasPermission(Object object, String node) {
28 | CommandContext context = (CommandContext) object;
29 | if (context.getSource().hasPermission(BaseConstant.MOD_PERMISSION_LEVEL)) return true;
30 | handleCommandReturnMessage(object, "您没有权限执行此命令");
31 | return false;
32 | }
33 | }
--------------------------------------------------------------------------------
/neoforge/origin/src/main/resources/assets/queqiao/lang/en_us.json:
--------------------------------------------------------------------------------
1 | {
2 | "itemGroup.queqiao": "Example Mod Tab",
3 | "block.queqiao.example_block": "Example Block",
4 | "item.queqiao.example_item": "Example Item"
5 | }
6 |
--------------------------------------------------------------------------------
/neoforge/origin/src/test/java/com/github/theword/queqiao/utils/ParseJsonToEventImplTest.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils;
2 |
3 |
4 | class ParseJsonToEventImplTest {
5 |
6 | }
--------------------------------------------------------------------------------
/origin/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/17TheWord/QueQiao/d8a83d46256c45513932aead79911c346e4d8ac3/origin/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/origin/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/spigot/origin/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx3G
2 | org.gradle.daemon=false
3 | # Mod Properties
4 | mod_id=queqiao
5 | mod_name=QueQiao
6 | mod_license=MIT
7 | mod_group_id=com.github.theword.queqiao
8 | mod_authors=17TheWord
9 | mod_description=Connect to nonebot2.
10 | # Lib Properties
11 | lombok_version=1.18.30
12 | slf4j_version=1.7.36
13 | snakeyaml_version=2.2
14 | junit_jupiter_version=5.11.4
15 | java_websocket_version=1.5.3
16 | jetbrains_annotations_version=24.0.0
17 | maven_repository_url=https://maven.pkg.github.com/17TheWord/QueQiaoTool
18 | # JDK Version
19 | # IF spigot-1.12.2
20 | #java_version=8
21 | # ELSE IF >= spigot-1.20.5
22 | #java_version=21
23 | # ELSE
24 | #java_version=17
25 | # END IF
26 | # Spigot Properties
27 | # IF spigot-1.12.2
28 | #api_version=1.12.2
29 | #spigot_version=1.12.2-R0.1-SNAPSHOT
30 | # ELSE
31 | #api_version=1.13
32 | #spigot_version=1.20.1-R0.1-SNAPSHOT
33 | # END IF
34 | #
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/QueQiao.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | import com.github.theword.queqiao.command.CommandExecutor;
4 | import com.github.theword.queqiao.handle.HandleApiImpl;
5 | import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl;
6 | import com.github.theword.queqiao.tool.constant.BaseConstant;
7 | import com.github.theword.queqiao.tool.constant.ServerTypeConstant;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.command.PluginCommand;
10 | import org.bukkit.plugin.java.JavaPlugin;
11 |
12 | import static com.github.theword.queqiao.tool.utils.Tool.initTool;
13 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
14 |
15 | public final class QueQiao extends JavaPlugin {
16 |
17 | public static JavaPlugin instance;
18 |
19 | @Override
20 | public void onEnable() {
21 | instance = this;
22 | initTool(
23 | false,
24 | instance.getServer().getVersion(),
25 | ServerTypeConstant.SPIGOT,
26 | new HandleApiImpl(),
27 | new HandleCommandReturnMessageImpl()
28 | );
29 | websocketManager.startWebsocketOnServerStart();
30 | Bukkit.getPluginManager().registerEvents(new EventProcessor(), this);
31 |
32 | PluginCommand command = getCommand(BaseConstant.COMMAND_HEADER);
33 | if (command != null) command.setExecutor(new CommandExecutor());
34 | }
35 |
36 | @Override
37 | public void onDisable() {
38 | websocketManager.stopWebsocketByServerClose();
39 | }
40 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/CommandExecutor.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
4 | import com.github.theword.queqiao.tool.constant.BaseConstant;
5 | import org.bukkit.command.Command;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.command.TabExecutor;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 |
14 | public class CommandExecutor implements TabExecutor {
15 | private final CommandManager commandManager = new CommandManager();
16 |
17 | @Override
18 | public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
19 | if (args.length == 0) {
20 | return new HelpCommand().onCommand(commandSender, args);
21 | } else {
22 | for (SpigotSubCommand subCommand : commandManager.getSubCommandList()) {
23 | if (subCommand.getName().equalsIgnoreCase(args[0])) {
24 | return subCommand.onCommand(commandSender, args);
25 | }
26 | }
27 | }
28 | return false;
29 | }
30 |
31 | @Override
32 | public List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
33 | if (command.getName().equalsIgnoreCase(BaseConstant.COMMAND_HEADER)) {
34 | if (args.length == 1) {
35 | List commandList = new ArrayList<>();
36 | commandManager.getSubCommandList().forEach(subCommand -> {
37 | if (subCommand.getPrefix() == null) {
38 | commandList.add(subCommand.getName());
39 | }
40 | });
41 | return commandList;
42 | } else if (args.length == 2) {
43 | for (SpigotSubCommand subCommand : commandManager.getSubCommandList()) {
44 | if (subCommand.getName().equalsIgnoreCase(args[0])) {
45 | return subCommand.getSubCommands(commandSender, args);
46 | }
47 | }
48 | } else if (args.length == 3) {
49 | for (SpigotSubCommand subCommand : commandManager.getSubCommandList()) {
50 | if (subCommand.getName().equalsIgnoreCase(args[1])) {
51 | return subCommand.getSubCommands(commandSender, args);
52 | }
53 | }
54 | }
55 | }
56 | return new ArrayList<>();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/CommandManager.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 |
4 | import com.github.theword.queqiao.command.subCommand.ClientCommand;
5 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
6 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
7 | import com.github.theword.queqiao.command.subCommand.ServerCommand;
8 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class CommandManager {
14 | List subCommandList = new ArrayList<>();
15 |
16 |
17 | public CommandManager() {
18 | subCommandList.add(new HelpCommand());
19 | subCommandList.add(new ReloadCommand());
20 | subCommandList.add(new ClientCommand());
21 | subCommandList.add(new ServerCommand());
22 |
23 | subCommandList.add(new ReconnectCommand());
24 | }
25 |
26 | public List getSubCommandList() {
27 | return subCommandList;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/SpigotSubCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.tool.command.SubCommand;
4 | import org.bukkit.command.CommandSender;
5 |
6 | import java.util.List;
7 |
8 | public interface SpigotSubCommand extends SubCommand {
9 |
10 | boolean onCommand(CommandSender commandSender, String[] args);
11 |
12 | List getSubCommands(CommandSender commandSender, String[] args);
13 |
14 | String getPrefix();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/subCommand/ClientCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.SpigotSubCommand;
4 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
5 | import com.github.theword.queqiao.tool.command.subCommand.ClientCommandAbstract;
6 | import org.bukkit.command.CommandSender;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
12 |
13 | public class ClientCommand extends ClientCommandAbstract implements SpigotSubCommand {
14 | @Override
15 | public boolean onCommand(CommandSender commandSender, String[] args) {
16 | if (!handleCommandReturnMessageService.hasPermission(commandSender, getPermissionNode())) return false;
17 | if (args.length == 0) {
18 | commandSender.sendMessage("§c请输入子命令");
19 | return false;
20 | } else if (args[1].equalsIgnoreCase("reconnect")) {
21 | return new ReconnectCommand().onCommand(commandSender, args);
22 | }
23 | return false;
24 | }
25 |
26 | @Override
27 | public List getSubCommands(CommandSender commandSender, String[] args) {
28 | return new ArrayList() {{
29 | add("reconnect");
30 | add("list");
31 | }};
32 | }
33 |
34 | @Override
35 | public String getPrefix() {
36 | return null;
37 | }
38 |
39 | @Override
40 | public String getName() {
41 | return "client";
42 | }
43 |
44 | @Override
45 | public String getDescription() {
46 | return "Websocket Client 的命令";
47 | }
48 |
49 | @Override
50 | public String getUsage() {
51 | return "使用:/mcqq client ";
52 | }
53 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/subCommand/HelpCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 |
4 | import com.github.theword.queqiao.command.CommandManager;
5 | import com.github.theword.queqiao.command.SpigotSubCommand;
6 | import com.github.theword.queqiao.tool.command.SubCommand;
7 | import com.github.theword.queqiao.tool.command.subCommand.HelpCommandAbstract;
8 | import org.bukkit.command.CommandSender;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
14 |
15 | public class HelpCommand extends HelpCommandAbstract implements SpigotSubCommand {
16 | @Override
17 | public boolean onCommand(CommandSender commandSender, String[] args) {
18 | if (!handleCommandReturnMessageService.hasPermission(commandSender, getPermissionNode())) return false;
19 | commandSender.sendMessage("-------------------");
20 | for (SubCommand subCommand : new CommandManager().getSubCommandList()) {
21 | commandSender.sendMessage(subCommand.getUsage() + "---" + subCommand.getDescription());
22 | }
23 | commandSender.sendMessage("-------------------");
24 | return true;
25 | }
26 |
27 | @Override
28 | public List getSubCommands(CommandSender commandSender, String[] args) {
29 | return new ArrayList<>();
30 | }
31 |
32 | @Override
33 | public String getPrefix() {
34 | return null;
35 | }
36 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/subCommand/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.SpigotSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.ReloadCommandAbstract;
5 | import org.bukkit.command.CommandSender;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
11 |
12 |
13 | public class ReloadCommand extends ReloadCommandAbstract implements SpigotSubCommand {
14 | @Override
15 | public boolean onCommand(CommandSender commandSender, String[] args) {
16 | if (!handleCommandReturnMessageService.hasPermission(commandSender, getPermissionNode())) return false;
17 | execute(commandSender, false);
18 | return true;
19 | }
20 |
21 | @Override
22 | public List getSubCommands(CommandSender commandSender, String[] args) {
23 | return new ArrayList<>();
24 | }
25 |
26 | @Override
27 | public String getPrefix() {
28 | return null;
29 | }
30 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/subCommand/ServerCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.SpigotSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.ServerCommandAbstract;
5 | import org.bukkit.command.CommandSender;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | public class ServerCommand extends ServerCommandAbstract implements SpigotSubCommand {
11 | @Override
12 | public boolean onCommand(CommandSender commandSender, String[] args) {
13 | commandSender.sendMessage("Server commands are not implemented yet.");
14 | return false;
15 | }
16 |
17 | @Override
18 | public List getSubCommands(CommandSender commandSender, String[] args) {
19 | return new ArrayList() {
20 | };
21 | }
22 |
23 | @Override
24 | public String getPrefix() {
25 | return null;
26 | }
27 |
28 | @Override
29 | public String getName() {
30 | return "server";
31 | }
32 |
33 | @Override
34 | public String getDescription() {
35 | return "Websocket Client 的命令";
36 | }
37 |
38 | @Override
39 | public String getUsage() {
40 | return "使用:/mcqq client ";
41 | }
42 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.SpigotSubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import org.bukkit.command.CommandSender;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
11 |
12 |
13 | public class ReconnectCommand extends ReconnectCommandAbstract implements SpigotSubCommand {
14 |
15 | @Override
16 | public boolean onCommand(CommandSender commandSender, String[] args) {
17 | if (args.length == 2) {
18 | if (args[1].equalsIgnoreCase("reconnect")) {
19 | execute(commandSender, false);
20 | return true;
21 | }
22 | } else if (args.length == 3) {
23 | if (args[2].equalsIgnoreCase("all")) {
24 | execute(commandSender, true);
25 | return true;
26 | }
27 | }
28 | commandSender.sendMessage(getUsage());
29 | return false;
30 | }
31 |
32 | @Override
33 | public List getSubCommands(CommandSender commandSender, String[] args) {
34 | return new ArrayList() {{
35 | add("all");
36 | }};
37 | }
38 |
39 | @Override
40 | public String getPrefix() {
41 | return "client";
42 | }
43 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotAsyncPlayerChatEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerChatEvent;
4 |
5 | public class SpigotAsyncPlayerChatEvent extends BasePlayerChatEvent {
6 |
7 | public SpigotAsyncPlayerChatEvent(SpigotPlayer player, String message) {
8 | super("AsyncPlayerChatEvent", "", player, message);
9 | }
10 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotPlayer.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayer;
4 | import com.google.gson.annotations.SerializedName;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.EqualsAndHashCode;
8 | import lombok.NoArgsConstructor;
9 |
10 |
11 | @Data
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | @EqualsAndHashCode(callSuper = true)
15 | public class SpigotPlayer extends BasePlayer {
16 |
17 | @SerializedName("display_name")
18 | private String displayName;
19 | @SerializedName("player_list_name")
20 | private String playerListName;
21 | private String address;
22 |
23 | @SerializedName("is_health_scaled")
24 | private boolean isHealthScaled;
25 | @SerializedName("health_scale")
26 | private double healthScale;
27 |
28 | private float exp;
29 |
30 | @SerializedName("total_exp")
31 | private int totalExp;
32 | private int level;
33 |
34 | private String locale;
35 |
36 | private int ping;
37 | @SerializedName("player_time")
38 | private long playerTime;
39 | @SerializedName("is_player_time_relative")
40 | private boolean isPlayerTimeRelative;
41 | @SerializedName("player_time_offset")
42 | private long playerTimeOffset;
43 | @SerializedName("walk_speed")
44 | private float walkSpeed;
45 | @SerializedName("fly_speed")
46 | private float flySpeed;
47 | @SerializedName("allow_flight")
48 | private boolean allowFlight;
49 | @SerializedName("is_sprinting")
50 | private boolean isSprinting;
51 | @SerializedName("is_sneaking")
52 | private boolean isSneaking;
53 | @SerializedName("is_flying")
54 | private boolean isFlying;
55 | @SerializedName("is_op")
56 | private boolean isOp;
57 |
58 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotPlayerAdvancementDoneEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.event.spigot.dto.advancement.SpigotAdvancement;
4 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
5 |
6 | public class SpigotPlayerAdvancementDoneEvent extends BasePlayerAdvancementEvent {
7 | public SpigotPlayerAdvancementDoneEvent(SpigotPlayer player, SpigotAdvancement advancement) {
8 | super("PlayerAdvancementDoneEvent", player, advancement);
9 | }
10 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotPlayerCommandPreprocessEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BaseCommandEvent;
4 |
5 | public class SpigotPlayerCommandPreprocessEvent extends BaseCommandEvent {
6 |
7 | public SpigotPlayerCommandPreprocessEvent(SpigotPlayer player, String command) {
8 | super("PlayerCommandPreprocessEvent", "", player, command);
9 | }
10 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotPlayerDeathEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerDeathEvent;
4 |
5 | public class SpigotPlayerDeathEvent extends BasePlayerDeathEvent {
6 |
7 | public SpigotPlayerDeathEvent(SpigotPlayer player, String message) {
8 | super("PlayerDeathEvent", "", player, message);
9 | }
10 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotPlayerJoinEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerJoinEvent;
4 |
5 | public class SpigotPlayerJoinEvent extends BasePlayerJoinEvent {
6 |
7 | public SpigotPlayerJoinEvent(SpigotPlayer player) {
8 | super("PlayerJoinEvent", player);
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/SpigotPlayerQuitEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerQuitEvent;
4 |
5 | public class SpigotPlayerQuitEvent extends BasePlayerQuitEvent {
6 |
7 | public SpigotPlayerQuitEvent(SpigotPlayer player) {
8 | super("PlayerQuitEvent", player);
9 | }
10 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/dto/advancement/AdvancementDisplayDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | // IF > spigot-1.12.2
7 | //import org.bukkit.advancement.AdvancementDisplayType;
8 | // END IF
9 | @Data
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class AdvancementDisplayDTO {
13 | private String title;
14 | private String description;
15 | private ItemStackDTO icon;
16 | private Boolean shouldShowToast;
17 | private Boolean shouldAnnounceChat;
18 | private Boolean isHidden;
19 | private Float x;
20 | private Float y;
21 | // IF > spigot-1.12.2
22 | // private AdvancementDisplayType type;
23 | // END IF
24 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/dto/advancement/ItemMetaDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot.dto.advancement;
2 |
3 | import com.google.common.collect.Multimap;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import org.bukkit.attribute.Attribute;
8 | import org.bukkit.attribute.AttributeModifier;
9 | import org.bukkit.enchantments.Enchantment;
10 | import org.bukkit.inventory.ItemFlag;
11 |
12 | import java.util.List;
13 | import java.util.Map;
14 | import java.util.Set;
15 |
16 | @Data
17 | @NoArgsConstructor
18 | @AllArgsConstructor
19 | public class ItemMetaDTO {
20 | private String displayName;
21 | private String localizedName;
22 | private List lore;
23 | private Integer customModelData;
24 | private Map enchants;
25 | private Set itemFlags;
26 | private Boolean unbreakable;
27 | private Multimap attributeModifiers;
28 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/dto/advancement/ItemStackDTO.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot.dto.advancement;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class ItemStackDTO {
11 | private String material;
12 | private ItemMetaDTO meta;
13 | private Integer amount;
14 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/event/spigot/dto/advancement/SpigotAdvancement.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.spigot.dto.advancement;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerAdvancementEvent;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.NoArgsConstructor;
8 |
9 | import java.util.Collection;
10 |
11 | @Data
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | @EqualsAndHashCode(callSuper = true)
15 | public class SpigotAdvancement extends BasePlayerAdvancementEvent.BaseAdvancement {
16 | private Collection criteria;
17 | // IF > spigot-1.12.2
18 | // /**
19 | // * Original: org.bukkit.advancement.AdvancementDisplay
20 | // * version > 1.12.2
21 | // */
22 | // private AdvancementDisplayDTO display;
23 | // END IF
24 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/java/com/github/theword/queqiao/handle/HandleCommandReturnMessageImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle;
2 |
3 | import com.github.theword.queqiao.tool.handle.HandleCommandReturnMessageService;
4 | import org.bukkit.command.CommandSender;
5 |
6 | public class HandleCommandReturnMessageImpl implements HandleCommandReturnMessageService {
7 |
8 | /**
9 | * 处理命令返回消息
10 | *
11 | * @param object 命令发送者
12 | * @param message 消息
13 | */
14 | @Override
15 | public void handleCommandReturnMessage(Object object, String message) {
16 | CommandSender commandSender = (CommandSender) object;
17 | commandSender.sendMessage(message);
18 | }
19 |
20 | /**
21 | * 判断命令发送者是否有权限执行命令
22 | *
23 | * @param object 命令发送者
24 | * @param node 权限节点
25 | * @return 是否有权限
26 | */
27 | @Override
28 | public boolean hasPermission(Object object, String node) {
29 | CommandSender commandSender = (CommandSender) object;
30 | if (commandSender.hasPermission(node)) return true;
31 | commandSender.sendMessage("您没有权限执行当前命令");
32 | return false;
33 | }
34 | }
--------------------------------------------------------------------------------
/spigot/origin/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: QueQiao
2 | version: ${version}
3 | main: com.github.theword.queqiao.QueQiao
4 | api-version: ${api_version}
5 | authors: [ 17TheWord ]
6 | description: ${description}
7 | website: https://github.com/17TheWord/QueQiao
8 | commands:
9 | queqiao:
10 | description: 鹊桥命令
11 | permission: queqiao
12 | permission-message: 您没有执行命令的权限
--------------------------------------------------------------------------------
/spigot/origin/src/test/java/com/github/theword/queqiao/utils/ParseJsonToEventImplTest.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils;
2 |
3 | import com.github.theword.queqiao.tool.response.Response;
4 | import com.google.gson.JsonElement;
5 | import com.google.gson.JsonParser;
6 | import org.junit.jupiter.api.Test;
7 | import net.md_5.bungee.api.ChatColor;
8 |
9 | import java.io.FileNotFoundException;
10 | import java.io.FileReader;
11 |
12 | import static com.github.theword.queqiao.tool.utils.TestUtils.testParseJsonMessage;
13 | import static com.github.theword.queqiao.tool.utils.Tool.logger;
14 | import static org.slf4j.LoggerFactory.getLogger;
15 |
16 |
17 | class ParseJsonToEventImplTest {
18 |
19 | @Test
20 | void parseChatColor() {
21 | // IF spigot-1.12.2
22 | // ChatColor yellow = ChatColor.valueOf("BLACK");
23 | // ELSE
24 | // ChatColor yellow = ChatColor.of("BLACK");
25 | // END IF
26 | System.out.println("yellow = " + yellow);
27 | }
28 |
29 | ParseJsonToEventImpl parseJsonToEventImpl = new ParseJsonToEventImpl();
30 |
31 | @Test
32 | void parseMessage() throws FileNotFoundException {
33 | FileReader reader = new FileReader("../../test_messages.json");
34 | // IF spigot-1.12.2
35 | // JsonElement testMessageJsonElement = new JsonParser().parse(reader);
36 | // ELSE
37 | // JsonElement testMessageJsonElement = JsonParser.parseReader(reader);
38 | // END IF
39 | logger = getLogger(getClass());
40 |
41 | if (!testMessageJsonElement.isJsonArray()) {
42 | logger.warn("jsonElement is not json array");
43 | return;
44 | }
45 |
46 | logger.info("Testing messages");
47 |
48 | for (JsonElement message : testMessageJsonElement.getAsJsonArray()) {
49 | logger.info("============================================");
50 | Response response = testParseJsonMessage(message.getAsString(), parseJsonToEventImpl);
51 | logger.info("response = " + response);
52 | }
53 |
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/spigot/spigot-1.13/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo. 1>&2
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48 | echo. 1>&2
49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50 | echo location of your Java installation. 1>&2
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo. 1>&2
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62 | echo. 1>&2
63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64 | echo location of your Java installation. 1>&2
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/test_messages.json:
--------------------------------------------------------------------------------
1 | [
2 | "{\"api\": \"broadcast\",\"data\": {\"message\": [{\"type\": \"text\",\"data\": {\"text\": \"test\",\"color\": \"aqua\",\"font\": null,\"bold\": false,\"italic\": false,\"underlined\": false,\"strikethrough\": false,\"obfuscated\": false,\"insertion\": null,\"click_event\": {\"action\": \"OPEN_URL\",\"value\": \"https: //www.baidu.com\"},\"hover_event\": {\"action\": \"SHOW_TEXT\",\"text\": [{\"text\": \"testhover\",\"color\": \"aqua\",\"font\": null,\"bold\": true,\"italic\": false,\"underlined\": true,\"strikethrough\": false,\"obfuscated\": false,\"insertion\": null}]}}}]},\"echo\": \"1\"}",
3 | "{\"api\": \"send_title\",\"data\": {\"title\": [{\"type\": \"text\",\"data\": {\"text\": \"Title1\",\"color\": \"aqua\"}},{\"type\": \"text\",\"data\": {\"text\": \"Title2\",\"color\": null,\"font\": null,\"bold\": true,\"italic\": true,\"underlined\": false,\"strikethrough\": false,\"obfuscated\": false,\"insertion\": null}}],\"subtitle\": [{\"type\": \"text\",\"data\": {\"text\": \"SubTitle1\",\"color\": null,\"font\": null,\"bold\": false,\"italic\": false,\"underlined\": true,\"strikethrough\": true,\"obfuscated\": false,\"insertion\": null}},{\"type\": \"text\",\"data\": {\"text\": \"SubTitle2\",\"color\": null,\"font\": null,\"bold\": false,\"italic\": false,\"underlined\": false,\"strikethrough\": false,\"obfuscated\": true,\"insertion\": null}}],\"fadein\": 10,\"stay\": 20,\"fadeout\": 10},\"echo\": \"1\"}",
4 | "{\"api\": \"send_actionbar\",\"data\": {\"message\": [{\"type\": \"text\",\"data\": {\"text\": \"Actionbar1\",\"color\": \"aqua\",\"font\": null,\"bold\": true,\"italic\": false,\"underlined\": true,\"strikethrough\": false,\"obfuscated\": false,\"insertion\": null}}]},\"echo\": \"1\"}",
5 | "{\"api\": \"send_private_msg\",\"data\": {\"uuid\": \"aa96407b-9d4d-44f8-8d79-51d0dcfdedff\",\"nickname\": \"\",\"message\": [{\"type\": \"text\",\"data\": {\"text\": \"test\",\"color\": \"aqua\",\"font\": null,\"bold\": false,\"italic\": false,\"underlined\": false,\"strikethrough\": false,\"obfuscated\": false,\"insertion\": null,\"click_event\": {\"action\": \"open_url\",\"value\": \"https: //www.baidu.com\"},\"hover_event\": {\"action\": \"show_text\",\"text\": [{\"text\": \"testhover\",\"color\": \"aqua\",\"font\": null,\"bold\": true,\"italic\": false,\"underlined\": true,\"strikethrough\": false,\"obfuscated\": false,\"insertion\": null}]}}}]},\"echo\": \"1\"}"
6 | ]
--------------------------------------------------------------------------------
/tool/ModMultiVersionTool-1.3.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/17TheWord/QueQiao/d8a83d46256c45513932aead79911c346e4d8ac3/tool/ModMultiVersionTool-1.3.9.jar
--------------------------------------------------------------------------------
/tool_version.txt:
--------------------------------------------------------------------------------
1 | 0.2.8
--------------------------------------------------------------------------------
/velocity/origin/build/generated/sources/templates/com/github/theword/queqiao/BuildConstants.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | // The constants are replaced before compilation
4 | public class BuildConstants {
5 |
6 | public static final String VERSION = "0.1.1";
7 | }
--------------------------------------------------------------------------------
/velocity/origin/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx3G
2 | org.gradle.daemon=false
3 | # Mod Properties
4 | mod_id=queqiao
5 | mod_name=QueQiao
6 | mod_license=MIT
7 | mod_group_id=com.github.theword.queqiao
8 | mod_authors=17TheWord
9 | mod_description=Connect to nonebot2.
10 | # Lib Properties
11 | lombok_version=1.18.30
12 | slf4j_version=2.0.12
13 | snakeyaml_version=2.2
14 | commons_io_version=2.15.1
15 | junit_jupiter_version=5.10.0
16 | java_websocket_version=1.5.3
17 | jetbrains_annotations_version=24.0.0
18 | maven_repository_url=https://maven.pkg.github.com/17TheWord/QueQiaoTool
19 | # JDK Version
20 | java_version=17
21 | # Api Version
22 | api_version=3.3.0
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/EventProcessor.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | import com.github.theword.queqiao.event.velocity.*;
4 | import com.velocitypowered.api.event.Subscribe;
5 | import com.velocitypowered.api.event.command.CommandExecuteEvent;
6 | import com.velocitypowered.api.event.connection.DisconnectEvent;
7 | import com.velocitypowered.api.event.connection.LoginEvent;
8 | import com.velocitypowered.api.event.player.PlayerChatEvent;
9 | import com.velocitypowered.api.proxy.Player;
10 |
11 | import static com.github.theword.queqiao.tool.utils.Tool.config;
12 | import static com.github.theword.queqiao.tool.utils.Tool.sendWebsocketMessage;
13 | import static com.github.theword.queqiao.utils.VelocityTool.getVelocityPlayer;
14 |
15 |
16 | public class EventProcessor {
17 |
18 | @Subscribe
19 | public void onPlayerChat(PlayerChatEvent event) {
20 | if (!config.getSubscribeEvent().isPlayerChat()) return;
21 |
22 | VelocityPlayer player = getVelocityPlayer(event.getPlayer());
23 | String message = event.getMessage();
24 | VelocityPlayerChatEvent velocityPlayerChatEvent = new VelocityPlayerChatEvent(player, message);
25 | sendWebsocketMessage(velocityPlayerChatEvent);
26 | }
27 |
28 | @Subscribe
29 | public void onPlayerLogin(LoginEvent event) {
30 | if (!config.getSubscribeEvent().isPlayerJoin()) return;
31 |
32 | VelocityPlayer player = getVelocityPlayer(event.getPlayer());
33 | VelocityLoginEvent velocityLoginEvent = new VelocityLoginEvent(player);
34 | sendWebsocketMessage(velocityLoginEvent);
35 | }
36 |
37 | @Subscribe
38 | public void onDisconnect(DisconnectEvent event) {
39 | if (!config.getSubscribeEvent().isPlayerQuit()) return;
40 |
41 | VelocityPlayer player = getVelocityPlayer(event.getPlayer());
42 | VelocityDisconnectEvent velocityDisconnectEvent = new VelocityDisconnectEvent(player);
43 | sendWebsocketMessage(velocityDisconnectEvent);
44 | }
45 |
46 | @Subscribe
47 | public void onCommandExecute(CommandExecuteEvent event) {
48 | if (!(event.getCommandSource() instanceof Player player) || !config.getSubscribeEvent().isPlayerCommand()) return;
49 |
50 | String command = event.getCommand();
51 |
52 | VelocityCommandExecuteEvent velocityCommandExecuteEvent = new VelocityCommandExecuteEvent(getVelocityPlayer(player), command);
53 | sendWebsocketMessage(velocityCommandExecuteEvent);
54 | }
55 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/QueQiao.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | import com.github.theword.queqiao.handle.HandleApiImpl;
4 | import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl;
5 | import com.github.theword.queqiao.tool.constant.BaseConstant;
6 | import com.github.theword.queqiao.tool.constant.ServerTypeConstant;
7 | import com.google.inject.Inject;
8 | import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
9 | import com.velocitypowered.api.event.Subscribe;
10 | import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
11 | import com.velocitypowered.api.plugin.Plugin;
12 | import com.velocitypowered.api.proxy.ProxyServer;
13 |
14 | import static com.github.theword.queqiao.tool.utils.Tool.initTool;
15 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
16 |
17 | @Plugin(id = BaseConstant.MOD_ID, name = BaseConstant.MODULE_NAME, version = BuildConstants.VERSION)
18 | public class QueQiao {
19 |
20 | public static ProxyServer minecraftServer;
21 |
22 | @Inject
23 | public QueQiao(ProxyServer server) {
24 | minecraftServer = server;
25 | }
26 |
27 | @Subscribe
28 | public void onProxyInitialization(ProxyInitializeEvent event) {
29 | initTool(
30 | false,
31 | minecraftServer.getVersion().getVersion(),
32 | ServerTypeConstant.VELOCITY,
33 | new HandleApiImpl(),
34 | new HandleCommandReturnMessageImpl()
35 | );
36 | websocketManager.startWebsocketOnServerStart();
37 | minecraftServer.getEventManager().register(this, new EventProcessor());
38 | }
39 |
40 | @Subscribe
41 | public void onProxyShutdown(ProxyShutdownEvent event) {
42 | websocketManager.stopWebsocketByServerClose();
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/CommandExecutor.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
4 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
5 | import com.github.theword.queqiao.command.subCommand.client.ReconnectAllCommand;
6 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
7 | import com.github.theword.queqiao.tool.constant.BaseConstant;
8 | import com.mojang.brigadier.Command;
9 | import com.mojang.brigadier.builder.LiteralArgumentBuilder;
10 | import com.mojang.brigadier.tree.LiteralCommandNode;
11 | import com.velocitypowered.api.command.BrigadierCommand;
12 | import com.velocitypowered.api.command.CommandSource;
13 | import com.velocitypowered.api.proxy.ProxyServer;
14 | import net.kyori.adventure.text.Component;
15 |
16 | public class CommandExecutor {
17 |
18 | public static BrigadierCommand createBrigadierCommand(final ProxyServer proxy) {
19 | LiteralCommandNode helloNode = BrigadierCommand.literalArgumentBuilder(BaseConstant.COMMAND_HEADER)
20 | .requires(source -> source.hasPermission("queqiao.admin"))
21 | .executes(context -> new HelpCommand().onCommand(context))
22 | .then(LiteralArgumentBuilder.literal("help")
23 | .executes(context -> new HelpCommand().onCommand(context)))
24 | .then(LiteralArgumentBuilder.literal("reload")
25 | .executes(context -> new ReloadCommand().onCommand(context)))
26 | .then(LiteralArgumentBuilder.literal("server")
27 | .executes(context -> {
28 | context.getSource().sendMessage(Component.text("Server command not supported."));
29 | return Command.SINGLE_SUCCESS;
30 | }))
31 | .then(LiteralArgumentBuilder.literal("client")
32 | .then(LiteralArgumentBuilder.literal("reconnect")
33 | .executes(context -> new ReconnectCommand().onCommand(context))
34 | .then(LiteralArgumentBuilder.literal("all")
35 | .executes(context -> new ReconnectAllCommand().onCommand(context)
36 | )
37 | )
38 | )
39 | ).build();
40 | return new BrigadierCommand(helloNode);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/CommandManager.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 |
4 | import com.github.theword.queqiao.command.subCommand.HelpCommand;
5 | import com.github.theword.queqiao.command.subCommand.ReloadCommand;
6 | import com.github.theword.queqiao.command.subCommand.client.ReconnectCommand;
7 | import lombok.Getter;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | @Getter
13 | public class CommandManager {
14 | List subCommandList = new ArrayList<>();
15 |
16 |
17 | public CommandManager() {
18 | subCommandList.add(new HelpCommand());
19 | subCommandList.add(new ReloadCommand());
20 | subCommandList.add(new ReconnectCommand());
21 | }
22 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/VelocitySubCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command;
2 |
3 | import com.github.theword.queqiao.tool.command.SubCommand;
4 | import com.mojang.brigadier.context.CommandContext;
5 | import com.velocitypowered.api.command.CommandSource;
6 |
7 | public interface VelocitySubCommand extends SubCommand {
8 |
9 | int onCommand(CommandContext context);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/subCommand/HelpCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.CommandManager;
4 | import com.github.theword.queqiao.command.VelocitySubCommand;
5 | import com.github.theword.queqiao.tool.command.subCommand.HelpCommandAbstract;
6 | import com.mojang.brigadier.Command;
7 | import com.mojang.brigadier.context.CommandContext;
8 | import com.velocitypowered.api.command.CommandSource;
9 |
10 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
11 |
12 | public class HelpCommand extends HelpCommandAbstract implements VelocitySubCommand {
13 |
14 | @Override
15 | public int onCommand(CommandContext context) {
16 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
17 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "-------------------");
18 | for (VelocitySubCommand forgeSubCommand : new CommandManager().getSubCommandList()) {
19 | handleCommandReturnMessageService.handleCommandReturnMessage(context, forgeSubCommand.getUsage() + "---" + forgeSubCommand.getDescription());
20 | }
21 | handleCommandReturnMessageService.handleCommandReturnMessage(context, "-------------------");
22 | return Command.SINGLE_SUCCESS;
23 | }
24 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/subCommand/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand;
2 |
3 | import com.github.theword.queqiao.command.VelocitySubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.ReloadCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 | import com.velocitypowered.api.command.CommandSource;
8 |
9 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
10 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
11 |
12 | public class ReloadCommand extends ReloadCommandAbstract implements VelocitySubCommand {
13 | @Override
14 | public int onCommand(CommandContext context) {
15 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
16 | execute(context, false);
17 | return Command.SINGLE_SUCCESS;
18 | }
19 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectAllCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.VelocitySubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 | import com.velocitypowered.api.command.CommandSource;
8 |
9 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
10 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
11 |
12 | public class ReconnectAllCommand extends ReconnectCommandAbstract implements VelocitySubCommand {
13 | @Override
14 | public int onCommand(CommandContext context) {
15 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
16 | execute(context, true);
17 | return Command.SINGLE_SUCCESS;
18 | }
19 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/command/subCommand/client/ReconnectCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.command.subCommand.client;
2 |
3 | import com.github.theword.queqiao.command.VelocitySubCommand;
4 | import com.github.theword.queqiao.tool.command.subCommand.client.ReconnectCommandAbstract;
5 | import com.mojang.brigadier.Command;
6 | import com.mojang.brigadier.context.CommandContext;
7 | import com.velocitypowered.api.command.CommandSource;
8 |
9 | import static com.github.theword.queqiao.tool.utils.Tool.handleCommandReturnMessageService;
10 | import static com.github.theword.queqiao.tool.utils.Tool.websocketManager;
11 |
12 | public class ReconnectCommand extends ReconnectCommandAbstract implements VelocitySubCommand {
13 | @Override
14 | public int onCommand(CommandContext context) {
15 | if (!handleCommandReturnMessageService.hasPermission(context, getPermissionNode())) return 0;
16 | execute(context, false);
17 | return Command.SINGLE_SUCCESS;
18 | }
19 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/event/velocity/VelocityCommandExecuteEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.velocity;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BaseCommandEvent;
4 |
5 | public class VelocityCommandExecuteEvent extends BaseCommandEvent {
6 | public VelocityCommandExecuteEvent(VelocityPlayer player, String command) {
7 | super("VelocityCommandExecuteEvent", "", player, command);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/event/velocity/VelocityDisconnectEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.velocity;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerQuitEvent;
4 |
5 | public class VelocityDisconnectEvent extends BasePlayerQuitEvent {
6 | public VelocityDisconnectEvent(VelocityPlayer player) {
7 | super("VelocityDisconnectEvent", player);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/event/velocity/VelocityLoginEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.velocity;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerJoinEvent;
4 |
5 | public class VelocityLoginEvent extends BasePlayerJoinEvent {
6 | public VelocityLoginEvent(VelocityPlayer player) {
7 | super("VelocityLoginEvent", player);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/event/velocity/VelocityPlayer.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.velocity;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayer;
4 | import com.google.gson.annotations.SerializedName;
5 | import com.velocitypowered.api.proxy.player.PlayerSettings;
6 | import com.velocitypowered.api.util.GameProfile;
7 | import lombok.Data;
8 | import lombok.EqualsAndHashCode;
9 |
10 | import java.net.InetSocketAddress;
11 |
12 |
13 | @Data
14 | @EqualsAndHashCode(callSuper = true)
15 | public class VelocityPlayer extends BasePlayer {
16 |
17 | private long ping;
18 | @SerializedName("online_mode")
19 | private boolean onlineMode;
20 | @SerializedName("game_profile")
21 | private GameProfile gameProfile;
22 | @SerializedName("remote_address")
23 | private InetSocketAddress remoteAddress;
24 | @SerializedName("player_settings")
25 | private PlayerSettings playerSettings;
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/event/velocity/VelocityPlayerChatEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.event.velocity;
2 |
3 | import com.github.theword.queqiao.tool.event.base.BasePlayerChatEvent;
4 |
5 | public class VelocityPlayerChatEvent extends BasePlayerChatEvent {
6 | public VelocityPlayerChatEvent(VelocityPlayer player, String message){
7 | super("VelocityPlayerChatEvent", "", player, message);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/handle/HandleApiImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle;
2 |
3 | import com.github.theword.queqiao.tool.handle.HandleApiService;
4 | import com.github.theword.queqiao.tool.payload.MessageSegment;
5 | import com.github.theword.queqiao.tool.payload.TitlePayload;
6 | import com.github.theword.queqiao.tool.response.PrivateMessageResponse;
7 | import com.github.theword.queqiao.tool.utils.Tool;
8 | import com.github.theword.queqiao.utils.ParseJsonToEventImpl;
9 | import com.velocitypowered.api.proxy.Player;
10 | import net.kyori.adventure.text.Component;
11 | import net.kyori.adventure.title.TitlePart;
12 |
13 | import java.util.List;
14 | import java.util.UUID;
15 |
16 | import static com.github.theword.queqiao.QueQiao.minecraftServer;
17 | import static com.github.theword.queqiao.utils.VelocityTool.getVelocityPlayer;
18 |
19 | public class HandleApiImpl implements HandleApiService {
20 |
21 | private final ParseJsonToEventImpl parseJsonToEvent = new ParseJsonToEventImpl();
22 |
23 | @Override
24 | public void handleBroadcastMessage(List messageList) {
25 | Component component = parseJsonToEvent.parsePerMessageToComponent(Tool.getPrefixComponent());
26 | Component append = component.append(parseJsonToEvent.parseMessageListToComponent(messageList));
27 | minecraftServer.sendMessage(append);
28 | }
29 |
30 | @Override
31 | public void handleSendTitleMessage(TitlePayload titlePayload) {
32 | Component title = parseJsonToEvent.parseMessageListToComponent(titlePayload.getTitle());
33 | minecraftServer.sendTitlePart(TitlePart.TITLE, title);
34 | if (titlePayload.getSubtitle() != null) {
35 | Component subtitle = parseJsonToEvent.parseMessageListToComponent(titlePayload.getSubtitle());
36 | minecraftServer.sendTitlePart(TitlePart.SUBTITLE, subtitle);
37 | }
38 | }
39 |
40 | @Override
41 | public void handleSendActionBarMessage(List messageList) {
42 | Component component = parseJsonToEvent.parsePerMessageToComponent(Tool.getPrefixComponent());
43 | minecraftServer.sendActionBar(component);
44 | }
45 |
46 | @Override
47 | public PrivateMessageResponse handleSendPrivateMessage(String nickname, UUID uuid, List messageList) {
48 | for (Player player : minecraftServer.getAllPlayers()) {
49 | if ((uuid != null && uuid.equals(player.getUniqueId())) || (nickname != null && nickname.equals(player.getUsername()))) {
50 | Component component = parseJsonToEvent.parsePerMessageToComponent(Tool.getPrefixComponent());
51 | minecraftServer.sendMessage(component);
52 | return PrivateMessageResponse.sendSuccess(getVelocityPlayer(player));
53 | }
54 | }
55 | return PrivateMessageResponse.playerNotFound();
56 | }
57 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/handle/HandleCommandReturnMessageImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.handle;
2 |
3 | import com.github.theword.queqiao.tool.handle.HandleCommandReturnMessageService;
4 | import com.mojang.brigadier.context.CommandContext;
5 | import com.velocitypowered.api.command.CommandSource;
6 | import net.kyori.adventure.text.Component;
7 |
8 | public class HandleCommandReturnMessageImpl implements HandleCommandReturnMessageService {
9 | @Override
10 | @SuppressWarnings("unchecked")
11 | public void handleCommandReturnMessage(Object o, String s) {
12 | CommandContext context = (CommandContext) o;
13 | context.getSource().sendMessage(Component.text(s));
14 | }
15 |
16 | /**
17 | * @param object CommandContext
18 | * @param node 权限节点
19 | * @return 是否有权限
20 | */
21 | @Override
22 | @SuppressWarnings("unchecked")
23 | public boolean hasPermission(Object object, String node) {
24 | CommandContext context = (CommandContext) object;
25 | if (context.getSource().hasPermission(node)) return true;
26 | handleCommandReturnMessage(object, "您没有执行此命令的权限");
27 | return false;
28 | }
29 | }
--------------------------------------------------------------------------------
/velocity/origin/src/main/java/com/github/theword/queqiao/utils/VelocityTool.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils;
2 |
3 | import com.github.theword.queqiao.event.velocity.VelocityPlayer;
4 | import com.velocitypowered.api.proxy.Player;
5 |
6 | public class VelocityTool {
7 |
8 | public static VelocityPlayer getVelocityPlayer(Player player) {
9 | VelocityPlayer velocityPlayer = new VelocityPlayer();
10 |
11 | velocityPlayer.setNickname(player.getUsername());
12 | velocityPlayer.setUuid(player.getUniqueId());
13 | velocityPlayer.setPing(player.getPing());
14 | velocityPlayer.setOnlineMode(player.isOnlineMode());
15 |
16 | velocityPlayer.setGameProfile(player.getGameProfile());
17 | velocityPlayer.setRemoteAddress(player.getRemoteAddress());
18 | velocityPlayer.setPlayerSettings(player.getPlayerSettings());
19 | return velocityPlayer;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/velocity/origin/src/main/templates/com/github/theword/queqiao/BuildConstants.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao;
2 |
3 | // The constants are replaced before compilation
4 | public class BuildConstants {
5 |
6 | public static final String VERSION = "${version}";
7 | }
8 |
--------------------------------------------------------------------------------
/velocity/origin/src/test/java/com/github/theword/queqiao/utils/ParseJsonToEventImplTest.java:
--------------------------------------------------------------------------------
1 | package com.github.theword.queqiao.utils;
2 |
3 | import com.github.theword.queqiao.tool.response.Response;
4 | import com.google.gson.JsonElement;
5 | import com.google.gson.JsonParser;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import java.io.FileNotFoundException;
9 | import java.io.FileReader;
10 |
11 | import static com.github.theword.queqiao.tool.utils.TestUtils.testParseJsonMessage;
12 | import static com.github.theword.queqiao.tool.utils.Tool.logger;
13 | import static org.slf4j.LoggerFactory.getLogger;
14 |
15 | class ParseJsonToEventImplTest {
16 |
17 | ParseJsonToEventImpl parseJsonToEventImpl = new ParseJsonToEventImpl();
18 |
19 | @Test
20 | void parseMessage() throws FileNotFoundException {
21 | FileReader reader = new FileReader("../../test_messages.json");
22 | JsonElement testMessageJsonElement = JsonParser.parseReader(reader);
23 | logger = getLogger(getClass());
24 |
25 | if (!testMessageJsonElement.isJsonArray()) {
26 | logger.warn("jsonElement is not json array");
27 | return;
28 | }
29 |
30 | logger.info("Testing messages");
31 |
32 | for (JsonElement message : testMessageJsonElement.getAsJsonArray()) {
33 | logger.info("============================================");
34 | Response response = testParseJsonMessage(message.getAsString(), parseJsonToEventImpl);
35 | logger.info("response = " + response);
36 | }
37 |
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | 0.1.5
--------------------------------------------------------------------------------