first commit
This commit is contained in:
parent
a44ef3837f
commit
7b999be941
14
package.json
14
package.json
|
@ -1,22 +1,28 @@
|
||||||
{
|
{
|
||||||
"name": "koishi-plugin-minecraft-vc-rcon",
|
"name": "koishi-plugin-minecraft-vc-rcon",
|
||||||
"description": "",
|
"description": "velocity和lls_manager的自助白名单添加",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
|
"contributors": [
|
||||||
|
"SharwOrange <kuliangcha@qq.com>"
|
||||||
|
],
|
||||||
|
"homepage": "https://example.com",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"typings": "lib/index.d.ts",
|
"typings": "lib/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"lib",
|
"lib",
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MPL-2.0",
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"chatbot",
|
"chatbot",
|
||||||
"koishi",
|
"koishi",
|
||||||
"plugin"
|
"plugin"
|
||||||
],
|
],
|
||||||
"devDependencies": {},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"koishi": "^4.17.9"
|
"koishi": "^4.17.9"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rcon-client": "^4.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
66
src/index.ts
66
src/index.ts
|
@ -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 const name = 'minecraft-vc-rcon'
|
||||||
|
|
||||||
export interface Config {}
|
export interface Config {
|
||||||
|
host:string
|
||||||
export const Config: Schema<Config> = Schema.object({})
|
port:number
|
||||||
|
password:string
|
||||||
export function apply(ctx: Context) {
|
}
|
||||||
// write your plugin here
|
|
||||||
|
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')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user