From 76387ed9b94a325f88206c31159ec009f92800c8 Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 12:57:10 +0100 Subject: [PATCH 1/7] init project on my personnal repository --- .classpath | 32 +++++++++++++++++++ .project | 23 +++++++++++++ .settings/org.eclipse.core.resources.prefs | 4 +++ .settings/org.eclipse.jdt.core.prefs | 8 +++++ .settings/org.eclipse.m2e.core.prefs | 4 +++ .../java/de/Linus122/Telegram/Telegram.java | 4 +-- .../ChatMessageToTelegram.java | 1 + 7 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..3d58f05 --- /dev/null +++ b/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..a20fff0 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + xyz.spaceio.telegramchat + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..abdea9a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..79b9043 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/src/main/java/de/Linus122/Telegram/Telegram.java b/src/main/java/de/Linus122/Telegram/Telegram.java index ec121bf..698a13f 100755 --- a/src/main/java/de/Linus122/Telegram/Telegram.java +++ b/src/main/java/de/Linus122/Telegram/Telegram.java @@ -156,14 +156,13 @@ public void handleUserMessage(String text, Update update) { TelegramChat.getInstance().getLogger().info("Omitted message Telegram->MC because it was sent while the server was offline."); } } - } else { - this.sendMsg(chat.getId(), Utils.formatMSG("need-to-link")[0]); } } public void sendMsg(long id, String msg) { ChatMessageToTelegram chat = new ChatMessageToTelegram(); chat.chat_id = id; + chat.disable_notification = true; chat.text = msg; sendMsg(chat); } @@ -183,6 +182,7 @@ public void sendAll(final ChatMessageToTelegram chat) { public void run() { for (long id : TelegramChat.getBackend().chat_ids) { chat.chat_id = id; + chat.disable_notification = true; // post("sendMessage", gson.toJson(chat, Chat.class)); sendMsg(chat); } diff --git a/src/main/java/de/Linus122/TelegramComponents/ChatMessageToTelegram.java b/src/main/java/de/Linus122/TelegramComponents/ChatMessageToTelegram.java index b85a70c..710834b 100755 --- a/src/main/java/de/Linus122/TelegramComponents/ChatMessageToTelegram.java +++ b/src/main/java/de/Linus122/TelegramComponents/ChatMessageToTelegram.java @@ -2,6 +2,7 @@ public class ChatMessageToTelegram extends Cancellable { public String text; + public Boolean disable_notification; public long chat_id; public String parse_mode; } From 5e9a68281c96cba2dbbd265148f679d3c6eb3889 Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 13:06:23 +0100 Subject: [PATCH 2/7] Silent update * Adding an option to remove the need-to-link message spamming everyone. (usefull if you don't want to configure the link FROM telegram -> TO server * Adding an option to add only silent messages (telegram message without audio notification) --- src/main/java/de/Linus122/Telegram/Telegram.java | 14 ++++++++++++-- src/main/resources/config.yml | 2 ++ src/main/resources/plugin.yml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/Linus122/Telegram/Telegram.java b/src/main/java/de/Linus122/Telegram/Telegram.java index 698a13f..cadfdb1 100755 --- a/src/main/java/de/Linus122/Telegram/Telegram.java +++ b/src/main/java/de/Linus122/Telegram/Telegram.java @@ -156,13 +156,17 @@ public void handleUserMessage(String text, Update update) { TelegramChat.getInstance().getLogger().info("Omitted message Telegram->MC because it was sent while the server was offline."); } } + } else { + boolean skipIfNeedToLinkSilent = TelegramChat.getInstance().getConfig().getBoolean("omit-messages-need-to-link"); + if (!skipIfNeedToLinkSilent) { + this.sendMsg(chat.getId(), Utils.formatMSG("need-to-link")[0]); + } } } public void sendMsg(long id, String msg) { ChatMessageToTelegram chat = new ChatMessageToTelegram(); chat.chat_id = id; - chat.disable_notification = true; chat.text = msg; sendMsg(chat); } @@ -171,6 +175,13 @@ public void sendMsg(ChatMessageToTelegram chat) { for (TelegramActionListener actionListener : listeners) { actionListener.onSendToTelegram(chat); } + boolean turnNotificationToSilent = TelegramChat.getInstance().getConfig().getBoolean("turn-to-silent-notification"); + if(turnNotificationToSilent) { + chat.disable_notification = true; + } else { + chat.disable_notification = false; + } + Gson gson = new Gson(); if(!chat.isCancelled()){ post("sendMessage", gson.toJson(chat, ChatMessageToTelegram.class)); @@ -182,7 +193,6 @@ public void sendAll(final ChatMessageToTelegram chat) { public void run() { for (long id : TelegramChat.getBackend().chat_ids) { chat.chat_id = id; - chat.disable_notification = true; // post("sendMessage", gson.toJson(chat, Chat.class)); sendMsg(chat); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c9a621c..5a38331 100755 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,3 +20,5 @@ enable-chatmessages: true # this will prevent mass-sending unsent messages from telegram to mc upon server startup omit-messages-sent-while-server-was-offline: true +omit-messages-need-to-link: false +turn-to-silent-notification: false diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 31f9e08..f5f65fe 100755 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: TelegramChat main: de.Linus122.TelegramChat.TelegramChat version: ${project.version} -authors: [Linus122] +authors: [Linus122, Arthessia] softdepend: [Vault, SuperVanish, PremiumVanish] description: Brings minecraft chat to Telegram! commands: From cc40ac7ed866ed44120a2e7a44f0e23df44ebec7 Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 13:15:36 +0100 Subject: [PATCH 3/7] clean code --- src/main/java/de/Linus122/Handlers/BanHandler.java | 1 - src/main/java/de/Linus122/Handlers/CommandHandler.java | 9 --------- .../java/de/Linus122/TelegramChat/LinkTelegramCmd.java | 2 -- src/main/java/de/Linus122/TelegramChat/TelegramChat.java | 1 - 4 files changed, 13 deletions(-) diff --git a/src/main/java/de/Linus122/Handlers/BanHandler.java b/src/main/java/de/Linus122/Handlers/BanHandler.java index 7b82ab5..708e166 100644 --- a/src/main/java/de/Linus122/Handlers/BanHandler.java +++ b/src/main/java/de/Linus122/Handlers/BanHandler.java @@ -2,7 +2,6 @@ import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; import de.Linus122.Telegram.TelegramActionListener; import de.Linus122.TelegramComponents.ChatMessageToMc; diff --git a/src/main/java/de/Linus122/Handlers/CommandHandler.java b/src/main/java/de/Linus122/Handlers/CommandHandler.java index ef58eb0..816134b 100644 --- a/src/main/java/de/Linus122/Handlers/CommandHandler.java +++ b/src/main/java/de/Linus122/Handlers/CommandHandler.java @@ -1,25 +1,16 @@ package de.Linus122.Handlers; -import java.security.Permissions; -import java.util.Arrays; -import java.util.Locale; import java.util.logging.ConsoleHandler; -import java.util.logging.Formatter; -import java.util.logging.Handler; import java.util.logging.LogManager; import java.util.logging.LogRecord; -import java.util.logging.SimpleFormatter; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginLogger; import org.bukkit.plugin.RegisteredServiceProvider; import de.Linus122.Telegram.Telegram; import de.Linus122.Telegram.TelegramActionListener; -import de.Linus122.TelegramChat.TelegramChat; import de.Linus122.TelegramComponents.ChatMessageToMc; import de.Linus122.TelegramComponents.ChatMessageToTelegram; import net.milkbowl.vault.permission.Permission; diff --git a/src/main/java/de/Linus122/TelegramChat/LinkTelegramCmd.java b/src/main/java/de/Linus122/TelegramChat/LinkTelegramCmd.java index 68ca940..e7b5555 100755 --- a/src/main/java/de/Linus122/TelegramChat/LinkTelegramCmd.java +++ b/src/main/java/de/Linus122/TelegramChat/LinkTelegramCmd.java @@ -1,7 +1,5 @@ package de.Linus122.TelegramChat; -import java.io.IOException; - import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; diff --git a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java index 3c5eb6f..9198b5c 100755 --- a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java +++ b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java @@ -28,7 +28,6 @@ import com.google.gson.Gson; import de.Linus122.Handlers.BanHandler; -import de.Linus122.Handlers.CommandHandler; import de.Linus122.Metrics.Metrics; import de.Linus122.Telegram.Telegram; import de.Linus122.Telegram.Utils; From 21fe51166938bbdeee31b35b0eb4100f80912ff2 Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 13:39:30 +0100 Subject: [PATCH 4/7] send new version update of configuration file with comments --- pom.xml | 2 +- src/main/resources/config.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6db1f16..4912d1f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 xyz.spaceio telegramchat - 1.0.19-SNAPSHOT + 1.0.20-SNAPSHOT TelegramChat https://www.spigotmc.org/resources/telegramchat.16576/ diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5a38331..8422c48 100755 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,5 +20,9 @@ enable-chatmessages: true # this will prevent mass-sending unsent messages from telegram to mc upon server startup omit-messages-sent-while-server-was-offline: true + +# this will prevent sending message each time a non-registered person is speaking omit-messages-need-to-link: false + +# this will send a silent message to avoid triggering a sound each time a message is sent turn-to-silent-notification: false From b838f29927d9113c54cc6c07aafbcf9934f071b0 Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 15:59:00 +0100 Subject: [PATCH 5/7] fix requested by mastercake10 --- .gitignore | 4 ++++ .settings/org.eclipse.core.resources.prefs | 4 ---- .settings/org.eclipse.jdt.core.prefs | 8 -------- .settings/org.eclipse.m2e.core.prefs | 4 ---- src/main/java/de/Linus122/Telegram/Telegram.java | 7 +------ 5 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.m2e.core.prefs diff --git a/.gitignore b/.gitignore index 8a5f2ff..ba9d61c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ *.class /target *.iml +.project +.classpath +.settings/ +.settings2/ \ No newline at end of file diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index abdea9a..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 79b9043..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 -org.eclipse.jdt.core.compiler.compliance=9 -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=9 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/src/main/java/de/Linus122/Telegram/Telegram.java b/src/main/java/de/Linus122/Telegram/Telegram.java index cadfdb1..602769e 100755 --- a/src/main/java/de/Linus122/Telegram/Telegram.java +++ b/src/main/java/de/Linus122/Telegram/Telegram.java @@ -175,12 +175,7 @@ public void sendMsg(ChatMessageToTelegram chat) { for (TelegramActionListener actionListener : listeners) { actionListener.onSendToTelegram(chat); } - boolean turnNotificationToSilent = TelegramChat.getInstance().getConfig().getBoolean("turn-to-silent-notification"); - if(turnNotificationToSilent) { - chat.disable_notification = true; - } else { - chat.disable_notification = false; - } + chat.disable_notification = TelegramChat.getInstance().getConfig().getBoolean("turn-to-silent-notification"); Gson gson = new Gson(); if(!chat.isCancelled()){ From 69233fe5a0b261b52f1812c43fb46c3a6c8550d3 Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 15:59:59 +0100 Subject: [PATCH 6/7] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ba9d61c..8694dc6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ .project .classpath .settings/ -.settings2/ \ No newline at end of file +*.prefs \ No newline at end of file From ab920e751b8fa47f0fc6eeff48be996f164fa10d Mon Sep 17 00:00:00 2001 From: Arthessia Derven Date: Mon, 12 Dec 2022 16:06:51 +0100 Subject: [PATCH 7/7] removal of local files --- .classpath | 32 -------------------------------- .project | 23 ----------------------- 2 files changed, 55 deletions(-) delete mode 100644 .classpath delete mode 100644 .project diff --git a/.classpath b/.classpath deleted file mode 100644 index 3d58f05..0000000 --- a/.classpath +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index a20fff0..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - xyz.spaceio.telegramchat - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - -