mirror of
https://github.com/jie65535/gc-opencommand-plugin.git
synced 2025-12-15 19:31:35 +08:00
Compare commits
8 Commits
v1.5.2-for
...
v1.6.1
| Author | SHA1 | Date | |
|---|---|---|---|
| a084d39b02 | |||
| 6c19c09c00 | |||
| c6e0b51ea6 | |||
| bcb88740f1 | |||
| 290c4fbf8c | |||
| 564f4d1e56 | |||
| 66fb25aa9b | |||
| c3c2ed08a7 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -5,7 +5,7 @@ on:
|
||||
paths:
|
||||
- "**.java"
|
||||
branches:
|
||||
- "for-unstable"
|
||||
- "master"
|
||||
pull_request:
|
||||
paths:
|
||||
- "**.java"
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: Download latest grasscutter jar
|
||||
run: wget https://nightly.link/Grasscutters/Grasscutter/workflows/build/unstable/Grasscutter.zip && mkdir lib && unzip Grasscutter.zip -d lib
|
||||
run: wget https://nightly.link/Grasscutters/Grasscutter/workflows/build/development/Grasscutter.zip && mkdir lib && unzip Grasscutter.zip -d lib
|
||||
|
||||
- name: Change permission
|
||||
run: chmod +x gradlew
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
一个为第三方客户端开放GC命令执行接口的插件
|
||||
|
||||
## 分支说明
|
||||
|
||||
本分支目的在于兼容 GC 的 `unstable` 分支
|
||||
|
||||
## 使用本插件的应用
|
||||
- [GrasscutterTools](https://github.com/jie65535/GrasscutterCommandGenerator) —— Windows 客户端工具
|
||||
- [JGrasscutterCommand](https://github.com/jie65535/JGrasscutterCommand) —— [Mirai](https://github.com/mamoe/mirai) 插件,在QQ里执行命令
|
||||
@@ -74,7 +70,7 @@
|
||||
|
||||
## `config.json`
|
||||
|
||||
```json5
|
||||
```json
|
||||
{
|
||||
// 控制台连接令牌
|
||||
"consoleToken": "",
|
||||
@@ -263,7 +259,7 @@ public final class JsonResponse {
|
||||
| message | `Success` | `String` |
|
||||
| data | `{}` | `JsonObject` |
|
||||
|
||||
```json5
|
||||
```json
|
||||
{
|
||||
"retcode": 200,
|
||||
"message": "success",
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
A plugin that opens the GC command execution interface for third-party clients
|
||||
|
||||
## Branch Description
|
||||
|
||||
The purpose of this branch is to be compatible with the 'unstable' branch of GC
|
||||
|
||||
## Applications using this plug-in
|
||||
- [GrasscutterTools](https://github.com/jie65535/GrasscutterCommandGenerator) —— Windows Client Tools
|
||||
- [JGrasscutterCommand](https://github.com/jie65535/JGrasscutterCommand) —— [Mirai](https://github.com/mamoe/mirai) Plugin, run commands in QQ
|
||||
@@ -248,7 +244,7 @@ Success
|
||||
| message | `Success` | `String` |
|
||||
| data | `{}` | `JsonObject` |
|
||||
|
||||
```json5
|
||||
```json
|
||||
{
|
||||
"retcode": 200,
|
||||
"message": "success",
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'com.github.jie65535.opencommand'
|
||||
version '1.5.2'
|
||||
version '1.6.1'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
@@ -18,7 +18,7 @@ dependencies {
|
||||
}
|
||||
|
||||
jar {
|
||||
jar.baseName = 'opencommand-for-unstable'
|
||||
jar.baseName = 'opencommand'
|
||||
|
||||
destinationDir = file(".")
|
||||
}
|
||||
@@ -44,13 +44,11 @@ public final class EventListeners {
|
||||
* @param uid 玩家uid
|
||||
* @return 新的玩家消息处理类
|
||||
*/
|
||||
public static StringBuilder getPlayerNewMessageHandler(int uid) {
|
||||
public static StringBuilder getPlayerMessageHandler(int uid) {
|
||||
var handler = playerMessageHandlers.get(uid);
|
||||
if (handler == null) {
|
||||
handler = new StringBuilder();
|
||||
playerMessageHandlers.put(uid, handler);
|
||||
} else {
|
||||
handler.setLength(0);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class OpenCommandHandler implements Router {
|
||||
|
||||
var req = context.bodyAsClass(JsonRequest.class);
|
||||
if (req.action.equals("sendCode")) {
|
||||
int playerId = (int) req.data;
|
||||
int playerId = (int)Double.parseDouble(req.data.toString());
|
||||
var player = plugin.getServer().getPlayerByUid(playerId);
|
||||
if (player == null) {
|
||||
context.json(new JsonResponse(404, "Player Not Found."));
|
||||
@@ -152,11 +152,12 @@ public final class OpenCommandHandler implements Router {
|
||||
context.json(new JsonResponse(404, "Player not found"));
|
||||
return;
|
||||
}
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
synchronized (player) {
|
||||
// Player MessageHandler do not support concurrency
|
||||
var handler = EventListeners.getPlayerNewMessageHandler(player.getUid());
|
||||
var handler = EventListeners.getPlayerMessageHandler(player.getUid());
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
synchronized (handler) {
|
||||
try {
|
||||
handler.setLength(0);
|
||||
CommandMap.getInstance().invoke(player, player, command);
|
||||
context.json(new JsonResponse(handler.toString()));
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class OpenCommandOnlyHttpHandler implements Router {
|
||||
|
||||
var req = context.bodyAsClass(JsonRequest.class);
|
||||
if (req.action.equals("sendCode")) {
|
||||
int playerId = (int) req.data;
|
||||
int playerId = (int)Double.parseDouble(req.data.toString());
|
||||
var player = SocketData.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
context.json(new JsonResponse(404, "Player Not Found."));
|
||||
|
||||
@@ -159,11 +159,12 @@ public class SocketClient {
|
||||
sendPacket(new HttpPacket(404, "Player not found."), packet.packetID);
|
||||
return;
|
||||
}
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
synchronized (playerData) {
|
||||
// Player MessageHandler do not support concurrency
|
||||
var handler = EventListeners.getPlayerNewMessageHandler(playerData.getUid());
|
||||
var handler = EventListeners.getPlayerMessageHandler(playerData.getUid());
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
synchronized (handler) {
|
||||
try {
|
||||
handler.setLength(0);
|
||||
CommandMap.getInstance().invoke(playerData, playerData, command);
|
||||
sendPacket(new HttpPacket(200, handler.toString()), packet.packetID);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "opencommand-plugin",
|
||||
"description": "Open command interface for third-party clients",
|
||||
"version": "dev-1.5.2",
|
||||
"version": "1.6.1",
|
||||
"mainClass": "com.github.jie65535.opencommand.OpenCommandPlugin",
|
||||
"authors": ["jie65535", "方块君"]
|
||||
"authors": ["jie65535", "方块君"],
|
||||
"api": 2
|
||||
}
|
||||
Reference in New Issue
Block a user