Skip to content

Commit

Permalink
add zh_CN.properties and clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
KotMilkMeoWtwo committed Jan 16, 2023
1 parent 2e3cdbb commit 511eda3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/main/java/ru/meowland/config/Bundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Bundle {



public static final String[] langList = {"en_US", "ru_RU"};
public static final String[] langList = {"en_US", "ru_RU", "zn_CN"};
public static final Fi langDir = MeowlandPlugin.pluginDir.child("lang");

public static String seelctedLang;
Expand All @@ -29,7 +29,7 @@ public class Bundle {
private static ObjectMap<String, String> properties;

public static void init(){
Log.info("init b");
Log.info("Meowland plugin init");
generate();

seelctedLang = Config.get("language");
Expand All @@ -43,7 +43,6 @@ public static void init(){

public static void generate(){
for (String lang : langList){
Log.info("meow");
final String langPath = "lang/" + lang + ".properties";
final Fi file = MeowlandPlugin.pluginDir.child(langPath);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ru/meowland/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class Config {
private static String config = ""
+ "\n#Plugin language en_US/ru_RU"
+ "\n#Plugin language en_US/ru_RU/zh_CN"
+ "\nlanguage: en_US"
+ "\n#Discord integration settings"
+ "\n#webhook"
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/ru/meowland/discord/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ public class Bot extends ListenerAdapter {
public void bot() throws LoginException {
if(Config.get("bot_enable").equals("true")){
Log.info("Meowland: bot started");
JDA jda = JDABuilder.createDefault(Config.get("bot_token")).build();
JDABuilder builder = JDABuilder.createDefault(Config.get("bot_token")).addEventListeners(new Bot());
JDA jda = JDABuilder.createLight(Config.get("bot_token")).addEventListeners(this).build();

//builder.setActivity(Activity.watching(String.valueOf( (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory())/1024/1024 + "Mb/" + Runtime.getRuntime().maxMemory()/1024/1024 + "Mb")));
//builder.build();
Events.on(EventType.PlayerJoin.class, event ->{
Player player = event.player;
GuildMessageChannel ch = jda.getChannelById(GuildMessageChannel.class, Config.get("channel_id"));
Expand Down Expand Up @@ -65,6 +62,23 @@ public void bot() throws LoginException {
eb.addField(Bundle.get("discord.count"), String.valueOf(Groups.player.size()), false);
ch.sendMessageEmbeds(eb.build()).queue();
});
/*
[E] java.lang.NullPointerException: Cannot invoke "net.dv8tion.jda.api.entities.GuildMessageChannel.sendMessageEmbeds(net.dv8tion.jda.api.entities.MessageEmbed, net.dv8tion.jda.api.entities.MessageEmbed[])" because "ch" is null
at ru.meowland.discord.Bot.lambda$bot$3(Bot.java:70)
Events.on(EventType.ServerLoadEvent.class, event ->{
EmbedBuilder eb = new EmbedBuilder();
GuildMessageChannel ch = jda.getChannelById(GuildMessageChannel.class, Config.get("channel_id"));
eb.setTitle(Config.get("server_name"));
eb.addField(Bundle.get("server.load"), Bundle.get("server.nya"), false);
ch.sendMessageEmbeds(eb.build()).queue();
});
*/

}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/lang/en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ discord.help.players = - send list players. Admin only
discord.help.ban = <uuid> - ban player. Admin only
discord.help.unban = <uuid> - unban player. Admin only
discord.help.add_map = <map pin with message> - add map on server. Need restart server. Admin only


server.load: server was loaded
server.nya: nya
5 changes: 4 additions & 1 deletion src/main/resources/lang/ru_RU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ discord.help.send = <сообщение> - отправляет сообщени
discord.help.players = - отправляет лист игроков. Админ онли команда.
discord.help.ban = <uuid> - банит игрока. Админ онли команда.
discord.help.unban = <uuid> - разбанивает игрока. Админ онли команда.
discord.help.add_map = <карта в виде файла> - добавляет карту на сервер. Админ онли команда.
discord.help.add_map = <карта в виде файла> - добавляет карту на сервер. Админ онли команда.

server.load: сервер загружен
server.nya: ня
3 changes: 3 additions & 0 deletions src/main/resources/lang/zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ discord.help.players = - 列出玩家列表。仅限管理
discord.help.ban = <uuid> - 封禁玩家。仅限管理
discord.help.unban = <uuid> - 解封玩家。仅限管理
discord.help.add_map = <消息带上指定地图> - 给服务器增加地图,需要重启服务器。仅限管理

server.load: server was loaded
server.nya: nya
2 changes: 1 addition & 1 deletion src/main/resources/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"author": "KotMilkMeoW",
"main": "ru.meowland.MeowlandPlugin",
"description": "nya",
"version": "2.1"
"version": "2.2"
}

0 comments on commit 511eda3

Please sign in to comment.