diff --git a/src/main/java/ru/meowland/config/Bundle.java b/src/main/java/ru/meowland/config/Bundle.java index e1b6e85..8987d5d 100644 --- a/src/main/java/ru/meowland/config/Bundle.java +++ b/src/main/java/ru/meowland/config/Bundle.java @@ -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; @@ -29,7 +29,7 @@ public class Bundle { private static ObjectMap properties; public static void init(){ - Log.info("init b"); + Log.info("Meowland plugin init"); generate(); seelctedLang = Config.get("language"); @@ -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); diff --git a/src/main/java/ru/meowland/config/Config.java b/src/main/java/ru/meowland/config/Config.java index 1d45aea..1aff65e 100644 --- a/src/main/java/ru/meowland/config/Config.java +++ b/src/main/java/ru/meowland/config/Config.java @@ -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" diff --git a/src/main/java/ru/meowland/discord/Bot.java b/src/main/java/ru/meowland/discord/Bot.java index e955d8e..6aa2328 100644 --- a/src/main/java/ru/meowland/discord/Bot.java +++ b/src/main/java/ru/meowland/discord/Bot.java @@ -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")); @@ -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(); + }); + */ + } } diff --git a/src/main/resources/lang/en_US.properties b/src/main/resources/lang/en_US.properties index 2a99874..44233e1 100644 --- a/src/main/resources/lang/en_US.properties +++ b/src/main/resources/lang/en_US.properties @@ -52,3 +52,7 @@ discord.help.players = - send list players. Admin only discord.help.ban = - ban player. Admin only discord.help.unban = - unban player. Admin only discord.help.add_map = - add map on server. Need restart server. Admin only + + +server.load: server was loaded +server.nya: nya \ No newline at end of file diff --git a/src/main/resources/lang/ru_RU.properties b/src/main/resources/lang/ru_RU.properties index a287d46..abe43e5 100644 --- a/src/main/resources/lang/ru_RU.properties +++ b/src/main/resources/lang/ru_RU.properties @@ -52,4 +52,7 @@ discord.help.send = <сообщение> - отправляет сообщени discord.help.players = - отправляет лист игроков. Админ онли команда. discord.help.ban = - банит игрока. Админ онли команда. discord.help.unban = - разбанивает игрока. Админ онли команда. -discord.help.add_map = <карта в виде файла> - добавляет карту на сервер. Админ онли команда. \ No newline at end of file +discord.help.add_map = <карта в виде файла> - добавляет карту на сервер. Админ онли команда. + +server.load: сервер загружен +server.nya: ня \ No newline at end of file diff --git a/src/main/resources/lang/zh_CN.properties b/src/main/resources/lang/zh_CN.properties index 194a71f..c3a3880 100644 --- a/src/main/resources/lang/zh_CN.properties +++ b/src/main/resources/lang/zh_CN.properties @@ -52,3 +52,6 @@ discord.help.players = - 列出玩家列表。仅限管理 discord.help.ban = - 封禁玩家。仅限管理 discord.help.unban = - 解封玩家。仅限管理 discord.help.add_map = <消息带上指定地图> - 给服务器增加地图,需要重启服务器。仅限管理 + +server.load: server was loaded +server.nya: nya \ No newline at end of file diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 747554b..9edaf38 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -4,5 +4,5 @@ "author": "KotMilkMeoW", "main": "ru.meowland.MeowlandPlugin", "description": "nya", - "version": "2.1" + "version": "2.2" }