[L] 添加游戏内翻译

This commit is contained in:
Taskeren 2019-07-10 15:27:57 +08:00
parent 06ce0be2b5
commit 6bc37c5329
7 changed files with 25 additions and 27 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="output" path="bin/default"/>
<classpathentry output="bin/main" kind="src" path="src/main/java"> <classpathentry output="bin/main" kind="src" path="src/main/java">
<attributes> <attributes>
<attribute name="gradle_scope" value="main"/> <attribute name="gradle_scope" value="main"/>
@ -24,8 +25,6 @@
<attribute name="gradle_used_by_scope" value="test"/> <attribute name="gradle_used_by_scope" value="test"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry sourcepath="C:/Users/Taskeren/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.14.2-R0.1-SNAPSHOT/cccf9ead0e83de2bc2cc6c8a1ece9a76570ced0c/spigot-api-1.14.2-R0.1-SNAPSHOT-sources.jar" kind="lib" path="C:/Users/Taskeren/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.14.2-R0.1-SNAPSHOT/c3e1b7c24c243bd4c1564c68a174e9a6d201a8e3/spigot-api-1.14.2-R0.1-SNAPSHOT.jar"> <classpathentry sourcepath="C:/Users/Taskeren/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.14.2-R0.1-SNAPSHOT/cccf9ead0e83de2bc2cc6c8a1ece9a76570ced0c/spigot-api-1.14.2-R0.1-SNAPSHOT-sources.jar" kind="lib" path="C:/Users/Taskeren/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.14.2-R0.1-SNAPSHOT/c3e1b7c24c243bd4c1564c68a174e9a6d201a8e3/spigot-api-1.14.2-R0.1-SNAPSHOT.jar">
<attributes> <attributes>

View File

@ -5,17 +5,12 @@
<projects/> <projects/>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures> </natures>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments/> <arguments/>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments/>
</buildCommand>
</buildSpec> </buildSpec>
<linkedResources/> <linkedResources/>
<filteredResources/> <filteredResources/>

View File

@ -1,5 +1,5 @@
# #
#Wed Jul 10 14:47:02 CST 2019 #Wed Jul 10 15:19:10 CST 2019
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve

View File

@ -5,6 +5,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
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;
import cn.glycol.t18n.I18n;
import ren.taske.nativebot.MinecraftPlugin; import ren.taske.nativebot.MinecraftPlugin;
import ren.taske.nativebot.commons.Config; import ren.taske.nativebot.commons.Config;
import ren.taske.nativebot.core.NativeBot; import ren.taske.nativebot.core.NativeBot;
@ -51,7 +52,7 @@ public class Chatting {
message = CQUtils.removeCqCode(message); message = CQUtils.removeCqCode(message);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("<").append(username).append("> ").append("\u00a7r"); sb.append("<").append(username).append("> ").append("\u00a7r"); // \u007a = §
sb.append(message); sb.append(message);
plugin.getServer().broadcastMessage(sb.toString()); plugin.getServer().broadcastMessage(sb.toString());
@ -75,14 +76,14 @@ public class Chatting {
} }
if(um.getTencentId() == -1L) { if(um.getTencentId() == -1L) {
evt.getPlayer().sendMessage("Please set your Tencent userid first!"); evt.getPlayer().sendMessage(I18n.format("message.using.set-qq-first"));
return; return;
} }
UserTencent ut = UserTencent.of(um.getTencentId()); UserTencent ut = UserTencent.of(um.getTencentId());
if(!ut.hasPermission(NODE_CHATTING_MINECRAFT)) { if(!ut.hasPermission(NODE_CHATTING_MINECRAFT)) {
evt.getPlayer().sendMessage("You're Unauthorized!"); evt.getPlayer().sendMessage(I18n.format("message.unauthorized"));
return; return;
} }

View File

@ -26,47 +26,47 @@ public class UserMinecraft extends User {
@Override @Override
public SimpleDataStorage getData() { public SimpleDataStorage getData() {
return data; return getTencentUser().getData();
} }
@Override @Override
public void onUnload() { public void onUnload() {
data.save(); getTencentUser().onUnload();
} }
@Override @Override
public void reload() { public void reload() {
data.save(); getTencentUser().reload();
} }
/** 获取玩家对应QQ的权限 */
public boolean hasPermission(String node) { public boolean hasPermission(String node) {
return hasPermission(node, false); return getTencentUser().hasPermission(node);
}
public boolean hasPermission(String node, boolean defaultVal) {
if(node != null) {
data.setDefault(node, defaultVal);
data.save();
}
return data.getBoolean(node, false);
} }
/** 设置玩家对应QQ的权限 */
public void setPermission(String node, boolean val) { public void setPermission(String node, boolean val) {
data.setBoolean(node, val); getTencentUser().setPermission(node, val);
data.save();
} }
public static final String _TENCENT_UID = "tencent.uid"; public static final String _TENCENT_UID = "tencent.uid";
/** 设置该用户的QQ号 */
public void setTencentId(long uid) { public void setTencentId(long uid) {
data.setLong(_TENCENT_UID, uid); data.setLong(_TENCENT_UID, uid);
data.save(); data.save();
} }
/** 获取该用户的QQ号 */
public long getTencentId() { public long getTencentId() {
data.setDefault(_TENCENT_UID, -1L); data.setDefault(_TENCENT_UID, -1L);
data.save(); data.save();
return data.getLong(_TENCENT_UID, -1L); return data.getLong(_TENCENT_UID, -1L);
} }
/** 获取该用户的TencentUser */
public UserTencent getTencentUser() {
return UserTencent.of(getTencentId());
}
} }

View File

@ -69,5 +69,4 @@ public class UserTencent extends User {
data.save(); data.save();
} }
} }
} }

View File

@ -1,5 +1,9 @@
message.common.welcome=欢迎使用! message.common.welcome=欢迎使用!
message.using.set-qq-first=请先绑定QQ
message.unauthorized=您没有权限!
command.common.done=完成! command.common.done=完成!
command.common.fail=失败! command.common.fail=失败!
command.common.argument=参数错误! command.common.argument=参数错误!