From 84a25484c4c33909408d05ae6aa25ad1e2586ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Sat, 2 Oct 2021 17:03:01 +0200 Subject: [PATCH 1/6] Add PremiumVanish/SuperVanish (soft)dependencies --- pom.xml | 19 ++++++++++++++----- src/main/resources/plugin.yml | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 005609e..02bc281 100644 --- a/pom.xml +++ b/pom.xml @@ -25,15 +25,24 @@ jitpack.io https://jitpack.io + + nexus-snapshots + https://services.mind-overflow.net/nexus/repository/maven-releases/ + - org.bukkit - craftbukkit - 1.12.2-R0.1-SNAPSHOT + org.spigotmc + spigot-api + 1.17.1-R0.1-SNAPSHOT provided + + com.github.LeonMangler + PremiumVanishAPI + 2.7.3 + com.github.MilkBowl VaultAPI @@ -72,8 +81,8 @@ maven-compiler-plugin 3.1 - 1.8 - 1.8 + 9 + 9 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7f2f459..31f9e08 100755 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: TelegramChat main: de.Linus122.TelegramChat.TelegramChat version: ${project.version} authors: [Linus122] -softdepend: [Vault] +softdepend: [Vault, SuperVanish, PremiumVanish] description: Brings minecraft chat to Telegram! commands: telegram: From f3336c972222cc5be4a45d77fad41043426070ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Sat, 2 Oct 2021 17:03:14 +0200 Subject: [PATCH 2/6] Add .gitignore for post-compilation files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a5f2ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.idea +*.class +/target +*.iml From 2b6262df9ad1388cb7e784afacaee97b8a5fa34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Sat, 2 Oct 2021 17:03:34 +0200 Subject: [PATCH 3/6] Add basic vanish support for join/quit messages --- .../de/Linus122/Handlers/VanishHandler.java | 44 +++++++++++++++++++ .../Linus122/TelegramChat/TelegramChat.java | 12 +++++ 2 files changed, 56 insertions(+) create mode 100644 src/main/java/de/Linus122/Handlers/VanishHandler.java diff --git a/src/main/java/de/Linus122/Handlers/VanishHandler.java b/src/main/java/de/Linus122/Handlers/VanishHandler.java new file mode 100644 index 0000000..14ea048 --- /dev/null +++ b/src/main/java/de/Linus122/Handlers/VanishHandler.java @@ -0,0 +1,44 @@ +package de.Linus122.Handlers; + +import de.Linus122.Telegram.Utils; +import de.Linus122.TelegramChat.TelegramChat; +import de.Linus122.TelegramComponents.ChatMessageToTelegram; +import de.myzelyam.api.vanish.PlayerHideEvent; +import de.myzelyam.api.vanish.PlayerShowEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class VanishHandler implements Listener +{ + + @EventHandler + public void onVanish(PlayerHideEvent e) { + Player p = e.getPlayer(); + if(e.isCancelled()) return; + + if (!TelegramChat.getInstance().getConfig().getBoolean("enable-joinquitmessages")) + return; + if (TelegramChat.telegramHook.connected) { + ChatMessageToTelegram chat = new ChatMessageToTelegram(); + chat.parse_mode = "Markdown"; + chat.text = Utils.formatMSG("quit-message", e.getPlayer().getName())[0]; + TelegramChat.telegramHook.sendAll(chat); + } + } + + @EventHandler + public void onShow(PlayerShowEvent e) { + Player p = e.getPlayer(); + if(e.isCancelled()) return; + + if (!TelegramChat.getInstance().getConfig().getBoolean("enable-joinquitmessages")) + return; + if (TelegramChat.telegramHook.connected) { + ChatMessageToTelegram chat = new ChatMessageToTelegram(); + chat.parse_mode = "Markdown"; + chat.text = Utils.formatMSG("join-message", e.getPlayer().getName())[0]; + TelegramChat.telegramHook.sendAll(chat); + } + } +} diff --git a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java index 85a99f7..6dc578d 100755 --- a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java +++ b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java @@ -12,6 +12,7 @@ import java.util.Random; import java.util.UUID; import java.util.logging.Level; +import de.Linus122.Handlers.VanishHandler; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.file.FileConfiguration; @@ -40,17 +41,23 @@ public class TelegramChat extends JavaPlugin implements Listener { private static Data data = new Data(); public static Telegram telegramHook; + private static TelegramChat instance; @Override public void onEnable() { this.saveDefaultConfig(); cfg = this.getConfig(); + instance = this; Utils.cfg = cfg; Bukkit.getPluginCommand("telegram").setExecutor(new TelegramCmd()); Bukkit.getPluginCommand("linktelegram").setExecutor(new LinkTelegramCmd()); Bukkit.getPluginManager().registerEvents(this, this); + if (Bukkit.getPluginManager().isPluginEnabled("SuperVanish") || Bukkit.getPluginManager().isPluginEnabled("PremiumVanish")) { + Bukkit.getPluginManager().registerEvents(new VanishHandler(), this); + } + File dir = new File("plugins/TelegramChat/"); dir.mkdir(); data = new Data(); @@ -238,4 +245,9 @@ public class TelegramChat extends JavaPlugin implements Listener { } } + public static TelegramChat getInstance() + { + return instance; + } + } From de0002fccaceee22a6b04aac9e8097a3f5b90bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Sat, 2 Oct 2021 17:05:34 +0200 Subject: [PATCH 4/6] Add vanish support to real join/quit events --- .../java/de/Linus122/TelegramChat/TelegramChat.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java index 6dc578d..5120cc7 100755 --- a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java +++ b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java @@ -13,6 +13,7 @@ import java.util.UUID; import java.util.logging.Level; import de.Linus122.Handlers.VanishHandler; +import de.myzelyam.api.vanish.VanishAPI; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.file.FileConfiguration; @@ -42,6 +43,7 @@ public class TelegramChat extends JavaPlugin implements Listener { private static Data data = new Data(); public static Telegram telegramHook; private static TelegramChat instance; + private static boolean isSuperVanish; @Override public void onEnable() { @@ -55,6 +57,7 @@ public class TelegramChat extends JavaPlugin implements Listener { Bukkit.getPluginManager().registerEvents(this, this); if (Bukkit.getPluginManager().isPluginEnabled("SuperVanish") || Bukkit.getPluginManager().isPluginEnabled("PremiumVanish")) { + isSuperVanish = true; Bukkit.getPluginManager().registerEvents(new VanishHandler(), this); } @@ -197,6 +200,10 @@ public class TelegramChat extends JavaPlugin implements Listener { public void onJoin(PlayerJoinEvent e) { if (!this.getConfig().getBoolean("enable-joinquitmessages")) return; + + if(VanishAPI.isInvisible(e.getPlayer())) + return; + if (telegramHook.connected) { ChatMessageToTelegram chat = new ChatMessageToTelegram(); chat.parse_mode = "Markdown"; @@ -221,6 +228,10 @@ public class TelegramChat extends JavaPlugin implements Listener { public void onQuit(PlayerQuitEvent e) { if (!this.getConfig().getBoolean("enable-joinquitmessages")) return; + + if(VanishAPI.isInvisible(e.getPlayer())) + return; + if (telegramHook.connected) { ChatMessageToTelegram chat = new ChatMessageToTelegram(); chat.parse_mode = "Markdown"; From 18091cd7f85562c5a103f15a4d67bc06b681f7f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Sat, 2 Oct 2021 17:07:11 +0200 Subject: [PATCH 5/6] Go back to 1.12.2 for spigot base version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02bc281..614a3cb 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ org.spigotmc spigot-api - 1.17.1-R0.1-SNAPSHOT + 1.12.2-R0.1-SNAPSHOT provided From e13185fa29341d3f3af9b12974e9ddd4a73a9161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Sat, 2 Oct 2021 17:12:15 +0200 Subject: [PATCH 6/6] Implement plugin-support check for join/quit messages --- src/main/java/de/Linus122/TelegramChat/TelegramChat.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java index 5120cc7..5c5d8a7 100755 --- a/src/main/java/de/Linus122/TelegramChat/TelegramChat.java +++ b/src/main/java/de/Linus122/TelegramChat/TelegramChat.java @@ -201,7 +201,7 @@ public class TelegramChat extends JavaPlugin implements Listener { if (!this.getConfig().getBoolean("enable-joinquitmessages")) return; - if(VanishAPI.isInvisible(e.getPlayer())) + if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer())) return; if (telegramHook.connected) { @@ -229,7 +229,7 @@ public class TelegramChat extends JavaPlugin implements Listener { if (!this.getConfig().getBoolean("enable-joinquitmessages")) return; - if(VanishAPI.isInvisible(e.getPlayer())) + if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer())) return; if (telegramHook.connected) {