feat: 新增聊天相关API

merge/2/HEAD
coding 2018-05-13 16:13:32 +00:00
parent a041e8e2d2
commit 3df2625e65
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,9 @@
/*global Java, base, module, exports, require*/
function ChatHandlerDefault() {
this.tellraw = function(sender, raw) {
this.json(sender, JSON.stringify(raw));
}
}
var ChatHandler = Object.assign(new ChatHandlerDefault(), requireInternal('chat'));
exports = module.exports = ChatHandler;

View File

@ -0,0 +1,8 @@
/*global Java, base, module, exports, require*/
function json(sender, json) {
}
exports = module.exports = {
json: json
};

View File

@ -0,0 +1,9 @@
/*global Java, base, module, exports, require*/
var TextSerializers = Java.type('org.spongepowered.api.text.serializer.TextSerializers');
function json(sender, json) {
sender.sendMessage(TextSerializers.JSON.deserialize(json));
}
exports = module.exports = {
json: json
};