first commit

This commit is contained in:
SharwOrange橙夜 2024-07-05 17:09:19 +08:00
parent a44ef3837f
commit 7b999be941
Signed by: SharwOrange
GPG Key ID: 5507630E4F33F4B1
2 changed files with 69 additions and 11 deletions

View File

@ -1,22 +1,28 @@
{
"name": "koishi-plugin-minecraft-vc-rcon",
"description": "",
"version": "0.0.1",
"description": "velocity和lls_manager的自助白名单添加",
"version": "1.0.0",
"contributors": [
"SharwOrange <kuliangcha@qq.com>"
],
"homepage": "https://example.com",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
"lib",
"dist"
],
"license": "MIT",
"license": "MPL-2.0",
"scripts": {},
"keywords": [
"chatbot",
"koishi",
"plugin"
],
"devDependencies": {},
"peerDependencies": {
"koishi": "^4.17.9"
},
"dependencies": {
"rcon-client": "^4.2.4"
}
}

View File

@ -1,11 +1,63 @@
import { Context, Schema } from 'koishi'
import { Context, Schema} from 'koishi'
import { Rcon } from "rcon-client"
export const name = 'minecraft-vc-rcon'
export interface Config {}
export const Config: Schema<Config> = Schema.object({})
export function apply(ctx: Context) {
// write your plugin here
export interface Config {
host:string
port:number
password:string
}
export const Config: Schema<Config> = Schema.object({
host: Schema.string()
.description("服务器IP")
.default("127.0.0.1"),
port: Schema.number()
.description("Rcon端口")
.default(25575),
password: Schema.string()
.description("Rcon密码")
})
export async function apply(ctx: Context,config:Config) {
const rcon = new Rcon({
host: config.host,
port: config.port,
password: config.password,
})
async function whitelist_add(playername:string) {
try{
await rcon.connect()
await rcon.send(`lls_create_player ${playername}`)
await rcon.send(`lls_whitelist add ${playername} Login`)
await rcon.send(`lls_whitelist add ${playername} Survival`)
await rcon.send(`lls_whitelist add ${playername} Creative`)
await rcon.send(`lls_whitelist add ${playername} Mod-120`)
await rcon.end()
return true
}catch(e){
console.error(e)
return false
}
}
ctx.on('message', (session) => {
if (session.content === '天王盖地虎') {
session.send('宝塔镇河妖')
}
})
ctx.command('whitelist <playername:text>', {checkArgCount: true})
.action(async ({ session }, playername) => {
let back = whitelist_add(playername)
if(await back){
session.send(`成功为 ${playername} 添加了白名单`)
}else{
session.send('白名单添加失败,请查看日志')
}
})
.usage('自助白名单添加请将playername替换为你的游戏ID')
}