Compare commits

..

12 Commits

Author SHA1 Message Date
MasterCake
178399bf94
Update README.md
add developer information + add jenkins build status badge
2022-02-08 19:25:18 +01:00
MasterCake
72b48d2666 update minor version 2022-02-08 18:46:10 +01:00
MasterCake
fda86cc69e
Merge pull request #19 from iCaitlyn/master
Refactor user ids and chat ids from integer type to long type
2022-02-08 17:30:03 +00:00
iCaitlyn
62fc23beed
Update CommandHandler.java 2022-02-09 01:25:00 +08:00
iCaitlyn
d6232f4846
Update User.java 2022-02-09 01:24:12 +08:00
MasterCake
8f24cd35ac
Merge pull request #17 from mind-overflow/premiumvanish-support
SuperVanish/PremiumVanish support
2022-02-08 17:05:47 +00:00
e13185fa29 Implement plugin-support check for join/quit messages 2021-10-02 17:12:15 +02:00
18091cd7f8 Go back to 1.12.2 for spigot base version 2021-10-02 17:07:11 +02:00
de0002fcca Add vanish support to real join/quit events 2021-10-02 17:05:34 +02:00
2b6262df9a Add basic vanish support for join/quit messages 2021-10-02 17:03:34 +02:00
f3336c9722 Add .gitignore for post-compilation files 2021-10-02 17:03:14 +02:00
84a25484c4 Add PremiumVanish/SuperVanish (soft)dependencies 2021-10-02 17:03:01 +02:00
8 changed files with 121 additions and 19 deletions

4
.gitignore vendored Normal file
View File

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

View File

@ -1,21 +1,43 @@
[![GitHub last commit](https://img.shields.io/github/last-commit/mastercake10/TelegramChat.svg)](https://github.com/mastercake10/TelegramChat/commits/master) [![GitHub last commit](https://img.shields.io/github/last-commit/mastercake10/TelegramChat.svg)](https://github.com/mastercake10/TelegramChat/commits/master)
[![build status](https://ci.spaceio.xyz/buildStatus/icon?job=TelegramChat)](https://ci.spaceio.xyz/job/TelegramChat/lastBuild/xyz.spaceio$telegramchat/)
[![discord](https://discordapp.com/api/guilds/330725294749122561/widget.png)](https://discord.gg/3xgsPh8) [![discord](https://discordapp.com/api/guilds/330725294749122561/widget.png)](https://discord.gg/3xgsPh8)
[![view on SpigotMC](https://img.shields.io/badge/view%20on-spigotmc-orange.svg)](https://www.spigotmc.org/resources/telegramchat.16576/) [![view on SpigotMC](https://img.shields.io/badge/view%20on-spigotmc-orange.svg)](https://www.spigotmc.org/resources/telegramchat.16576/)
![resource icon](https://www.spigotmc.org/data/resource_icons/16/16576.jpg?1476392100) ![resource icon](https://www.spigotmc.org/data/resource_icons/16/16576.jpg?1476392100)
## Welcome to the TelegramChat GitHub repository! ## Welcome to the TelegramChat GitHub repository!
TelegramChat is a Spigot plugin compatible with Spigot versions 1.7 through 1.16.*, that connects Telegram with Minecraft. TelegramChat is a Bukkit plugin compatible with Paper/Spigot versions 1.7 through 1.18.*, that connects Telegram with Minecraft.
### Usage ## Usage
1. Create a new bot by messaging the @BotFather and following the instructions. 1. Create a new bot by messaging the @BotFather and following the instructions.
2. Obtain the token (`/tokentype` in Telegram) and type `/linktelegram <token>` to link the newly created Bot to your Server. This needs to be done once. 2. Obtain the token (`/tokentype` in Telegram) and type `/linktelegram <token>` to link the newly created Bot to your Server. This needs to be done once.
3. Each user needs to be linked to their Telegram account in order to chat mc <-> telegram. 3. Each user needs to be linked to their Telegram account in order to chat mc <-> telegram.
## Private chats ### Private chats
1. Your users need to type `/telegram` in-game to get a temporary code for linking 1. Your users need to type `/telegram` in-game to get a temporary code for linking
2. The code is then sent to the Telegram bot. 2. The code is then sent to the Telegram bot.
## Group chats ### Group chats
1. As an admin, you need to set the privacy setting to disabled using the BotFather. This is done by typing `/setprivacy` and then disabled. 1. As an admin, you need to set the privacy setting to disabled using the BotFather. This is done by typing `/setprivacy` and then disabled.
2. Users just need to join the group to see the MC chat. They might want to link their account by posting their /linktelegram code in the group chat. 2. Users just need to join the group to see the MC chat. They might want to link their account by posting their /linktelegram code in the group chat.
## Developers
* [Jenkins](https://ci.spaceio.xyz/job/TelegramChat/lastBuild/xyz.spaceio$telegramchat/) latest builds, including unstable ones
* [Repository](https://repo.spaceio.xyz/#browse/browse:maven-snapshots:xyz%2Fspaceio%2Ftelegramchat)
### API
```xml
<repository>
<id>spaceio-repo</id>
<url>https://repo.spaceio.xyz/repository/maven-public/</url>
</repository>
<dependencies>
<dependency>
<groupId>xyz.spaceio</groupId>
<artifactId>telegramchat</artifactId>
<version>VERSION_HERE-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
```

29
pom.xml
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>xyz.spaceio</groupId> <groupId>xyz.spaceio</groupId>
<artifactId>telegramchat</artifactId> <artifactId>telegramchat</artifactId>
<version>1.0.17-SNAPSHOT</version> <version>1.0.18-SNAPSHOT</version>
<name>TelegramChat</name> <name>TelegramChat</name>
<url>https://www.spigotmc.org/resources/telegramchat.16576/</url> <url>https://www.spigotmc.org/resources/telegramchat.16576/</url>
@ -25,15 +25,24 @@
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository>
<id>nexus-snapshots</id>
<url>https://services.mind-overflow.net/nexus/repository/maven-releases/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.spigotmc</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.LeonMangler</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.7.3</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.MilkBowl</groupId> <groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
@ -42,16 +51,16 @@
</dependency> </dependency>
</dependencies> </dependencies>
<distributionManagement> <distributionManagement>
<snapshotRepository>
<id>spaceio-snapshots</id>
<name>snapshots</name>
<url>https://repo.spaceio.xyz/repository/maven-snapshots/</url>
</snapshotRepository>
<repository> <repository>
<id>spaceio-releases</id> <id>spaceio-releases</id>
<name>releases</name> <name>releases</name>
<url>https://repo.spaceio.xyz/repository/maven-releases/</url> <url>https://repo.spaceio.xyz/repository/maven-releases/</url>
</repository> </repository>
<snapshotRepository>
<id>spaceio-snapshots</id>
<name>snapshots</name>
<url>https://repo.spaceio.xyz/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement> </distributionManagement>
<build> <build>
<!-- Uses the properties in this file for plugin.yml and config.yml --> <!-- Uses the properties in this file for plugin.yml and config.yml -->
@ -72,8 +81,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.1</version>
<configuration> <configuration>
<source>1.8</source> <source>9</source>
<target>1.8</target> <target>9</target>
</configuration> </configuration>
</plugin> </plugin>
<!-- Sets the custom JARfile name (Project name without spaces is good) --> <!-- Sets the custom JARfile name (Project name without spaces is good) -->

View File

@ -27,7 +27,7 @@ import net.milkbowl.vault.permission.Permission;
public class CommandHandler extends ConsoleHandler implements TelegramActionListener { public class CommandHandler extends ConsoleHandler implements TelegramActionListener {
private Permission permissionsAdapter; private Permission permissionsAdapter;
private int lastChatId = -1; private long lastChatId = -1;
private long lastCommandTyped; private long lastCommandTyped;
private Telegram telegram; private Telegram telegram;

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.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import de.Linus122.Handlers.VanishHandler;
import de.myzelyam.api.vanish.VanishAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -40,17 +42,25 @@ public class TelegramChat extends JavaPlugin implements Listener {
private static Data data = new Data(); private static Data data = new Data();
public static Telegram telegramHook; public static Telegram telegramHook;
private static TelegramChat instance;
private static boolean isSuperVanish;
@Override @Override
public void onEnable() { public void onEnable() {
this.saveDefaultConfig(); this.saveDefaultConfig();
cfg = this.getConfig(); cfg = this.getConfig();
instance = this;
Utils.cfg = cfg; Utils.cfg = cfg;
Bukkit.getPluginCommand("telegram").setExecutor(new TelegramCmd()); Bukkit.getPluginCommand("telegram").setExecutor(new TelegramCmd());
Bukkit.getPluginCommand("linktelegram").setExecutor(new LinkTelegramCmd()); Bukkit.getPluginCommand("linktelegram").setExecutor(new LinkTelegramCmd());
Bukkit.getPluginManager().registerEvents(this, this); 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/"); File dir = new File("plugins/TelegramChat/");
dir.mkdir(); dir.mkdir();
data = new Data(); data = new Data();
@ -190,6 +200,10 @@ public class TelegramChat extends JavaPlugin implements Listener {
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
if (!this.getConfig().getBoolean("enable-joinquitmessages")) if (!this.getConfig().getBoolean("enable-joinquitmessages"))
return; return;
if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer()))
return;
if (telegramHook.connected) { if (telegramHook.connected) {
ChatMessageToTelegram chat = new ChatMessageToTelegram(); ChatMessageToTelegram chat = new ChatMessageToTelegram();
chat.parse_mode = "Markdown"; chat.parse_mode = "Markdown";
@ -214,6 +228,10 @@ public class TelegramChat extends JavaPlugin implements Listener {
public void onQuit(PlayerQuitEvent e) { public void onQuit(PlayerQuitEvent e) {
if (!this.getConfig().getBoolean("enable-joinquitmessages")) if (!this.getConfig().getBoolean("enable-joinquitmessages"))
return; return;
if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer()))
return;
if (telegramHook.connected) { if (telegramHook.connected) {
ChatMessageToTelegram chat = new ChatMessageToTelegram(); ChatMessageToTelegram chat = new ChatMessageToTelegram();
chat.parse_mode = "Markdown"; chat.parse_mode = "Markdown";
@ -238,4 +256,9 @@ public class TelegramChat extends JavaPlugin implements Listener {
} }
} }
public static TelegramChat getInstance()
{
return instance;
}
} }

View File

@ -1,16 +1,16 @@
package de.Linus122.TelegramComponents; package de.Linus122.TelegramComponents;
public class User { public class User {
private int id; private long id;
private boolean is_bot; private boolean is_bot;
private String first_name; private String first_name;
private String last_name; private String last_name;
public int getId() { public long getId() {
return id; return id;
} }
public void setId(int id) { public void setId(long id) {
this.id = id; this.id = id;
} }

View File

@ -2,7 +2,7 @@ name: TelegramChat
main: de.Linus122.TelegramChat.TelegramChat main: de.Linus122.TelegramChat.TelegramChat
version: ${project.version} version: ${project.version}
authors: [Linus122] authors: [Linus122]
softdepend: [Vault] softdepend: [Vault, SuperVanish, PremiumVanish]
description: Brings minecraft chat to Telegram! description: Brings minecraft chat to Telegram!
commands: commands:
telegram: telegram: