[+] 很多改进

1. 添加了更多中文翻译
2. 将/qq的功能分成了/qq和/qq-admin两个指令
3. 将权限组的更改进行应用
4. 现在会优先读取群名片了
This commit is contained in:
Taskeren 2019-07-10 20:58:47 +08:00
parent 6bc37c5329
commit ba8869df5c
8 changed files with 77 additions and 40 deletions

View File

@ -27,6 +27,8 @@ repositories {
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
} }
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
dependencies { dependencies {
implementation 'com.github.nitu2003:TConfig:1.0' implementation 'com.github.nitu2003:TConfig:1.0'
implementation 'com.github.nitu2003:SimpleDataStorage:1.2' implementation 'com.github.nitu2003:SimpleDataStorage:1.2'
@ -38,21 +40,9 @@ dependencies {
} }
shadowJar { shadowJar {
classifier = "" classifier = null
dependencies { from("./") {
include(dependency("com.github.nitu2003:TConfig:1.0")) include 'build.gradle'
include(dependency("com.github.nitu2003:SimpleDataStorage:1.2"))
include(dependency("com.github.nitu2003:T18n:1.1"))
include(dependency("commons-io:commons-io:2.4"))
include(dependency("com.github.hydevelop:PicqBotX:4.10.1.928"))
include(dependency("com.github.hydevelop:HyLogger:4.0.254"))
include(dependency("com.github.hydevelop:HyCommonUtils:1.3.5.130"))
include(dependency("cn.hutool:hutool-all:4.5.10"))
include(dependency("com.google.code.gson:gson:2.8.5"))
include(dependency("org.mariuszgromada.math:MathParser.org-mXparser:4.2.0"))
include(dependency("org.projectlombok:1.14.8"))
include(dependency("org.fusesource.jansi:jansi:1.17.1"))
} }
} }

View File

@ -13,6 +13,7 @@ import ren.taske.nativebot.bot.chatting.TencentMessage;
import ren.taske.nativebot.core.NativeBot; import ren.taske.nativebot.core.NativeBot;
import ren.taske.nativebot.i18n.I18nInit; import ren.taske.nativebot.i18n.I18nInit;
import ren.taske.nativebot.minecraft.command.CommandQQ; import ren.taske.nativebot.minecraft.command.CommandQQ;
import ren.taske.nativebot.minecraft.command.CommandQQAdmin;
public class MinecraftPlugin extends JavaPlugin { public class MinecraftPlugin extends JavaPlugin {
@ -23,6 +24,7 @@ public class MinecraftPlugin extends JavaPlugin {
protected final TencentMessage tencentevent = new TencentMessage(this); protected final TencentMessage tencentevent = new TencentMessage(this);
protected final CommandQQ cmdqq = new CommandQQ(this); protected final CommandQQ cmdqq = new CommandQQ(this);
protected final CommandQQAdmin cmdqqadmin = new CommandQQAdmin();
@Override @Override
public void onEnable() { public void onEnable() {
@ -35,6 +37,7 @@ public class MinecraftPlugin extends JavaPlugin {
nativebot.onEnable(); nativebot.onEnable();
getCommand("qq").setExecutor(cmdqq); getCommand("qq").setExecutor(cmdqq);
getCommand("qq-admin").setExecutor(cmdqqadmin);
nativebot.getBot().register(tencentevent); nativebot.getBot().register(tencentevent);
getServer().getPluginManager().registerEvents(mcevent, this); getServer().getPluginManager().registerEvents(mcevent, this);

View File

@ -2,6 +2,8 @@ package ren.taske.nativebot.bot.chatting;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import cc.moecraft.icq.event.events.message.EventGroupMessage;
import cc.moecraft.icq.event.events.message.EventGroupOrDiscussMessage;
import cc.moecraft.icq.event.events.message.EventMessage; import cc.moecraft.icq.event.events.message.EventMessage;
import cc.moecraft.icq.user.User; import cc.moecraft.icq.user.User;
import cc.moecraft.icq.utils.CQUtils; import cc.moecraft.icq.utils.CQUtils;
@ -35,7 +37,13 @@ public class Chatting {
long userid = user.getId(); long userid = user.getId();
UserTencent ut = UserTencent.of(userid); UserTencent ut = UserTencent.of(userid);
String message = evt.getMessage(); String message = evt.getMessage();
String username = user.getInfo().getNickname(); String username;
if(evt instanceof EventGroupOrDiscussMessage) {
username = ((EventGroupOrDiscussMessage) evt).getGroupSender().getInfo().getCard();
} else {
username = user.getInfo().getNickname();
}
if(!isPrefixed(message)) { if(!isPrefixed(message)) {
return; return;

View File

@ -27,6 +27,10 @@ public class I18nInit {
public static void init() { public static void init() {
if(FILE_I18N.exists() && Config.useJarLanguageFile) {
FILE_I18N.delete();
}
if(!FILE_I18N.exists() || Config.useJarLanguageFile) { if(!FILE_I18N.exists() || Config.useJarLanguageFile) {
writeContextToFile(getContextFromJar()); writeContextToFile(getContextFromJar());
} }

View File

@ -1,15 +1,13 @@
package ren.taske.nativebot.minecraft.command; package ren.taske.nativebot.minecraft.command;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import cn.glycol.t18n.I18n;
import ren.taske.data.util.ParseUtil; import ren.taske.data.util.ParseUtil;
import ren.taske.nativebot.MinecraftPlugin; import ren.taske.nativebot.MinecraftPlugin;
import ren.taske.nativebot.commons.Reference;
import ren.taske.nativebot.core.profile.UserMinecraft; import ren.taske.nativebot.core.profile.UserMinecraft;
import ren.taske.nativebot.core.profile.UserTencent;
public class CommandQQ implements CommandExecutor { public class CommandQQ implements CommandExecutor {
@ -28,30 +26,14 @@ public class CommandQQ implements CommandExecutor {
if(qqid != null) { if(qqid != null) {
if(um.getTencentId() == -1L) { if(um.getTencentId() == -1L) {
um.setTencentId(qqid); um.setTencentId(qqid);
sender.sendMessage("Your Tencent userid now is " + qqid); sender.sendMessage(I18n.format("command.qq.done", qqid));
} else { } else {
sender.sendMessage("You have set your Tencent userid!"); sender.sendMessage(I18n.format("command.qq.undone", um.getTencentId()));
} }
return true; return true;
} }
} }
if(args.length == 2) {
UserMinecraft um = UserMinecraft.of(args[1]);
UserTencent ut = UserTencent.of(um.getTencentId());
Long qqid = ParseUtil.parseLong(args[0]);
if(ut.hasPermission(Reference.NODE_OP)) {
if(qqid != null) {
um.setTencentId(qqid);
sender.sendMessage(ChatColor.GOLD+um.getUserId()+ChatColor.RESET+"'s Tencent userid now is "+qqid);
}
} else {
sender.sendMessage("You have no permission!");
}
return true;
}
return false; return false;
} }

View File

@ -0,0 +1,31 @@
package ren.taske.nativebot.minecraft.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import cn.glycol.t18n.I18n;
import ren.taske.data.util.ParseUtil;
import ren.taske.nativebot.core.profile.UserMinecraft;
public class CommandQQAdmin implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(args.length == 2) {
Long qqid = ParseUtil.parseLong(args[0]);
if(qqid != null) {
UserMinecraft oped = UserMinecraft.of(args[1]);
oped.setTencentId(qqid);
sender.sendMessage(I18n.format("command.qq-admin.done", oped.getUserId(), oped.getTencentId()));
return true;
}
}
return false;
}
}

View File

@ -4,6 +4,11 @@ message.using.set-qq-first=请先绑定QQ
message.unauthorized=您没有权限! message.unauthorized=您没有权限!
command.qq.done=您的账号绑定了QQ%s。
command.qq.undone=您的账号已经绑定了QQ%s。
command.qq-admin.done=%1$s的账号绑定了QQ%2$s。
command.common.done=完成! command.common.done=完成!
command.common.fail=失败! command.common.fail=失败!
command.common.argument=参数错误! command.common.argument=参数错误!

View File

@ -4,7 +4,21 @@ version: 1.0.0
commands: commands:
qq: qq:
description: set your qq userid description: to set your qq userid
usage: /qq <QQNumber> [MinecraftName] usage: /qq <QQNumber>
permission: nativebot.qq permission: nativebot.qq
permission-message: You don't have permission! permission-message: You don't have permission!
qq-admin:
description: to set a player's qq userid
usage: /qq-admin <QQNumber> [MinecraftUser]
aliases: [qqadmin]
permission: nativebot.admin
permission-message: You don't have permission!
permissions:
nativebot.admin:
description: A permission node used for command qq-admin
default: op
nativebot.qq:
description: A permission node used for command qq
default: true