feat: MiaoConsole exclude nukkit
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
e7d44af48c
commit
3f475a7dc1
@ -16,7 +16,7 @@ const refList: Array<{ server: string, future: string }> = [
|
||||
{ server: 'func_147137_ag', future: 'field_151274_e' }//catserver 1.12.2
|
||||
]
|
||||
|
||||
@plugin({ name: 'MiaoConsole', version: '1.0.0', author: 'MiaoWoo', source: __filename })
|
||||
@plugin({ name: 'MiaoConsole', version: '1.0.0', author: 'MiaoWoo', servers: ['!nukkit'], source: __filename })
|
||||
export class MiaoConsole extends interfaces.Plugin {
|
||||
public static GlobalContainer: Container
|
||||
public static GlobalLogger: Console
|
||||
@ -98,6 +98,7 @@ export class MiaoConsole extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
injectMiaoDetect() {
|
||||
let MiaoDetectHandler = getMiaoDetectHandler();
|
||||
this.pipeline.addFirst('miao_detect', new MiaoDetectHandler())
|
||||
this.container.bind(MessageHandle).toFunction(this.onmessage.bind(this))
|
||||
this.logger.info('Netty Channel Pipeline Inject MiaoDetectHandler Successful!')
|
||||
@ -132,38 +133,39 @@ export class MiaoConsole extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
sendResult(ctx: any, type: string, msg: string) {
|
||||
let TextWebSocketFrame = getTextWebSocketFrame()
|
||||
ctx.writeAndFlush(new TextWebSocketFrame(`${type}${SPLIT_LINE}${msg}`))
|
||||
}
|
||||
}
|
||||
|
||||
const ChannelInboundHandlerAdapter = Java.type('io.netty.channel.ChannelInboundHandlerAdapter')
|
||||
const CharsetUtil = Java.type('io.netty.util.CharsetUtil')
|
||||
const TextWebSocketFrame = Java.type('io.netty.handler.codec.http.websocketx.TextWebSocketFrame')
|
||||
const MiaoDetectHandler = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
function getMiaoDetectHandler() {
|
||||
const ChannelInboundHandlerAdapter = Java.type('io.netty.channel.ChannelInboundHandlerAdapter')
|
||||
const CharsetUtil = Java.type('io.netty.util.CharsetUtil')
|
||||
const MiaoDetectHandler = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
channelRead: (ctx: any, channel: any) => {
|
||||
channel.pipeline().addFirst('miaowebsocket', new WebSocketHandler())
|
||||
ctx.fireChannelRead(channel)
|
||||
}
|
||||
})
|
||||
const TypeParameterMatcher = Java.type('io.netty.util.internal.TypeParameterMatcher')
|
||||
const DefaultHttpResponse = Java.type('io.netty.handler.codec.http.DefaultHttpResponse')
|
||||
const DefaultFullHttpResponse = Java.type('io.netty.handler.codec.http.DefaultFullHttpResponse')
|
||||
const HttpHeaders = Java.type('io.netty.handler.codec.http.HttpHeaders')
|
||||
const HttpVersion = Java.type('io.netty.handler.codec.http.HttpVersion')
|
||||
const HttpResponseStatus = Java.type('io.netty.handler.codec.http.HttpResponseStatus')
|
||||
const LastHttpContent = Java.type('io.netty.handler.codec.http.LastHttpContent')
|
||||
const HttpServerCodec = Java.type('io.netty.handler.codec.http.HttpServerCodec')
|
||||
const ChunkedWriteHandler = Java.type('io.netty.handler.stream.ChunkedWriteHandler')
|
||||
const HttpObjectAggregator = Java.type('io.netty.handler.codec.http.HttpObjectAggregator')
|
||||
const WebSocketServerProtocolHandler = Java.type('io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler')
|
||||
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
|
||||
const FullHttpRequestMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.FullHttpRequest'))
|
||||
const File = Java.type('java.io.File')
|
||||
const Runnable = Java.type('java.lang.Runnable')
|
||||
const RandomAccessFile = Java.type('java.io.RandomAccessFile')
|
||||
const DefaultFileRegion = Java.type('io.netty.channel.DefaultFileRegion')
|
||||
const ChannelFutureListener = Java.type('io.netty.channel.ChannelFutureListener')
|
||||
const HttpRequestHandler = Java.extend(SimpleChannelInboundHandler, {
|
||||
})
|
||||
const TypeParameterMatcher = Java.type('io.netty.util.internal.TypeParameterMatcher')
|
||||
const DefaultHttpResponse = Java.type('io.netty.handler.codec.http.DefaultHttpResponse')
|
||||
const DefaultFullHttpResponse = Java.type('io.netty.handler.codec.http.DefaultFullHttpResponse')
|
||||
const HttpHeaders = Java.type('io.netty.handler.codec.http.HttpHeaders')
|
||||
const HttpVersion = Java.type('io.netty.handler.codec.http.HttpVersion')
|
||||
const HttpResponseStatus = Java.type('io.netty.handler.codec.http.HttpResponseStatus')
|
||||
const LastHttpContent = Java.type('io.netty.handler.codec.http.LastHttpContent')
|
||||
const HttpServerCodec = Java.type('io.netty.handler.codec.http.HttpServerCodec')
|
||||
const ChunkedWriteHandler = Java.type('io.netty.handler.stream.ChunkedWriteHandler')
|
||||
const HttpObjectAggregator = Java.type('io.netty.handler.codec.http.HttpObjectAggregator')
|
||||
const WebSocketServerProtocolHandler = Java.type('io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler')
|
||||
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
|
||||
const FullHttpRequestMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.FullHttpRequest'))
|
||||
const File = Java.type('java.io.File')
|
||||
const Runnable = Java.type('java.lang.Runnable')
|
||||
const RandomAccessFile = Java.type('java.io.RandomAccessFile')
|
||||
const DefaultFileRegion = Java.type('io.netty.channel.DefaultFileRegion')
|
||||
const ChannelFutureListener = Java.type('io.netty.channel.ChannelFutureListener')
|
||||
const HttpRequestHandler = Java.extend(SimpleChannelInboundHandler, {
|
||||
acceptInboundMessage: (msg: any) => {
|
||||
return FullHttpRequestMatcher.match(msg)
|
||||
},
|
||||
@ -201,9 +203,9 @@ const HttpRequestHandler = Java.extend(SimpleChannelInboundHandler, {
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
const TextWebSocketFrameMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.websocketx.TextWebSocketFrame'))
|
||||
const TextWebSocketFrameHandler = Java.extend(SimpleChannelInboundHandler, {
|
||||
})
|
||||
const TextWebSocketFrameMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.websocketx.TextWebSocketFrame'))
|
||||
const TextWebSocketFrameHandler = Java.extend(SimpleChannelInboundHandler, {
|
||||
userEventTriggered: (ctx: any, evt: any) => {
|
||||
if (evt == 'HANDSHAKE_COMPLETE') {
|
||||
clients.push(ctx.channel())
|
||||
@ -216,8 +218,8 @@ const TextWebSocketFrameHandler = Java.extend(SimpleChannelInboundHandler, {
|
||||
channelRead0: (ctx: any, msg: any) => {
|
||||
MiaoConsole.GlobalContainer.get<any>(MessageHandle)(ctx, msg)
|
||||
}
|
||||
})
|
||||
const WebSocketHandler = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
})
|
||||
const WebSocketHandler = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
channelRead: function(ctx: any, msg: any) {
|
||||
msg.markReaderIndex()
|
||||
let message: string = msg.toString(CharsetUtil.UTF_8)
|
||||
@ -239,4 +241,10 @@ const WebSocketHandler = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
msg.resetReaderIndex()
|
||||
ctx.fireChannelRead(msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
return MiaoDetectHandler;
|
||||
}
|
||||
|
||||
function getTextWebSocketFrame() {
|
||||
return Java.type('io.netty.handler.codec.http.websocketx.TextWebSocketFrame')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user