Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd6a2023dc | |||
| 498b0ee017 | |||
| 9bfaf984c1 | |||
| 3c33ebf4e6 | |||
| 8af69c98f3 | |||
| 72277f4d1a | |||
| d85f75ba1f | |||
| ed14d317f4 | |||
| fb8a11ea05 | |||
| eae80fa30b | |||
| 3e69fc42d9 | |||
| c5595a65fb | |||
| df266905f2 | |||
| f8046e38be | |||
| 51fb5aece3 | |||
| 7a1dd3e7b3 |
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.7",
|
||||
"useWorkspaces": true,
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/amqp",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript amqp package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,17 +19,17 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"@javatypes/amqp-client": "^0.0.2",
|
||||
"@javatypes/spring-amqp": "^0.0.2",
|
||||
"@javatypes/spring-rabbit": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/api",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,9 +19,9 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3",
|
||||
"@ccms/ployfill": "^0.9.3",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4",
|
||||
"@ccms/ployfill": "^0.9.4",
|
||||
"base64-js": "^1.3.1",
|
||||
"source-map-builder": "^0.0.7"
|
||||
},
|
||||
@@ -29,6 +29,6 @@
|
||||
"@types/base64-js": "^1.3.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { injectable, inject, provideSingleton } from "@ccms/container"
|
||||
import { injectable } from "@ccms/container"
|
||||
|
||||
export namespace channel {
|
||||
/**
|
||||
@@ -63,156 +63,4 @@ export namespace channel {
|
||||
*/
|
||||
abstract unregister(channel: string, listener?: any): void
|
||||
}
|
||||
export namespace proxy {
|
||||
const CHANNEL_NAME = "BungeeCord"
|
||||
const ByteArrayOutputStream = Java.type('java.io.ByteArrayOutputStream')
|
||||
const DataOutputStream = Java.type('java.io.DataOutputStream')
|
||||
const ByteStreams = Java.type('com.google.common.io.ByteStreams')
|
||||
namespace bungeecord {
|
||||
export class SubChannelBuilder {
|
||||
private channel: Channel
|
||||
private player: any
|
||||
private params: string[]
|
||||
constructor(channel: Channel, player: any) {
|
||||
this.channel = channel
|
||||
this.player = player
|
||||
this.params = []
|
||||
}
|
||||
connect(server: string) {
|
||||
this.params.push("Connect")
|
||||
this.params.push(server)
|
||||
}
|
||||
connectOther(player: string, server: string) {
|
||||
this.params.push("ConnectOther")
|
||||
this.params.push(player)
|
||||
this.params.push(server)
|
||||
}
|
||||
ip() {
|
||||
this.params.push("IP")
|
||||
}
|
||||
ipOther(player: string) {
|
||||
this.params.push("IPOther")
|
||||
this.params.push(player)
|
||||
}
|
||||
playerCount(server: string | "ALL") {
|
||||
this.params.push("PlayerCount")
|
||||
this.params.push(server)
|
||||
}
|
||||
/**
|
||||
* Get a list of players connected on a certain server, or on ALL the servers.
|
||||
* @param server count server
|
||||
* Response:
|
||||
* String server = in.readUTF(); // The name of the server you got the player list of, as given in args.
|
||||
* String[] playerList = in.readUTF().split(", ");
|
||||
*/
|
||||
playerList(server: string | "ALL") {
|
||||
this.params.push("PlayerList")
|
||||
this.params.push(server)
|
||||
}
|
||||
/**
|
||||
* Get a list of server name strings, as defined in BungeeCord's config.yml
|
||||
* Response:
|
||||
* String[] serverList = in.readUTF().split(", ");
|
||||
*/
|
||||
getServers() {
|
||||
this.params.push("GetServers")
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Get this server's name, as defined in BungeeCord's config.yml
|
||||
*/
|
||||
getServer() {
|
||||
this.params.push("GetServer")
|
||||
return this.finalSend()
|
||||
}
|
||||
broadcast(message: string) {
|
||||
this.message("ALL", message)
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Send a message (as in, a chat message) to the specified player.
|
||||
* @param player who reciver message
|
||||
* @param message message content
|
||||
*/
|
||||
message(player: string | "ALL", message: string) {
|
||||
this.params.push("Message")
|
||||
this.params.push(player)
|
||||
this.params.push(message)
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Send a raw message (as in, a chat message) to the specified player. The advantage of this method over Message is that you can include click events and hover events.
|
||||
* @param player who reciver message
|
||||
* @param message message content
|
||||
*/
|
||||
messageRaw(player: string | "ALL", json: string) {
|
||||
this.params.push("MessageRaw")
|
||||
this.params.push(player)
|
||||
this.params.push(json)
|
||||
return this.finalSend()
|
||||
}
|
||||
forwardAll(channel: string, data: any) {
|
||||
this.forward("ALL", channel, data)
|
||||
}
|
||||
/**
|
||||
* Send a custom plugin message to said server. This is one of the most useful channels ever.
|
||||
* Remember, the sending and receiving server(s) need to have a player online.
|
||||
* @param server reciver
|
||||
* @param channel channelName
|
||||
* @param data data
|
||||
*/
|
||||
forward(server: string | "ALL", channel: string, data: any) {
|
||||
this.params.push("Forward")
|
||||
this.params.push(server)
|
||||
this.params.push(channel)
|
||||
this.params.push(typeof data === "string" ? data : JSON.stringify(data))
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Send a custom plugin message to said server. This is one of the most useful channels ever.
|
||||
* Remember, the sending and receiving server(s) need to have a player online.
|
||||
* @param server reciver
|
||||
* @param channel channelName
|
||||
* @param data data
|
||||
*/
|
||||
forwardToPlayer(server: string | "ALL", channel: string, data: any) {
|
||||
this.params.push("Forward")
|
||||
this.params.push(server)
|
||||
this.params.push(channel)
|
||||
this.params.push(typeof data === "string" ? data : JSON.stringify(data))
|
||||
return this.finalSend()
|
||||
}
|
||||
generic(...args: string[]) {
|
||||
args && this.params.concat(...args)
|
||||
return this.finalSend()
|
||||
}
|
||||
private send(...middlewares: ((out: java.io.DataOutputStream) => void)[]) {
|
||||
let byteArray = new ByteArrayOutputStream()
|
||||
let out = new DataOutputStream(byteArray)
|
||||
this.params.forEach(utf => out.writeUTF(utf))
|
||||
for (let middleware of middlewares) {
|
||||
middleware(out)
|
||||
}
|
||||
this.channel.send(this.player, CHANNEL_NAME, byteArray.toByteArray())
|
||||
}
|
||||
private finalSend() {
|
||||
return {
|
||||
send: this.send.bind(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@provideSingleton(BungeeCord)
|
||||
export class BungeeCord {
|
||||
@inject(Channel)
|
||||
private channel: Channel
|
||||
/**
|
||||
* 获得代理
|
||||
* @param player 玩家
|
||||
*/
|
||||
for(player: any): bungeecord.SubChannelBuilder {
|
||||
return new bungeecord.SubChannelBuilder(this.channel, player)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export namespace command {
|
||||
*/
|
||||
on(plugin: plugin.Plugin, name: string, exec: { cmd: Function, tab?: Function }) {
|
||||
var cmd = this.create(plugin, name)
|
||||
if (!cmd) { throw Error("") }
|
||||
if (!cmd) { throw Error(`Plugin ${plugin.description.name} can't create Command ${name}!`) }
|
||||
console.debug(i18n.translate("ms.api.command.register", { plugin: plugin.description.name, name, cmd }))
|
||||
if (exec.cmd && typeof exec.cmd === "function") {
|
||||
this.onCommand(plugin, cmd, exec.cmd)
|
||||
@@ -62,9 +62,9 @@ export namespace command {
|
||||
var complete = tabCompleter(sender, command, Java.from(args)) || []
|
||||
return this.copyPartialMatches(complete, token)
|
||||
} catch (ex) {
|
||||
console.i18n("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
|
||||
console.i18n("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
|
||||
console.ex(ex)
|
||||
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
|
||||
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import "@ccms/nashorn"
|
||||
export * from './chat'
|
||||
export * from './task'
|
||||
export * from './event'
|
||||
export * from './proxy'
|
||||
export * from './console'
|
||||
export * from './channel'
|
||||
export * from './command'
|
||||
|
||||
160
packages/api/src/proxy.ts
Normal file
160
packages/api/src/proxy.ts
Normal file
@@ -0,0 +1,160 @@
|
||||
import { provideSingleton, Autowired } from '@ccms/container'
|
||||
import { channel } from './channel'
|
||||
|
||||
export namespace proxy {
|
||||
const ByteArrayOutputStream = Java.type('java.io.ByteArrayOutputStream')
|
||||
const DataOutputStream = Java.type('java.io.DataOutputStream')
|
||||
namespace bungeecord {
|
||||
const CHANNEL_NAME = "BungeeCord"
|
||||
export class SubChannelBuilder {
|
||||
private channel: channel.Channel
|
||||
private player: any
|
||||
private params: string[]
|
||||
constructor(channel: channel.Channel, player: any) {
|
||||
this.channel = channel
|
||||
this.player = player
|
||||
this.params = []
|
||||
}
|
||||
connect(server: string) {
|
||||
this.params.push("Connect")
|
||||
this.params.push(server)
|
||||
return this.finalSend()
|
||||
}
|
||||
connectOther(player: string, server: string) {
|
||||
this.params.push("ConnectOther")
|
||||
this.params.push(player)
|
||||
this.params.push(server)
|
||||
return this.finalSend()
|
||||
}
|
||||
ip() {
|
||||
this.params.push("IP")
|
||||
return this.finalSend()
|
||||
}
|
||||
ipOther(player: string) {
|
||||
this.params.push("IPOther")
|
||||
this.params.push(player)
|
||||
return this.finalSend()
|
||||
}
|
||||
playerCount(server: string | "ALL") {
|
||||
this.params.push("PlayerCount")
|
||||
this.params.push(server)
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Get a list of players connected on a certain server, or on ALL the servers.
|
||||
* @param server count server
|
||||
* Response:
|
||||
* String server = in.readUTF(); // The name of the server you got the player list of, as given in args.
|
||||
* String[] playerList = in.readUTF().split(", ");
|
||||
*/
|
||||
playerList(server: string | "ALL") {
|
||||
this.params.push("PlayerList")
|
||||
this.params.push(server)
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Get a list of server name strings, as defined in BungeeCord's config.yml
|
||||
* Response:
|
||||
* String[] serverList = in.readUTF().split(", ");
|
||||
*/
|
||||
getServers() {
|
||||
this.params.push("GetServers")
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Get this server's name, as defined in BungeeCord's config.yml
|
||||
*/
|
||||
getServer() {
|
||||
this.params.push("GetServer")
|
||||
return this.finalSend()
|
||||
}
|
||||
broadcast(message: string) {
|
||||
this.message("ALL", message)
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Send a message (as in, a chat message) to the specified player.
|
||||
* @param player who reciver message
|
||||
* @param message message content
|
||||
*/
|
||||
message(player: string | "ALL", message: string) {
|
||||
this.params.push("Message")
|
||||
this.params.push(player)
|
||||
this.params.push(message)
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Send a raw message (as in, a chat message) to the specified player. The advantage of this method over Message is that you can include click events and hover events.
|
||||
* @param player who reciver message
|
||||
* @param message message content
|
||||
*/
|
||||
messageRaw(player: string | "ALL", json: string) {
|
||||
this.params.push("MessageRaw")
|
||||
this.params.push(player)
|
||||
this.params.push(json)
|
||||
return this.finalSend()
|
||||
}
|
||||
forwardAll(channel: string, data: any) {
|
||||
return this.forward("ALL", channel, data)
|
||||
}
|
||||
/**
|
||||
* Send a custom plugin message to said server. This is one of the most useful channels ever.
|
||||
* Remember, the sending and receiving server(s) need to have a player online.
|
||||
* @param server reciver
|
||||
* @param channel channelName
|
||||
* @param data data
|
||||
*/
|
||||
forward(server: string | "ALL", channel: string, data: any) {
|
||||
this.params.push("Forward")
|
||||
this.params.push(server)
|
||||
this.params.push(channel)
|
||||
this.params.push(typeof data === "string" ? data : JSON.stringify(data))
|
||||
return this.finalSend()
|
||||
}
|
||||
/**
|
||||
* Send a custom plugin message to said server. This is one of the most useful channels ever.
|
||||
* Remember, the sending and receiving server(s) need to have a player online.
|
||||
* @param server reciver
|
||||
* @param channel channelName
|
||||
* @param data data
|
||||
*/
|
||||
forwardToPlayer(server: string | "ALL", channel: string, data: any) {
|
||||
this.params.push("Forward")
|
||||
this.params.push(server)
|
||||
this.params.push(channel)
|
||||
this.params.push(typeof data === "string" ? data : JSON.stringify(data))
|
||||
return this.finalSend()
|
||||
}
|
||||
generic(...args: string[]) {
|
||||
args && this.params.concat(...args)
|
||||
return this.finalSend()
|
||||
}
|
||||
private send(...middlewares: ((out: java.io.DataOutputStream) => void)[]) {
|
||||
let byteArray = new ByteArrayOutputStream()
|
||||
let out = new DataOutputStream(byteArray)
|
||||
this.params.forEach(utf => out.writeUTF(utf))
|
||||
for (let middleware of middlewares) {
|
||||
middleware(out)
|
||||
}
|
||||
return this.channel.send(this.player, CHANNEL_NAME, byteArray.toByteArray())
|
||||
}
|
||||
private finalSend() {
|
||||
return {
|
||||
send: this.send.bind(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@provideSingleton(BungeeCord)
|
||||
export class BungeeCord {
|
||||
@Autowired()
|
||||
private channel: channel.Channel
|
||||
/**
|
||||
* 获得代理
|
||||
* @param player 玩家
|
||||
*/
|
||||
for(player: any): bungeecord.SubChannelBuilder {
|
||||
return new bungeecord.SubChannelBuilder(this.channel, player)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/bukkit",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript bukkit package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,11 +22,11 @@
|
||||
"@javatypes/spigot-api": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ export class BukkitChat extends chat.Chat {
|
||||
this.sendJson(sender, { text: message }, 2)
|
||||
}
|
||||
sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) {
|
||||
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)
|
||||
try {
|
||||
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)
|
||||
} catch (error) {
|
||||
sender.sendTitle(title, subtitle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/bungee",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript bungee package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,11 +22,11 @@
|
||||
"@javatypes/bungee-api": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,20 +6,20 @@ const Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy()
|
||||
@provideSingleton(channel.Channel)
|
||||
export class BungeeChannel extends channel.Channel {
|
||||
@inject(event.Event)
|
||||
private eventManager: event.Event;
|
||||
private eventManager: event.Event
|
||||
|
||||
send(player: any, channel: string, data: any) {
|
||||
throw new Error("Method not implemented.");
|
||||
throw new Error("Method not implemented.")
|
||||
}
|
||||
register(channel: string, listener: channel.ChannelListener) {
|
||||
Bungee.registerChannel(channel);
|
||||
Bungee.registerChannel(channel)
|
||||
// console.console('§6[§eWARN§6] §eMiaoScript channel in BungeeCord only register. you need self hanler PluginMessageEvent!')
|
||||
return this.eventManager.listen({ description: { name: channel } }, "PluginMessageEvent", (event: net.md_5.bungee.api.event.PluginMessageEvent) => {
|
||||
listener(event.getData(), event)
|
||||
})
|
||||
}
|
||||
unregister(channel: string, listener: any) {
|
||||
Bungee.unregisterChannel(channel);
|
||||
listener.off();
|
||||
unregister(channel: string, off: any) {
|
||||
Bungee.unregisterChannel(channel)
|
||||
off()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@ccms/client",
|
||||
"version": "0.9.0",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript client package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,10 +22,10 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"minecraft-protocol": "^1.13.0"
|
||||
"minecraft-protocol": "^1.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ import { $ } from './color'
|
||||
export function attachEvents(client) {
|
||||
client.on('chat', (packet) => {
|
||||
// Listen for chat messages and echo them back.
|
||||
var jsonMsg = JSON.parse(packet.message);
|
||||
var jsonMsg = JSON.parse(packet.message)
|
||||
console.log($(jsonMsg))
|
||||
})
|
||||
client.on('state', (newState, oldState) => {
|
||||
console.log('Client Change State', oldState, 'to', newState)
|
||||
let targetServer = process.argv[3]
|
||||
let targetServer = process.argv[6]
|
||||
if (newState == "play" && targetServer) {
|
||||
setTimeout(() => {
|
||||
client.write('chat', {
|
||||
@@ -24,4 +24,10 @@ export function attachEvents(client) {
|
||||
} else if (packet.health > 0) {
|
||||
}
|
||||
})
|
||||
client.on('kick_disconnect', (packet) => {
|
||||
console.log($(packet.reason))
|
||||
})
|
||||
client.on('disconnect', (packet) => {
|
||||
console.log($(packet.reason))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,33 +5,52 @@ import { attachForge } from './forge'
|
||||
import { attachEvents } from './event'
|
||||
|
||||
let username = process.argv[2] || 'Mr_jtb'
|
||||
let version = process.argv[3] || '1.12.2'
|
||||
let address = process.argv[4] || '192.168.2.5:25577'
|
||||
let realAddress = address.split(":");
|
||||
let client = createConnection(realAddress[0], parseInt(realAddress[1] || "25565"), username)
|
||||
let password = process.argv[3] || ''
|
||||
let version = process.argv[4] || '1.12.2'
|
||||
let readAddress = process.argv[5] || '192.168.2.5:25577'
|
||||
let realAddress = readAddress.split(":")
|
||||
let address = realAddress[0]
|
||||
let port = parseInt(realAddress[1] || "25565")
|
||||
let client = commandLineCreateClient()
|
||||
|
||||
function createConnection(host: string, port: number, username: string) {
|
||||
function commandLineCreateClient() {
|
||||
return createConnection(address, port, username, password)
|
||||
}
|
||||
|
||||
function createConnection(host: string, port: number, username: string, password: string) {
|
||||
let client = createClient({
|
||||
version,
|
||||
host,
|
||||
port,
|
||||
username,
|
||||
skipValidation: true
|
||||
password,
|
||||
clientToken: 'd02c7f39-2376-45da-a5a5-50e24fa8b185',
|
||||
//@ts-ignore
|
||||
authServer: 'https://mcsso.yumc.pw/api/yggdrasil/authserver',
|
||||
sessionServer: 'https://mcsso.yumc.pw/api/yggdrasil/sessionserver'
|
||||
})
|
||||
|
||||
attachCommon(client)
|
||||
attachForge(client)
|
||||
attachEvents(client)
|
||||
return client;
|
||||
return client
|
||||
}
|
||||
|
||||
client.on('error', (error) => {
|
||||
console.log("Client Error", error)
|
||||
})
|
||||
|
||||
client.on('end', (resone) => {
|
||||
console.log("Client End Resone:", resone)
|
||||
client = createConnection('192.168.2.5', 25577, username)
|
||||
})
|
||||
function attachCommon(client) {
|
||||
client.on('error', (error) => {
|
||||
console.log("Client Error", error)
|
||||
})
|
||||
client.on('end', (resone) => {
|
||||
console.log("Client End Resone:", resone)
|
||||
if (`${resone}` != "SocketClosed") {
|
||||
setTimeout(() => {
|
||||
client = commandLineCreateClient()
|
||||
}, 500)
|
||||
} else {
|
||||
process.exit(0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
@@ -54,22 +73,22 @@ const rl = createInterface({
|
||||
rl.on('line', function (line) {
|
||||
switch (line) {
|
||||
case "":
|
||||
break;
|
||||
break
|
||||
case "eval":
|
||||
break;
|
||||
break
|
||||
case "write":
|
||||
break;
|
||||
break
|
||||
case "/respawn":
|
||||
client.write('client_command', { payload: 0 })
|
||||
break;
|
||||
break
|
||||
case "//reco":
|
||||
client.end("")
|
||||
client = createConnection('192.168.2.5', 25577, username)
|
||||
break;
|
||||
client = commandLineCreateClient()
|
||||
break
|
||||
case "//quit":
|
||||
console.info('Disconnected')
|
||||
client.end("")
|
||||
break;
|
||||
break
|
||||
case "//end":
|
||||
console.info('Forcibly ended client')
|
||||
process.exit(0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/common",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,11 +19,11 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"@javatypes/jdk": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/compile",
|
||||
"version": "0.9.0",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript compile package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -21,6 +21,6 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/container",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript container package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,10 +19,10 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"inversify": "^5.0.1",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import "reflect-metadata"
|
||||
import { initContainer, getContainer } from './decorators'
|
||||
import { interfaces, Container } from 'inversify'
|
||||
import { interfaces, Container, inject, named } from 'inversify'
|
||||
import { fluentProvide } from 'inversify-binding-decorators'
|
||||
import { ioc } from "./constants"
|
||||
|
||||
@@ -59,22 +59,20 @@ export const JSClass = (className: string) => {
|
||||
* 自动注入实例由平台实现
|
||||
* @param className 类名
|
||||
*/
|
||||
export const Autowired = (className?: string | any) => {
|
||||
export const Autowired = (className?: any) => {
|
||||
return function (target: any, propertyKey: string, index?: number) {
|
||||
let container = getContainer()
|
||||
if (className instanceof Symbol || className instanceof Function) {
|
||||
return inject(className)(target, propertyKey, index)
|
||||
}
|
||||
let type = Reflect.getMetadata('design:type', target, propertyKey)
|
||||
if (type && type !== Object) {
|
||||
try {
|
||||
return target[propertyKey] = container.getNamed(type, className || propertyKey)
|
||||
} catch (error) {
|
||||
try {
|
||||
return target[propertyKey] = container.get(type)
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (container.isBound(ioc.Autowired)) {
|
||||
inject(type)(target, propertyKey, index)
|
||||
named(className || propertyKey)(target, propertyKey, index)
|
||||
} else if (container.isBound(ioc.Autowired)) {
|
||||
target[propertyKey] = container.getNamed(ioc.Autowired, className || propertyKey)
|
||||
} else {
|
||||
throw new Error(`No matching bindings found for target: ${target.constructor.name} type: ${type} named: ${className || propertyKey}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/core",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -21,11 +21,11 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/container": "^0.9.4"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/database",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript database package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,10 +22,10 @@
|
||||
"@javatypes/spring-jdbc": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/container": "^0.9.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/i18n",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript i18n package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,11 +19,11 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "^3.14.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/keyvalue",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript keyvalue package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,18 +19,18 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"@javatypes/amqp-client": "^0.0.2",
|
||||
"@javatypes/spring-amqp": "^0.0.2",
|
||||
"@javatypes/spring-rabbit": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"gitHead": "2589633069d24f646ac09261b1b2304c21d4ea75"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/nashorn",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,6 +22,6 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/nodejs",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript nodejs package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,10 +19,10 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/nukkit",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript nukkit package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,11 +22,11 @@
|
||||
"@javatypes/nukkit-api": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/ployfill",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript ployfill package",
|
||||
"author": "MiaoWoo <admin@yumc.pw>",
|
||||
"homepage": "https://github.com/circlecloud/ms.git",
|
||||
@@ -14,14 +14,14 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/i18n": "^0.9.3",
|
||||
"@ccms/nodejs": "^0.9.3",
|
||||
"@ccms/i18n": "^0.9.4",
|
||||
"@ccms/nodejs": "^0.9.4",
|
||||
"core-js": "^3.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/plugin",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.7",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,13 +22,13 @@
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3",
|
||||
"@ccms/i18n": "^0.9.3",
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4",
|
||||
"@ccms/i18n": "^0.9.4",
|
||||
"js-yaml": "^3.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,35 @@
|
||||
import { command, plugin, server } from '@ccms/api'
|
||||
import { provideSingleton, postConstruct, inject } from '@ccms/container'
|
||||
import { provideSingleton, inject, Autowired } from '@ccms/container'
|
||||
import { getPluginCommandMetadata, getPluginTabCompleterMetadata } from './utils'
|
||||
|
||||
@provideSingleton(PluginCommandManager)
|
||||
export class PluginCommandManager {
|
||||
@inject(server.ServerChecker)
|
||||
private ServerChecker: server.ServerChecker
|
||||
@inject(command.Command)
|
||||
@Autowired()
|
||||
private CommandManager: command.Command
|
||||
@Autowired()
|
||||
private ServerChecker: server.ServerChecker
|
||||
|
||||
constructor() {
|
||||
process.on('plugin.before.enable', (plugin: plugin.Plugin) => this.registryCommand(plugin))
|
||||
process.on('plugin.after.disable', (plugin: plugin.Plugin) => this.unregistryCommand(plugin))
|
||||
process.on('plugin.before.enable', this.registryCommand.bind(this))
|
||||
process.on('plugin.after.disable', this.unregistryCommand.bind(this))
|
||||
}
|
||||
|
||||
private registryCommand(pluginInstance: plugin.Plugin) {
|
||||
let cmds = getPluginCommandMetadata(pluginInstance)
|
||||
let tabs = getPluginTabCompleterMetadata(pluginInstance)
|
||||
for (const [_, cmd] of cmds) {
|
||||
let tab = tabs.get(cmd.name)
|
||||
if (!this.ServerChecker.check(cmd.servers)) { continue }
|
||||
this.CommandManager.on(pluginInstance, cmd.name, {
|
||||
cmd: pluginInstance[cmd.executor].bind(pluginInstance),
|
||||
tab: tab ? pluginInstance[tab.executor].bind(pluginInstance) : undefined
|
||||
})
|
||||
for (const cmd of cmds) {
|
||||
if (!this.ServerChecker.check(cmd.servers)) {
|
||||
console.debug(`[${pluginInstance.description.name}] ${cmd.target.constructor.name} incompatible command ${cmd.name} server(${cmd.servers}) ignore.`)
|
||||
continue
|
||||
}
|
||||
for (let command of [cmd.name, ...cmd.alias]) {
|
||||
this.CommandManager.on(pluginInstance, command, {
|
||||
cmd: pluginInstance[cmd.executor].bind(pluginInstance),
|
||||
tab: tabs.has(command) ?
|
||||
pluginInstance[tabs.get(command).executor].bind(pluginInstance) :
|
||||
console.debug(`[${pluginInstance.description.name}] command ${cmd.name} is not registry tabCompleter`)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import * as yaml from 'js-yaml'
|
||||
import * as fs from '@ccms/common/dist/fs'
|
||||
import { plugin } from '@ccms/api'
|
||||
import { provideSingleton } from '@ccms/container'
|
||||
|
||||
import { interfaces } from './interfaces'
|
||||
import { getPluginConfigMetadata } from './utils'
|
||||
|
||||
export interface PluginConfigLoader {
|
||||
@@ -13,7 +16,7 @@ export class YamlPluginConfig implements PluginConfigLoader {
|
||||
return yaml.safeLoad(content)
|
||||
}
|
||||
dump(variable: any): string {
|
||||
return yaml.safeDump(variable, { skipInvalid: true })
|
||||
return yaml.safeDump(variable, { skipInvalid: true, lineWidth: 120 })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,63 +25,68 @@ export class JsonPluginConfig implements PluginConfigLoader {
|
||||
return JSON.parse(content)
|
||||
}
|
||||
dump(variable: any): string {
|
||||
return JSON.stringify(variable)
|
||||
return JSON.stringify(variable, undefined, 4)
|
||||
}
|
||||
}
|
||||
|
||||
const configLoaderMap = new Map<string, PluginConfigLoader>()
|
||||
@provideSingleton(PluginConfigManager)
|
||||
export class PluginConfigManager {
|
||||
private configLoaderMap = new Map<string, PluginConfigLoader>()
|
||||
|
||||
export function getConfigLoader(format: string) {
|
||||
if (!configLoaderMap.has(format)) { throw new Error(`Unsupport config format ${format} !`) }
|
||||
return configLoaderMap.get(format)
|
||||
}
|
||||
constructor() {
|
||||
this.configLoaderMap.set("json", new JsonPluginConfig())
|
||||
let yaml = new YamlPluginConfig()
|
||||
this.configLoaderMap.set("yml", yaml)
|
||||
this.configLoaderMap.set("yaml", yaml)
|
||||
process.on('plugin.before.load', this.loadConfig.bind(this))
|
||||
process.on('plugin.after.disable', this.saveConfig.bind(this))
|
||||
}
|
||||
|
||||
function loadConfig(plugin: plugin.Plugin) {
|
||||
let configs = getPluginConfigMetadata(plugin)
|
||||
for (let [_, config] of configs) {
|
||||
try {
|
||||
let configFile = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, config.name + '.' + config.format)
|
||||
let configFactory = getConfigLoader(config.format)
|
||||
if (!fs.exists(configFile)) {
|
||||
base.save(configFile, configFactory.dump(plugin[config.variable]))
|
||||
console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: config.name, format: config.format })
|
||||
} else {
|
||||
Object.defineProperty(plugin, config.variable, { value: configFactory.load(base.read(configFile)) })
|
||||
plugin[config.variable].save = () => {
|
||||
let result = configFactory.dump(plugin[config.variable])
|
||||
base.save(configFile, result)
|
||||
console.debug(`[${plugin.description.name}] Save Config ${config.variable} to file ${configFile} result ${result}`)
|
||||
getConfigLoader(format: string) {
|
||||
if (!this.configLoaderMap.has(format)) { throw new Error(`Unsupport config format ${format} !`) }
|
||||
return this.configLoaderMap.get(format)
|
||||
}
|
||||
|
||||
loadConfig(plugin: plugin.Plugin) {
|
||||
let configs = getPluginConfigMetadata(plugin)
|
||||
for (let [_, config] of configs) {
|
||||
try {
|
||||
config.file = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, config.filename)
|
||||
let configLoader = this.getConfigLoader(config.format)
|
||||
if (!fs.exists(config.file)) {
|
||||
base.save(config.file, configLoader.dump(plugin[config.variable]))
|
||||
console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: config.name, format: config.format })
|
||||
} else {
|
||||
Object.defineProperty(plugin, config.variable, { value: configLoader.load(base.read(config.file)) })
|
||||
plugin[config.variable].save = () => this.saveConfig0(plugin, config)
|
||||
console.debug(`[${plugin.description.name}] Load Config ${config.variable} from file ${config.file} =>\n${JSON.stringify(plugin[config.variable], undefined, 4)}`)
|
||||
}
|
||||
console.debug(`[${plugin.description.name}] Load Config ${config.variable} from file ${configFile} result ${JSON.stringify(plugin[config.variable])}`)
|
||||
} catch (error) {
|
||||
console.i18n("ms.plugin.manager.config.load.error", { plugin: plugin.description.name, name: config.name, format: config.format, error })
|
||||
console.ex(error)
|
||||
}
|
||||
} catch (error) {
|
||||
console.i18n("ms.plugin.manager.config.load.error", { plugin: plugin.description.name, name: config.name, format: config.format, error })
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveConfig(plugin: plugin.Plugin) {
|
||||
let configs = getPluginConfigMetadata(plugin)
|
||||
for (let [_, config] of configs) {
|
||||
saveConfig(plugin: plugin.Plugin) {
|
||||
let configs = getPluginConfigMetadata(plugin)
|
||||
for (let [_, config] of configs) {
|
||||
this.saveConfig0(plugin, config)
|
||||
}
|
||||
}
|
||||
|
||||
private saveConfig0(plugin: plugin.Plugin, metadata: interfaces.ConfigMetadata) {
|
||||
try {
|
||||
let configFile = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, config.name + '.' + config.format)
|
||||
let configFactory = getConfigLoader(config.format)
|
||||
if (!config.readonly) { base.save(configFile, configFactory.dump(plugin[config.variable])) }
|
||||
if (metadata.readonly) { console.debug(`[${plugin.description.name}] Skip Save Config ${metadata.variable} Because it's readonly!`) }
|
||||
metadata.file = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, metadata.filename)
|
||||
let result = this.getConfigLoader(metadata.format).dump(plugin[metadata.variable])
|
||||
base.save(metadata.file, result)
|
||||
console.debug(`[${plugin.description.name}] Save Config ${metadata.variable} to file ${metadata.file} =>\n${result}`)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.i18n("ms.plugin.manager.config.save.error", { plugin: plugin.description.name, name: config.name, format: config.format, error })
|
||||
console.i18n("ms.plugin.manager.config.save.error", { plugin: plugin.description.name, name: metadata.name, format: metadata.format, error })
|
||||
console.ex(error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
configLoaderMap.set("json", new JsonPluginConfig())
|
||||
let yaml = new YamlPluginConfig()
|
||||
configLoaderMap.set("yml", yaml)
|
||||
configLoaderMap.set("yaml", yaml)
|
||||
process.on('plugin.before.load', loadConfig)
|
||||
process.on('plugin.after.load', saveConfig)
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const METADATA_KEY = {
|
||||
plugin: Symbol.for("@ccms/plugin:plugin"),
|
||||
souece: Symbol.for("@ccms/plugin:souece"),
|
||||
source: Symbol.for("@ccms/plugin:source"),
|
||||
cmd: Symbol.for("@ccms/plugin:cmd"),
|
||||
tab: Symbol.for("@ccms/plugin:tab"),
|
||||
listener: Symbol.for("@ccms/plugin:listener"),
|
||||
@@ -10,4 +10,4 @@ export const METADATA_KEY = {
|
||||
enable: Symbol.for("@ccms/plugin:stage:enable"),
|
||||
disable: Symbol.for("@ccms/plugin:stage:disable")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export function plugin(metadata: pluginApi.PluginMetadata | any) {
|
||||
Reflect.defineMetadata(METADATA_KEY.plugin, previousMetadata, Reflect)
|
||||
const previousSources: Map<string, pluginApi.PluginMetadata> = getPluginSources()
|
||||
previousSources.set(metadata.source.toString(), metadata)
|
||||
Reflect.defineMetadata(METADATA_KEY.souece, previousSources, Reflect)
|
||||
Reflect.defineMetadata(METADATA_KEY.source, previousSources, Reflect)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,11 @@ export function plugin(metadata: pluginApi.PluginMetadata | any) {
|
||||
export function cmd(metadata: interfaces.CommandMetadata = {}) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || key
|
||||
metadata.alias = metadata.alias || []
|
||||
metadata.target = target
|
||||
metadata.executor = key
|
||||
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
|
||||
const previousMetadata: Map<string, interfaces.CommandMetadata> = getPluginCommandMetadata(target)
|
||||
previousMetadata.set(metadata.name, metadata)
|
||||
metadata.alias?.forEach((name) => previousMetadata.set(name, metadata))
|
||||
Reflect.defineMetadata(METADATA_KEY.cmd, previousMetadata, target.constructor)
|
||||
Reflect.defineMetadata(METADATA_KEY.cmd, [metadata, ...getPluginCommandMetadata(target)], target.constructor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +46,11 @@ export function tab(metadata: interfaces.CommandMetadata = {}) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || (key.startsWith('tab') ? key.split('tab', 2)[1] : key)
|
||||
if (!metadata.name) { return }
|
||||
metadata.alias = metadata.alias || []
|
||||
metadata.target = target
|
||||
metadata.executor = key
|
||||
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
|
||||
const previousMetadata: Map<string, interfaces.CommandMetadata> = getPluginTabCompleterMetadata(target)
|
||||
let previousMetadata = getPluginTabCompleterMetadata(target)
|
||||
previousMetadata.set(metadata.name, metadata)
|
||||
metadata.alias?.forEach((name) => previousMetadata.set(name, metadata))
|
||||
Reflect.defineMetadata(METADATA_KEY.tab, previousMetadata, target.constructor)
|
||||
@@ -67,8 +66,7 @@ export function listener(metadata: interfaces.ListenerMetadata = {}) {
|
||||
metadata.name = metadata.name || key
|
||||
metadata.target = target
|
||||
metadata.executor = key
|
||||
const previousMetadata: interfaces.ListenerMetadata[] = getPluginListenerMetadata(target)
|
||||
Reflect.defineMetadata(METADATA_KEY.listener, [metadata, ...previousMetadata], target.constructor)
|
||||
Reflect.defineMetadata(METADATA_KEY.listener, [metadata, ...getPluginListenerMetadata(target)], target.constructor)
|
||||
Reflect.defineMetadata(METADATA_KEY.listener, metadata, target[key])
|
||||
}
|
||||
}
|
||||
@@ -79,7 +77,8 @@ export function config(metadata: interfaces.ConfigMetadata = {}) {
|
||||
metadata.variable = key
|
||||
metadata.version = metadata.version ?? 1
|
||||
metadata.format = metadata.format ?? 'yml'
|
||||
const previousMetadata: Map<string, interfaces.ConfigMetadata> = getPluginConfigMetadata(target)
|
||||
metadata.filename = metadata.filename ?? metadata.name + '.' + metadata.format
|
||||
let previousMetadata = getPluginConfigMetadata(target)
|
||||
previousMetadata.set(metadata.name, metadata)
|
||||
Reflect.defineMetadata(METADATA_KEY.config, previousMetadata, target.constructor)
|
||||
}
|
||||
@@ -90,8 +89,7 @@ function stage(stage: string) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || key
|
||||
metadata.executor = key
|
||||
const previousMetadata: interfaces.ExecMetadata[] = getPluginStageMetadata(target, stage)
|
||||
Reflect.defineMetadata(METADATA_KEY.stage[stage], [metadata, ...previousMetadata], target.constructor)
|
||||
Reflect.defineMetadata(METADATA_KEY.stage[stage], [metadata, ...getPluginStageMetadata(target, stage)], target.constructor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
import { event, plugin, server } from '@ccms/api'
|
||||
import { provideSingleton, postConstruct, inject } from '@ccms/container'
|
||||
import { provideSingleton, Autowired } from '@ccms/container'
|
||||
import { getPluginListenerMetadata } from './utils'
|
||||
|
||||
@provideSingleton(PluginEventManager)
|
||||
export class PluginEventManager {
|
||||
@inject(server.ServerChecker)
|
||||
private ServerChecker: server.ServerChecker
|
||||
@inject(event.Event)
|
||||
@Autowired()
|
||||
private EventManager: event.Event
|
||||
@Autowired()
|
||||
private ServerChecker: server.ServerChecker
|
||||
|
||||
constructor() {
|
||||
process.on('plugin.before.enable', (plugin: plugin.Plugin) => this.registryListener(plugin))
|
||||
process.on('plugin.after.disable', (plugin: plugin.Plugin) => this.unregistryListener(plugin))
|
||||
process.on('plugin.before.enable', this.registryListener.bind(this))
|
||||
process.on('plugin.after.disable', this.unregistryListener.bind(this))
|
||||
}
|
||||
|
||||
mapEventName() {
|
||||
return this.EventManager.mapEventName().toFixed(0)
|
||||
}
|
||||
|
||||
private registryListener(pluginInstance: plugin.Plugin) {
|
||||
let events = getPluginListenerMetadata(pluginInstance)
|
||||
for (const event of events) {
|
||||
// ignore space listener
|
||||
if (!this.ServerChecker.check(event.servers)) { continue }
|
||||
if (!this.ServerChecker.check(event.servers)) {
|
||||
console.debug(`[${pluginInstance.description.name}] ${event.target.constructor.name} incompatible event ${event.name} server(${event.servers}) ignore.`)
|
||||
continue
|
||||
}
|
||||
// here must bind this to pluginInstance
|
||||
let exec = event.target[event.executor]
|
||||
let execBinded = exec.bind(pluginInstance)
|
||||
|
||||
@@ -75,5 +75,13 @@ export namespace interfaces {
|
||||
* 是否为只读(关闭时将不会自动保存)
|
||||
*/
|
||||
readonly?: boolean
|
||||
/**
|
||||
* 配置文件名称
|
||||
*/
|
||||
filename?: string
|
||||
/**
|
||||
* 配置文件全路径
|
||||
*/
|
||||
file?: any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { plugin, server } from "@ccms/api"
|
||||
import { inject, ContainerInstance, Container, provideSingletonNamed } from "@ccms/container"
|
||||
import { inject, ContainerInstance, Container, provideSingletonNamed, Autowired } from "@ccms/container"
|
||||
|
||||
import { interfaces } from "../interfaces"
|
||||
import { getPluginStageMetadata, getPluginSources } from "../utils"
|
||||
@@ -11,7 +11,7 @@ export class IocLoader implements plugin.PluginLoader {
|
||||
type: string = LOADER_TYPE_NAME
|
||||
@inject(ContainerInstance)
|
||||
private container: Container
|
||||
@inject(server.ServerChecker)
|
||||
@Autowired()
|
||||
private serverChecker: server.ServerChecker
|
||||
|
||||
private pluginMetadataMap: Map<string, plugin.PluginMetadata>
|
||||
@@ -69,7 +69,7 @@ export class IocLoader implements plugin.PluginLoader {
|
||||
console.i18n('ms.plugin.manager.build.duplicate', { exists: pluginInstance.description.source, source: metadata.source })
|
||||
}
|
||||
this.container.rebind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
|
||||
} catch{
|
||||
} catch {
|
||||
this.container.bind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import i18n from '@ccms/i18n'
|
||||
import { plugin, server, event } from '@ccms/api'
|
||||
import { inject, provideSingleton, Container, ContainerInstance } from '@ccms/container'
|
||||
import { inject, provideSingleton, Container, ContainerInstance, Autowired } from '@ccms/container'
|
||||
|
||||
import './config'
|
||||
import { interfaces } from './interfaces'
|
||||
import { PluginTaskManager } from './task'
|
||||
import { PluginEventManager } from './event'
|
||||
import { PluginCommandManager } from './command'
|
||||
import { PluginConfigManager } from './config'
|
||||
|
||||
const Thread = Java.type('java.lang.Thread')
|
||||
|
||||
@@ -18,16 +19,17 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
private pluginInstance: any
|
||||
@inject(server.ServerType)
|
||||
private serverType: string
|
||||
@inject(event.Event)
|
||||
private EventManager: event.Event
|
||||
@inject(server.ServerChecker)
|
||||
|
||||
@Autowired()
|
||||
private serverChecker: server.ServerChecker
|
||||
|
||||
@inject(PluginTaskManager)
|
||||
@Autowired()
|
||||
private taskManager: PluginTaskManager
|
||||
@inject(PluginEventManager)
|
||||
@Autowired()
|
||||
private eventManager: PluginEventManager
|
||||
@inject(PluginCommandManager)
|
||||
@Autowired()
|
||||
private configManager: PluginConfigManager
|
||||
@Autowired()
|
||||
private commandManager: PluginCommandManager
|
||||
|
||||
private initialized: boolean = false
|
||||
@@ -48,6 +50,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
// ignore unused
|
||||
this.taskManager
|
||||
this.eventManager
|
||||
this.configManager
|
||||
this.commandManager
|
||||
}
|
||||
|
||||
@@ -55,7 +58,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
if (this.pluginInstance === undefined) { throw new Error("Can't found Plugin Instance!") }
|
||||
if (this.initialized !== true) {
|
||||
console.i18n('ms.plugin.initialize', { plugin: this.pluginInstance, loader: Thread.currentThread().contextClassLoader })
|
||||
console.i18n('ms.plugin.event.map', { count: this.EventManager.mapEventName().toFixed(0), type: this.serverType })
|
||||
console.i18n('ms.plugin.event.map', { count: this.eventManager.mapEventName(), type: this.serverType })
|
||||
let pluginScanner = this.container.getAll<plugin.PluginScanner>(plugin.PluginScanner)
|
||||
pluginScanner.forEach((scanner) => {
|
||||
console.debug(`loading plugin sacnner ${scanner.type}...`)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { plugin, task } from '@ccms/api'
|
||||
import { provideSingleton, inject } from '@ccms/container'
|
||||
import { provideSingleton, Autowired } from '@ccms/container'
|
||||
|
||||
@provideSingleton(PluginTaskManager)
|
||||
export class PluginTaskManager {
|
||||
@inject(task.TaskManager)
|
||||
@Autowired()
|
||||
private taskManager: task.TaskManager
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -14,7 +14,7 @@ function getPlugin(name: string) {
|
||||
|
||||
function getPluginSources() {
|
||||
let pluginSources: Map<string, plugin.PluginMetadata> = Reflect.getMetadata(
|
||||
METADATA_KEY.souece,
|
||||
METADATA_KEY.source,
|
||||
Reflect
|
||||
) || pluginSourceCache
|
||||
return pluginSources
|
||||
@@ -37,10 +37,10 @@ function getPluginMetadata(target: any) {
|
||||
}
|
||||
|
||||
function getPluginCommandMetadata(target: any) {
|
||||
let commandMetadata: Map<string, interfaces.CommandMetadata> = Reflect.getMetadata(
|
||||
let commandMetadata: interfaces.CommandMetadata[] = Reflect.getMetadata(
|
||||
METADATA_KEY.cmd,
|
||||
target.constructor
|
||||
) || new Map<string, interfaces.CommandMetadata>()
|
||||
) || []
|
||||
return commandMetadata
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
- 玩家兑换公告
|
||||
- 配置兑换比例
|
||||
- 服务器信息查询
|
||||
|
||||
- 玩家请求授权
|
||||
- 玩家扫码
|
||||
- 玩家扫码确认
|
||||
- 玩家扫码兑换完成
|
||||
- 腐竹扫码确认
|
||||
- 腐竹扫码完成
|
||||
## 插件命令
|
||||
```
|
||||
>mrd
|
||||
@@ -36,15 +41,66 @@
|
||||
## 插件安装/配置
|
||||
|
||||
### 基础准备工作
|
||||
- 申请内测服务器账号
|
||||
- QQ搜索小程序 `圈云盒子` 并登录
|
||||
- 申请内测服务器账号 个人中心 => 配置面板 => 圈云盒子客服群 加群申请
|
||||
|
||||
### 服务器准备工作
|
||||
- 先安装 `MiaoScript` [站内地址]()
|
||||
- 执行 `mpm install MiaoReward`
|
||||
- 可以通过 Yum 快速安装 `/yum install MiaoScript`
|
||||
- 等待 MiaoScript 引擎启动完成(首次启动可能需要10-20秒 依赖于您的网络环境)
|
||||
- 执行 `/mspm install MiaoReward`
|
||||
|
||||
### 绑定服务器
|
||||
- 执行 `/mrd bind server`
|
||||
- 使用QQ扫码
|
||||
- 选择需要绑定的服务器
|
||||
- 完成绑定
|
||||
- 配置服务器兑换比例
|
||||
- 执行 `/mrd ratio 0.001` (最低为 1:0.0001)
|
||||
- 执行兑换比例确认指令
|
||||
- 执行 `/mrd server` 查看服务器信息
|
||||
- 如需绑定多台 可以直接复制绑定之后的 `MiaoScript/plugins/MiaoReward/config.yml` 文件到多台服务器上 然后 `/mrd reload` 重载插件
|
||||
|
||||
### QQ群配置
|
||||
- 打开小程序
|
||||
- 登录
|
||||
- 个人中心 => 设置面板 => 添加到群应用 => 选择你的QQ群
|
||||
- 配置群快捷栏 个人中心 => 设置面板 => 查看设置群快捷栏
|
||||
- 配置结果
|
||||
|
||||
### 玩家绑定账号
|
||||
- 执行 `/mrd bind`
|
||||
- 使用QQ扫码
|
||||
- 完成绑定
|
||||
|
||||
## 使用说明
|
||||
- 玩家可以通过下列方式获取喵币
|
||||
- 签到 5-10 喵币
|
||||
- 视频广告 5-15 喵币
|
||||
- 盒子广告 5-15 喵币
|
||||
- 获得的喵币可以在服务器兑换成对应的奖励
|
||||
- 腐竹可以在平台将喵币兑换成RMB(兑换比例请加群联系客服详谈)
|
||||
- 登录小程序后 个人中心 => 配置面板 => 圈云盒子客服群
|
||||
|
||||
## 配置文件
|
||||
|
||||
``` yaml
|
||||
# 服务器ID
|
||||
serverId: '16'
|
||||
# 服务器Token
|
||||
serverToken: d50d3f6e-2a59-460a-2b29-82b66c4bbf52
|
||||
# 兑换指令
|
||||
drawCommand: 'p give %player_name% %amount%'
|
||||
# 冷却时间
|
||||
drawCooldown: 300
|
||||
# 提示前缀
|
||||
prefix: '§6[§b广告系统§6]§r'
|
||||
```
|
||||
|
||||
## Roadmap
|
||||
- 绑定服务器(已完成)
|
||||
- 绑定玩家(已完成)
|
||||
- 兑换喵币(已完成)
|
||||
- 自助开通服务器(开发中)
|
||||
- 自助兑换RMB(开发中)
|
||||
- 自助提现(开发中)
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@ccms/plugins",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.7",
|
||||
"description": "MiaoScript plugins package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -25,11 +25,11 @@
|
||||
"@javatypes/tomcat": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3",
|
||||
"@ccms/plugin": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/container": "^0.9.4",
|
||||
"@ccms/plugin": "^0.9.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/// <reference types="@javatypes/spigot-api" />
|
||||
/// <reference types="@javatypes/sponge-api" />
|
||||
|
||||
import { server, plugin as pluginApi, channel, constants, chat } from '@ccms/api'
|
||||
import { inject, optional } from '@ccms/container'
|
||||
import { server, channel, constants, chat } from '@ccms/api'
|
||||
import { optional, Autowired } from '@ccms/container'
|
||||
import { plugin, interfaces, cmd, listener, tab, config, enable } from '@ccms/plugin'
|
||||
import Tellraw from '@ccms/common/dist/tellraw'
|
||||
|
||||
@@ -52,12 +52,13 @@ class MiaoMessage {
|
||||
|
||||
@plugin({ name: 'MiaoChat', version: '1.0.0', author: 'MiaoWoo', source: __filename })
|
||||
export class MiaoChat extends interfaces.Plugin {
|
||||
@inject(server.Server)
|
||||
@Autowired()
|
||||
private Server: server.Server
|
||||
@inject(chat.Chat)
|
||||
@optional()
|
||||
@Autowired()
|
||||
private chat: chat.Chat
|
||||
@inject(channel.Channel)
|
||||
@optional() private Channel: channel.Channel
|
||||
@Autowired()
|
||||
private Channel: channel.Channel
|
||||
|
||||
private channelOff: { off: () => void }
|
||||
|
||||
@@ -169,6 +170,11 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
return string
|
||||
}
|
||||
}
|
||||
if (!this.chat) {
|
||||
this.logger.console('§4消息管理器注入失败 请检查当前服务器是否兼容...')
|
||||
this.AsyncPlayerChatEvent['off']()
|
||||
this.MessageChannelEvent$Chat['off']()
|
||||
}
|
||||
}
|
||||
|
||||
disable() {
|
||||
@@ -227,13 +233,13 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
})
|
||||
}
|
||||
|
||||
@cmd({ servers: ["bungee"] })
|
||||
@cmd({ servers: [constants.ServerType.Bungee] })
|
||||
mct(sender: any, command: string, args: string[]) {
|
||||
this.logger.log(sender, command, args)
|
||||
sender.sendMessage(JSON.stringify({ command, ...args }))
|
||||
}
|
||||
|
||||
@cmd({ servers: ["!bungee"] })
|
||||
@cmd({ servers: [`!${constants.ServerType.Bungee}`] })
|
||||
mchat(sender: any, command: string, args: string[]) {
|
||||
this.logger.log(sender, command, args)
|
||||
sender.sendMessage(JSON.stringify({ command, ...args }))
|
||||
@@ -243,12 +249,12 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
tabmchat(_sender: any, _command: string, _args: string[]) {
|
||||
}
|
||||
|
||||
@listener({ servers: ['bukkit'] })
|
||||
@listener({ servers: [constants.ServerType.Bukkit] })
|
||||
AsyncPlayerChatEvent(event: org.bukkit.event.player.AsyncPlayerChatEvent) {
|
||||
this.sendChat(event.getPlayer(), event.getMessage(), () => event.setCancelled(true))
|
||||
}
|
||||
|
||||
@listener({ servers: ['sponge'] })
|
||||
@listener({ servers: [constants.ServerType.Sponge] })
|
||||
MessageChannelEvent$Chat(event: org.spongepowered.api.event.message.MessageChannelEvent.Chat) {
|
||||
//@ts-ignore
|
||||
var player = event.getCause().first(org.spongepowered.api.entity.living.player.Player.class).orElse(null)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { constants, task, server, channel, chat } from "@ccms/api"
|
||||
import { constants, task, server, channel, chat, proxy } from "@ccms/api"
|
||||
import { JSPlugin, interfaces, Cmd, Tab, Listener, Config } from "@ccms/plugin"
|
||||
|
||||
import { QRCode, QRErrorCorrectLevel } from '@ccms/common/dist/qrcode'
|
||||
|
||||
import { Autowired, JSClass, optional, inject } from '@ccms/container'
|
||||
import { Autowired, JSClass, optional } from '@ccms/container'
|
||||
import http from '@ccms/common/dist/http'
|
||||
|
||||
let MapView
|
||||
@@ -54,7 +54,7 @@ interface PlaceholderAPI {
|
||||
setPlaceholders: (player: any, str: string) => string
|
||||
}
|
||||
|
||||
@JSPlugin({ prefix: 'MRD', version: '1.2.3', author: 'MiaoWoo', servers: [constants.ServerType.Bukkit], source: __filename })
|
||||
@JSPlugin({ prefix: 'MRD', version: '1.3.0', author: 'MiaoWoo', servers: [constants.ServerType.Bukkit], source: __filename })
|
||||
export class MiaoReward extends interfaces.Plugin {
|
||||
private serverInfo: any
|
||||
private cacheBindUuid = ''
|
||||
@@ -73,10 +73,11 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
private server: server.Server
|
||||
@Autowired()
|
||||
private taskManager: task.TaskManager
|
||||
@optional()
|
||||
@Autowired()
|
||||
private channel: channel.Channel
|
||||
@Autowired()
|
||||
private bungee: channel.proxy.BungeeCord
|
||||
private bungee: proxy.BungeeCord
|
||||
|
||||
@Config()
|
||||
private config = {
|
||||
@@ -196,7 +197,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
disable() {
|
||||
this.server.getOnlinePlayers().forEach(p => this.checkAndClear(p))
|
||||
Java.from(this.server.getOnlinePlayers()).forEach(p => this.checkAndClear(p))
|
||||
this.channelOff?.off()
|
||||
}
|
||||
|
||||
@@ -240,6 +241,9 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
} else if (result.data.status == "cancel") {
|
||||
this.chat.sendTitle(sender, '§c已取消授权')
|
||||
cancel?.()
|
||||
} else if (result.data.status == "scaned") {
|
||||
this.chat.sendTitle(sender, '§c授权操作超时')
|
||||
cancel?.()
|
||||
} else {
|
||||
this.chat.sendTitle(sender, "§c未知的结果", result.data.status)
|
||||
}
|
||||
@@ -269,7 +273,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (this.drawCooldown.has(sender.getName()) && !sender.isOp()) {
|
||||
if (this.drawCooldown.has(sender.getName()) && !sender.hasPermission('mrd.admin')) {
|
||||
let leftTime = cooldown - (Date.now() - this.drawCooldown.get(sender.getName())) / 1000
|
||||
if (leftTime > 0) {
|
||||
this.logger.sender(sender, `§c扫码功能冷却中 剩余 ${leftTime} 秒!`)
|
||||
@@ -285,6 +289,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
|
||||
cmdbind(sender: org.bukkit.entity.Player, server: boolean) {
|
||||
if (this.bindCheck(sender, 60)) return
|
||||
if (!sender.getItemInHand) { return this.logger.sender(sender, '§c手持物品检测异常 请检查是否在客户端执行命令!') }
|
||||
if (sender.getItemInHand()?.getType() !== Material.AIR) { return this.logger.sender(sender, "§c请空手执行此命令!") }
|
||||
if (server) {
|
||||
if (!sender.isOp()) { return this.logger.sender(sender, '§4您没有配置服务器的权限!') }
|
||||
@@ -296,6 +301,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
cmddraw(sender: org.bukkit.entity.Player, amount: number) {
|
||||
if (!sender.getItemInHand) { return this.logger.sender(sender, '§c手持物品检测异常 请检查是否在客户端执行命令!') }
|
||||
amount = Number(amount)
|
||||
if (!Number.isInteger(amount)) {
|
||||
return this.logger.sender(sender, '§4金额必须是数字!')
|
||||
@@ -340,7 +346,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
this.taskManager.create(() => {
|
||||
let command = this.config.drawCommand.replace('%player_name%', sender.getName()).replace('%amount%', draw.data)
|
||||
if (!this.server.dispatchConsoleCommand(command)) {
|
||||
return this.sendError(sender, '§6执行命令 §3/' + command + ' §c可能存在异常')
|
||||
return this.sendError(sender, ...draw.msg.split('\n'), `§6执行结果: §4已扣除 §c${amount} §4喵币`, `§6执行命令: §3/${command} §c可能存在异常`)
|
||||
}
|
||||
this.logger.sender(sender, draw.msg.split('\n'))
|
||||
this.sendBroadcast(sender, `${this.config.prefix}§6玩家 §b${sender.getName()} §6成功将 §a${amount}喵币 §6兑换成 §c${draw.data}点券!`)
|
||||
@@ -348,10 +354,10 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
}).submit()
|
||||
}
|
||||
|
||||
private sendError(sender, error) {
|
||||
private sendError(sender: any, ...error: string[]) {
|
||||
return this.logger.sender(sender, [
|
||||
`§c========== ${this.config.prefix}§4兑换异常 §c==========`,
|
||||
error,
|
||||
...error,
|
||||
`§6异常账号: §b${sender.getName()}`,
|
||||
`§6异常时间: §a${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,
|
||||
`§c如果喵币被扣除且未得到奖励 请截图发往QQ群!`,
|
||||
@@ -401,6 +407,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
|
||||
cmdratio(sender: any, ratioStr: string, confirm: string) {
|
||||
if (!sender.isOp()) { return this.logger.sender(sender, '§4你没有此命令的权限!') }
|
||||
if (!sender.getItemInHand) { return this.logger.sender(sender, '§c手持物品检测异常 请检查是否在客户端执行命令!') }
|
||||
let [ratio, mbr, msg] = this.ratio2string(ratioStr)
|
||||
if (!confirm) {
|
||||
return this.logger.sender(sender, [
|
||||
@@ -411,17 +418,31 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
])
|
||||
}
|
||||
if (confirm != 'confirm') return this.logger.sender(sender, `§6请执行 §b/mrd ratio §c${ratio} §econfirm §c确认修改!`)
|
||||
let result = this.httpPost(`https://reward.yumc.pw/server/ratio`, {
|
||||
id: this.config.serverId,
|
||||
token: this.config.serverToken,
|
||||
ratio
|
||||
if (this.bindCheck(sender, 60)) return
|
||||
this.scanAuth(sender, "ratio", {
|
||||
title: `是否授权 ${this.serverInfo.name} 调整兑换比例`,
|
||||
content: [
|
||||
`操作玩家: ${sender.getName()}`,
|
||||
`调整前: ${this.serverInfo.ratio}`,
|
||||
`调整后: ${msg.replace(/§./ig, '')}`,
|
||||
'调整结果实时生效!',
|
||||
'跨服端 将自动同步比例!',
|
||||
'非跨服端 请重载插件同步比例!'
|
||||
].join('\n')
|
||||
}, (token) => {
|
||||
let result = this.httpPost(`https://reward.yumc.pw/server/ratio`, {
|
||||
id: this.config.serverId,
|
||||
token: this.config.serverToken,
|
||||
ratio,
|
||||
userToken: token
|
||||
})
|
||||
if (result.code !== 200) {
|
||||
return this.logger.sender(sender, `§4操作异常 §6服务器返回: §c${result.msg}`)
|
||||
}
|
||||
this.logger.sender(sender, `§a操作成功 §6服务器返回: §a${result.msg}`)
|
||||
this.updateServerInfo(sender)
|
||||
this.sendBroadcast(sender, `${this.config.prefix} §6当前兑换比例已调整为 ` + msg)
|
||||
})
|
||||
if (result.code !== 200) {
|
||||
return this.logger.sender(sender, `§4操作异常 §6服务器返回: §c${result.msg}`)
|
||||
}
|
||||
this.logger.sender(sender, `§a操作成功 §6服务器返回: §a${result.msg}`)
|
||||
this.updateServerInfo(sender)
|
||||
this.sendBroadcast(sender, `${this.config.prefix} §6当前兑换比例已调整为 ` + msg)
|
||||
}
|
||||
|
||||
private ratio2string(ratio) {
|
||||
@@ -454,9 +475,9 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
if (check.code == 200) {
|
||||
this.config.serverId = check.data.serverId
|
||||
this.config.serverToken = check.data.serverToken
|
||||
// @ts-ignore
|
||||
this.config.save()
|
||||
this.config['save']()
|
||||
this.logger.sender(sender, '§a已成功绑定服务器: §b' + check.data.serverName)
|
||||
this.updateServerInfo()
|
||||
}
|
||||
sync.scaned = true
|
||||
}).async().submit()
|
||||
@@ -514,6 +535,7 @@ export class MiaoReward extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
private queryUser(sender: org.bukkit.entity.Player, sync = false) {
|
||||
if (!this.config.serverId || !this.config.serverToken) { return this.logger.sender(sender, '§4当前服务器尚未配置绑定ID 请联系腐竹进行配置!') }
|
||||
return this.httpPost(`https://reward.yumc.pw/server/queryUser`, {
|
||||
id: this.config.serverId,
|
||||
token: this.config.serverToken,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { plugin as pluginApi, task, server, plugin, channel, constants } from '@ccms/api'
|
||||
|
||||
import { plugin as pluginApi, task, server, channel, constants, proxy } from '@ccms/api'
|
||||
import { Translate } from '@ccms/i18n'
|
||||
import { inject, DefaultContainer as container, optional, JSClass } from '@ccms/container'
|
||||
import { DefaultContainer as container, JSClass, Autowired } from '@ccms/container'
|
||||
import { interfaces, JSPlugin, Cmd, Tab, enable, Listener, disable } from '@ccms/plugin'
|
||||
|
||||
import * as fs from '@ccms/common/dist/fs'
|
||||
@@ -10,16 +9,16 @@ import http from '@ccms/common/dist/http'
|
||||
|
||||
let help = [
|
||||
'§6========= §6[§aMiaoScriptPackageManager§6] 帮助 §aBy §bMiaoWoo §6=========',
|
||||
'§6/mpm §ainstall §e<插件名称> §6- §3安装仓库插件',
|
||||
'§6/mpm §aload §e<插件名称> §6- §3安装本地插件',
|
||||
'§6/mpm §aunload §e<插件名称> §6- §3卸载已安装插件',
|
||||
'§6/mpm §areload §e<插件名称> §6- §3重载已安装插件(无名称则重载自身)',
|
||||
'§6/mpm §alist [i] §6- §3列出仓库插件[已安装的插件]',
|
||||
'§6/mpm §aupdate §e[插件名称] §6- §3更新插件(无名称则更新源)',
|
||||
'§6/mpm §aupgrade §e[插件名称] §6- §3升级插件/框架(§4无名称则升级框架§3)',
|
||||
'§6/mpm §arun §e<JS代码> §6- §3运行JS代码',
|
||||
'§6/mpm §adeploy §e<插件名称> §6- §3发布插件',
|
||||
'§6/mpm §crestart §6- §4重启MiaoScript脚本引擎'
|
||||
'§6/mspm §ainstall §e<插件名称> §6- §3安装仓库插件',
|
||||
'§6/mspm §aload §e<插件名称> §6- §3安装本地插件',
|
||||
'§6/mspm §aunload §e<插件名称> §6- §3卸载已安装插件',
|
||||
'§6/mspm §areload §e<插件名称> §6- §3重载已安装插件(无名称则重载自身)',
|
||||
'§6/mspm §alist [i] §6- §3列出仓库插件[已安装的插件]',
|
||||
'§6/mspm §aupdate §e[插件名称] §6- §3更新插件(无名称则更新源)',
|
||||
'§6/mspm §aupgrade §e[插件名称] §6- §3升级插件/框架(§4无名称则升级框架§3)',
|
||||
'§6/mspm §arun §e<JS代码> §6- §3运行JS代码',
|
||||
'§6/mspm §adeploy §e<插件名称> §6- §3发布插件',
|
||||
'§6/mspm §crestart §6- §4重启MiaoScript脚本引擎'
|
||||
]
|
||||
|
||||
let langMap = {
|
||||
@@ -27,9 +26,15 @@ let langMap = {
|
||||
'main.command.help.tip': '§6请执行 §b/{command} §ahelp §6查看帮助!',
|
||||
'main.command.no.permission': '§c你没有此命令的权限!',
|
||||
'list.install.header': '§6当前 §bMiaoScript §6已安装下列插件:',
|
||||
'list.install.body': '§6插件名称: §b{name} §6版本: §a{version}\n§6作者: §3{author} §6来源: §c{from}',
|
||||
'list.install.body': `§6┌插件名称: §b{name}
|
||||
§6├版本: §a{version}
|
||||
§6├作者: §3{author}
|
||||
§6└来源: §c{from}`,
|
||||
'list.header': '§6当前 §bMiaoScriptPackageCenter §6中存在下列插件:',
|
||||
'list.body': '§6插件名称: §b{name} §6版本: §a{version}\n§6作者: §3{author} §6更新时间: §9{updated_at}',
|
||||
'list.body': `§6┌插件名称: §b{name}
|
||||
§6├版本: §a{version}
|
||||
§6├作者: §3{author}
|
||||
§6└更新时间: §9{updated_at}`,
|
||||
'plugin.not.exists': '§6插件 §b{name} §c不存在!',
|
||||
'plugin.unload.start': '§c开始卸载 §6插件 §b{name} §6版本 §3{version}!',
|
||||
'plugin.unload.finish': '§6插件 §b{name} §6版本 §3{version} §a已卸载!',
|
||||
@@ -49,6 +54,7 @@ let langMap = {
|
||||
'deploy.token.not.exists': '§4请先配置发布Token!',
|
||||
'deploy.success': '§6插件 §b{name} §6版本 §3{version} §a发布成功! §6服务器返回: §a{msg}',
|
||||
'deploy.fail': '§6插件 §b{name} §6版本 §3{version} §c发布失败! §6服务器返回: §c{msg}',
|
||||
'prun.script': '§6指定插件:§b {name}',
|
||||
'run.script': '§b运行脚本:§r {script}',
|
||||
'run.result': '§a返回结果:§r {result}',
|
||||
'run.noresult': '§4没有返回结果!',
|
||||
@@ -66,34 +72,54 @@ class FakeSender {
|
||||
let FakeSenderAdapter = Java.extend(superclass, {
|
||||
getName: () => this.name,
|
||||
isOp: () => true,
|
||||
sendMessage: (message) => this.plugin.sendBungeeCordMessage(this.name, `§6[§3BPM§6][§a${this.plugin.serverName}§6] ${message}`)
|
||||
hasPermission: () => true,
|
||||
sendMessage: (message) => this.sendMessage(message)
|
||||
})
|
||||
this._proxy = new FakeSenderAdapter()
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
return this.plugin.sendBungeeCordMessage(this.name, `§6[§3BPM§6][§a${this.plugin.serverName}§6] ${message}`)
|
||||
}
|
||||
|
||||
getHandler() {
|
||||
return this._proxy
|
||||
}
|
||||
}
|
||||
|
||||
class BukkitFakeSender extends FakeSender {
|
||||
constructor(name: string, plugin: MiaoScriptPackageManager) {
|
||||
super(name, plugin, Java.type('org.bukkit.command.CommandSender'))
|
||||
}
|
||||
}
|
||||
|
||||
class SpongeFakeSender extends FakeSender {
|
||||
constructor(name: string, plugin: MiaoScriptPackageManager) {
|
||||
super(name, plugin, Java.type('org.spongepowered.api.command.CommandSource'))
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
return super.sendMessage(message.content)
|
||||
}
|
||||
}
|
||||
|
||||
@JSPlugin({ prefix: 'PM', version: '1.3.0', author: 'MiaoWoo', source: __filename })
|
||||
export class MiaoScriptPackageManager extends interfaces.Plugin {
|
||||
@inject(plugin.PluginManager)
|
||||
@Autowired()
|
||||
private pluginManager: pluginApi.PluginManager
|
||||
@inject(task.TaskManager)
|
||||
@Autowired()
|
||||
private taskManager: task.TaskManager
|
||||
@inject(server.ServerType)
|
||||
@Autowired(server.ServerType)
|
||||
private serverType: string
|
||||
@inject(server.Server)
|
||||
@Autowired()
|
||||
private server: server.Server
|
||||
@inject(pluginApi.PluginFolder)
|
||||
@Autowired(pluginApi.PluginFolder)
|
||||
private pluginFolder: string
|
||||
@inject(channel.Channel)
|
||||
@optional() private channel: channel.Channel
|
||||
@Autowired()
|
||||
private channel: channel.Channel
|
||||
@Autowired()
|
||||
private bungee: proxy.BungeeCord
|
||||
|
||||
@JSClass('java.io.ByteArrayOutputStream')
|
||||
private ByteArrayOutputStream: any
|
||||
@JSClass('java.io.DataOutputStream')
|
||||
private DataOutputStream: any
|
||||
@JSClass('com.google.common.io.ByteStreams')
|
||||
private ByteStreams: any
|
||||
|
||||
@@ -139,21 +165,12 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
||||
|
||||
private bungeeCordDetect(player) {
|
||||
if (player) {
|
||||
let byteArray = new this.ByteArrayOutputStream()
|
||||
let out = new this.DataOutputStream(byteArray)
|
||||
out.writeUTF("GetServer")
|
||||
this.channel.send(player, "BungeeCord", byteArray.toByteArray())
|
||||
this.bungee.for(player).getServer().send()
|
||||
}
|
||||
}
|
||||
private bungeeCordForward(player, command) {
|
||||
if (player) {
|
||||
let byteArray = new this.ByteArrayOutputStream()
|
||||
let out = new this.DataOutputStream(byteArray)
|
||||
out.writeUTF("Forward")
|
||||
out.writeUTF("ALL")
|
||||
out.writeUTF("MiaoScriptPackageManager")
|
||||
out.writeUTF(JSON.stringify(command))
|
||||
this.channel.send(player, "BungeeCord", byteArray.toByteArray())
|
||||
this.bungee.for(player).forward("ALL", "MiaoScriptPackageManager", command).send()
|
||||
}
|
||||
}
|
||||
private readForward(input) {
|
||||
@@ -166,9 +183,9 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
||||
private getProxySender(name: string) {
|
||||
switch (this.serverType) {
|
||||
case constants.ServerType.Bukkit:
|
||||
return new FakeSender(name, this, Java.type('org.bukkit.command.CommandSender')).getHandler()
|
||||
return new BukkitFakeSender(name, this).getHandler()
|
||||
case constants.ServerType.Sponge:
|
||||
return new FakeSender(name, this, Java.type('org.spongepowered.api.command.CommandSource')).getHandler()
|
||||
return new SpongeFakeSender(name, this).getHandler()
|
||||
default:
|
||||
return this.server.getConsoleSender()
|
||||
}
|
||||
@@ -193,12 +210,7 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
||||
sendBungeeCordMessage(sender, message) {
|
||||
let players = this.server.getOnlinePlayers()
|
||||
if (players.length) {
|
||||
let byteArray = new this.ByteArrayOutputStream()
|
||||
let out = new this.DataOutputStream(byteArray)
|
||||
out.writeUTF("Message")
|
||||
out.writeUTF(sender)
|
||||
out.writeUTF(message)
|
||||
this.channel.send(players[0], "BungeeCord", byteArray.toByteArray())
|
||||
this.bungee.for(players[0]).message(sender, message).send()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,23 +219,23 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
@Cmd({ servers: [`!${constants.ServerType.Bungee}`] })
|
||||
bmpm(sender: any, command: string, args: string[]) {
|
||||
if (!sender?.isOp()) { return this.i18n(sender, 'main.command.no.permission') }
|
||||
if (!this.isBungeeCord) return this.logger.sender(sender, '§c当前服务器尚未检测到BungeeCord链接...')
|
||||
gmspm(sender: any, command: string, args: string[]) {
|
||||
if (!sender.hasPermission('mspm.admin')) { return this.i18n(sender, 'main.command.no.permission') }
|
||||
if (!this.isBungeeCord) return this.logger.sender(sender, '§c当前服务器尚未检测到 BungeeCord 链接...')
|
||||
this.taskManager.create(() => this.main(sender, command, args)).async().submit()
|
||||
this.bungeeCordForward(sender, { sender: sender.getName(), command, args })
|
||||
this.logger.sender(sender, `§6[§3BPM§6][§a${this.serverName}§6] §6命令 §b/mpm ${args.join?.(' ')} §a发布成功!`)
|
||||
}
|
||||
|
||||
@Cmd({ servers: [constants.ServerType.Bungee] })
|
||||
mpmanager(sender: any, command: string, args: string[]) {
|
||||
if (!sender?.isOp()) { return this.i18n(sender, 'main.command.no.permission') }
|
||||
bungeemspm(sender: any, command: string, args: string[]) {
|
||||
if (!sender.hasPermission('mspm.admin')) { return this.i18n(sender, 'main.command.no.permission') }
|
||||
this.taskManager.create(() => this.main(sender, command, args)).async().submit()
|
||||
}
|
||||
|
||||
@Cmd({ servers: [`!${constants.ServerType.Bungee}`] })
|
||||
mpm(sender: any, command: string, args: string[]) {
|
||||
if (!sender?.isOp()) { return this.i18n(sender, 'main.command.no.permission') }
|
||||
mspm(sender: any, command: string, args: string[]) {
|
||||
if (!sender.hasPermission('mspm.admin')) { return this.i18n(sender, 'main.command.no.permission') }
|
||||
this.taskManager.create(() => this.main(sender, command, args)).async().submit()
|
||||
}
|
||||
|
||||
@@ -376,14 +388,27 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
||||
try {
|
||||
let script = args.join(' ')
|
||||
this.i18n(sender, 'run.script', { script })
|
||||
let result = this.runCode(script, sender)
|
||||
let result = this.runCode(script, sender, this)
|
||||
this.i18n(sender, 'run.result', { result: result == undefined ? this.translate.translate('run.noresult') : result + '' })
|
||||
} catch (ex) {
|
||||
this.logger.sender(sender, this.logger.stack(ex))
|
||||
}
|
||||
}
|
||||
|
||||
private runCode(code: string, sender: any) {
|
||||
cmdprun(sender: any, name: string, ...args: any[]) {
|
||||
try {
|
||||
if (!this.pluginManager.getPlugins().has(name)) { return this.logger.sender(sender, `§4插件 §c${name} §4不存在!`) }
|
||||
let script = args.join(' ')
|
||||
this.i18n(sender, 'prun.script', { name })
|
||||
this.i18n(sender, 'run.script', { script })
|
||||
let result = this.runCode(script, sender, this.pluginManager.getPlugins().get(name))
|
||||
this.i18n(sender, 'run.result', { result: result == undefined ? this.translate.translate('run.noresult') : result + '' })
|
||||
} catch (ex) {
|
||||
this.logger.sender(sender, this.logger.stack(ex))
|
||||
}
|
||||
}
|
||||
|
||||
private runCode(code: string, sender: any, _this: any) {
|
||||
let paramNames = [
|
||||
'sender',
|
||||
'reflect',
|
||||
@@ -404,8 +429,8 @@ if (this.serverType == "spring") {
|
||||
var db = dbm.getMainDatabase()
|
||||
var df = base.getInstance().getAutowireCapableBeanFactory()
|
||||
}
|
||||
return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
|
||||
return tfunc.apply(this, params) + ''
|
||||
return ''+ eval(${JSON.stringify(code)});`)
|
||||
return tfunc.apply(_this, params) + ''
|
||||
}
|
||||
|
||||
cmddeploy(sender: any, name: any) {
|
||||
@@ -419,7 +444,7 @@ return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
|
||||
version: plugin.description.version,
|
||||
source: base.read((plugin.description.source || plugin.description.loadMetadata.file).toString())
|
||||
})
|
||||
this.i18n(sender, result.code == 200 ? 'deploy.success' : 'deploy.fail', { name, msg: result.msg })
|
||||
this.i18n(sender, result.code == 200 ? 'deploy.success' : 'deploy.fail', { name, version: plugin.description.version, msg: result.msg })
|
||||
}
|
||||
}).async().submit()
|
||||
}
|
||||
@@ -433,9 +458,9 @@ return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
|
||||
}
|
||||
}
|
||||
|
||||
@Tab({ alias: ['bmpm'] })
|
||||
tabmpm(sender: any, command: any, args: string | any[]) {
|
||||
if (args.length === 1) { return ['list', 'install', 'update', 'upgrade', 'reload', 'restart', 'run', 'help', 'create', 'deploy'] }
|
||||
@Tab({ alias: ['gmspm', 'bungeemspm'] })
|
||||
tabmspm(_sender: any, _command: any, args: string | any[]) {
|
||||
if (args.length === 1) { return ['list', 'install', 'update', 'upgrade', 'reload', 'restart', 'run', 'prun', 'help', 'create', 'deploy'] }
|
||||
if (args.length > 1) {
|
||||
switch (args[0]) {
|
||||
case "list":
|
||||
@@ -446,6 +471,9 @@ return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
|
||||
if (args.length == 2) return ["system", ...this.pluginManager.getPlugins().keys()]
|
||||
if (args.length == 3 && args[1] == "system") return ["confirm"]
|
||||
return []
|
||||
case "prun":
|
||||
if (args.length == 2) return [...this.pluginManager.getPlugins().keys()]
|
||||
return []
|
||||
case "update":
|
||||
case "load":
|
||||
case "unload":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/sponge",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,11 +22,11 @@
|
||||
"@javatypes/sponge-api": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ class SimpleCommandCallable {
|
||||
this.callable = new CommandCallable({
|
||||
//CommandResult process(CommandSource source, String arguments) throws CommandException
|
||||
process: (sender: any, args) => {
|
||||
return this.executor(sender, '', command, Java.to(args.split(" ").filter(e => e))) ? CommandResult.success() : CommandResult.empty()
|
||||
return this.executor(sender, '', command, Java.to(args.split(" "))) ? CommandResult.success() : CommandResult.empty()
|
||||
},
|
||||
//List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException
|
||||
getSuggestions: (sender: any, args, target) => {
|
||||
return this.tabCompleter(sender, '', command, Java.to(args.split(" ").filter(e => e)))
|
||||
return this.tabCompleter(sender, '', command, Java.to(args.split(" ")))
|
||||
},
|
||||
//boolean testPermission(CommandSource source)
|
||||
testPermission: () => {
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
import { server } from '@ccms/api'
|
||||
import { Container } from '@ccms/container'
|
||||
|
||||
import { SpongeConsole } from './console';
|
||||
import './event';
|
||||
import './server';
|
||||
import './command';
|
||||
import './channel';
|
||||
import './task';
|
||||
import { SpongeConsole } from './console'
|
||||
import './chat'
|
||||
import './task'
|
||||
import './event'
|
||||
import './server'
|
||||
import './command'
|
||||
import './channel'
|
||||
|
||||
export default function SpongeImpl(container: Container) {
|
||||
container.bind(server.Console).toConstantValue(SpongeConsole);
|
||||
container.bind(server.Console).toConstantValue(SpongeConsole)
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ export class SpongeServer extends server.ReflectServer {
|
||||
if (typeof sender === 'string') {
|
||||
sender = this.getPlayer(sender)
|
||||
}
|
||||
return Sponge.getCommandManager().process(sender, command).getQueryResult().get() != 0
|
||||
return Sponge.getCommandManager().process(sender, command).getSuccessCount().get() != 0
|
||||
}
|
||||
dispatchConsoleCommand(command: string): boolean {
|
||||
return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult().get() != 0
|
||||
return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getSuccessCount().get() != 0
|
||||
}
|
||||
getPluginsFolder(): string {
|
||||
return this.pluginsFolder
|
||||
@@ -55,10 +55,4 @@ export class SpongeServer extends server.ReflectServer {
|
||||
getRootLogger() {
|
||||
return this.rootLogger
|
||||
}
|
||||
sendJson(sender: string | any, json: string): void {
|
||||
if (typeof sender === "string") {
|
||||
sender = this.getPlayer(sender)
|
||||
}
|
||||
sender.sendMessage(TextSerializers.JSON.deserialize(json))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/spring",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript spring package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -21,12 +21,12 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/common": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3",
|
||||
"@ccms/database": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/common": "^0.9.4",
|
||||
"@ccms/container": "^0.9.4",
|
||||
"@ccms/database": "^0.9.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/web",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "MiaoScript web package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -26,10 +26,10 @@
|
||||
"@javatypes/tomcat": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.9.3",
|
||||
"@ccms/container": "^0.9.3"
|
||||
"@ccms/api": "^0.9.5",
|
||||
"@ccms/container": "^0.9.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ccms/websocket",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "MiaoScript websocket package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -19,10 +19,10 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.9.3",
|
||||
"@ccms/nashorn": "^0.9.4",
|
||||
"@javatypes/tomcat-websocket-api": "^0.0.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.9.6"
|
||||
"typescript": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user