Merge pull request #17 from mind-overflow/premiumvanish-support

SuperVanish/PremiumVanish support
This commit is contained in:
MasterCake 2022-02-08 17:05:47 +00:00 committed by GitHub
commit 8f24cd35ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 5 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/.idea
*.class
/target
*.iml

17
pom.xml
View File

@ -25,15 +25,24 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>nexus-snapshots</id>
<url>https://services.mind-overflow.net/nexus/repository/maven-releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LeonMangler</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
@ -72,8 +81,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<!-- Sets the custom JARfile name (Project name without spaces is good) -->

View File

@ -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);
}
}
}

View File

@ -12,6 +12,8 @@ import java.util.Random;
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;
@ -40,17 +42,25 @@ 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() {
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")) {
isSuperVanish = true;
Bukkit.getPluginManager().registerEvents(new VanishHandler(), this);
}
File dir = new File("plugins/TelegramChat/");
dir.mkdir();
data = new Data();
@ -190,6 +200,10 @@ public class TelegramChat extends JavaPlugin implements Listener {
public void onJoin(PlayerJoinEvent e) {
if (!this.getConfig().getBoolean("enable-joinquitmessages"))
return;
if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer()))
return;
if (telegramHook.connected) {
ChatMessageToTelegram chat = new ChatMessageToTelegram();
chat.parse_mode = "Markdown";
@ -214,6 +228,10 @@ public class TelegramChat extends JavaPlugin implements Listener {
public void onQuit(PlayerQuitEvent e) {
if (!this.getConfig().getBoolean("enable-joinquitmessages"))
return;
if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer()))
return;
if (telegramHook.connected) {
ChatMessageToTelegram chat = new ChatMessageToTelegram();
chat.parse_mode = "Markdown";
@ -238,4 +256,9 @@ public class TelegramChat extends JavaPlugin implements Listener {
}
}
public static TelegramChat getInstance()
{
return instance;
}
}

View File

@ -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: