|
@@ -36,6 +36,8 @@ public class Main extends JavaPlugin implements Listener{
|
|
|
|
|
|
public static Data data = new Data();
|
|
public static Data data = new Data();
|
|
static Plugin pl;
|
|
static Plugin pl;
|
|
|
|
+ public static Telegram telegramHook;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onEnable(){
|
|
public void onEnable(){
|
|
this.saveDefaultConfig();
|
|
this.saveDefaultConfig();
|
|
@@ -60,11 +62,13 @@ public class Main extends JavaPlugin implements Listener{
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- Telegram.auth();
|
|
|
|
|
|
+ telegramHook = new Telegram();
|
|
|
|
+ telegramHook.auth(data.token);
|
|
|
|
+
|
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
|
public void run(){
|
|
public void run(){
|
|
- if(Telegram.connected){
|
|
|
|
- Telegram.getupdate();
|
|
|
|
|
|
+ if(telegramHook.connected){
|
|
|
|
+ telegramHook.getUpdate();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, 20L, 20L);
|
|
}, 20L, 20L);
|
|
@@ -95,7 +99,7 @@ public class Main extends JavaPlugin implements Listener{
|
|
recievers.remove((Object) sender);
|
|
recievers.remove((Object) sender);
|
|
String msgF = Main.cfg.getString("chat-format").replace('&', '§').replace("%player%", op.getName()).replace("%message%", msg);
|
|
String msgF = Main.cfg.getString("chat-format").replace('&', '§').replace("%player%", op.getName()).replace("%message%", msg);
|
|
for(int id : recievers){
|
|
for(int id : recievers){
|
|
- Telegram.sendMsg(id, msgF);
|
|
|
|
|
|
+ telegramHook.sendMsg(id, msgF);
|
|
}
|
|
}
|
|
Bukkit.broadcastMessage(msgF.replace("&", "§"));
|
|
Bukkit.broadcastMessage(msgF.replace("&", "§"));
|
|
|
|
|
|
@@ -103,7 +107,7 @@ public class Main extends JavaPlugin implements Listener{
|
|
public static void link(UUID player, int chatID){
|
|
public static void link(UUID player, int chatID){
|
|
Main.data.linkedChats.put(chatID, player);
|
|
Main.data.linkedChats.put(chatID, player);
|
|
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
|
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
|
- Telegram.sendMsg(chatID, "Success! Linked " + p.getName());
|
|
|
|
|
|
+ telegramHook.sendMsg(chatID, "Success! Linked " + p.getName());
|
|
}
|
|
}
|
|
public static String generateLinkToken(){
|
|
public static String generateLinkToken(){
|
|
Random rnd = new Random();
|
|
Random rnd = new Random();
|
|
@@ -126,42 +130,42 @@ public class Main extends JavaPlugin implements Listener{
|
|
@EventHandler
|
|
@EventHandler
|
|
public void onJoin(PlayerJoinEvent e){
|
|
public void onJoin(PlayerJoinEvent e){
|
|
if(!this.getConfig().getBoolean("enable-joinquitmessages")) return;
|
|
if(!this.getConfig().getBoolean("enable-joinquitmessages")) return;
|
|
- if(Telegram.connected){
|
|
|
|
|
|
+ if(telegramHook.connected){
|
|
Chat chat = new Chat();
|
|
Chat chat = new Chat();
|
|
chat.parse_mode = "Markdown";
|
|
chat.parse_mode = "Markdown";
|
|
chat.text = "`" + e.getPlayer().getName() + " joined the game.`";
|
|
chat.text = "`" + e.getPlayer().getName() + " joined the game.`";
|
|
- Telegram.sendAll(chat);
|
|
|
|
|
|
+ telegramHook.sendAll(chat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@EventHandler
|
|
@EventHandler
|
|
public void onDeath(PlayerDeathEvent e){
|
|
public void onDeath(PlayerDeathEvent e){
|
|
if(!this.getConfig().getBoolean("enable-deathmessages")) return;
|
|
if(!this.getConfig().getBoolean("enable-deathmessages")) return;
|
|
- if(Telegram.connected){
|
|
|
|
|
|
+ if(telegramHook.connected){
|
|
Chat chat = new Chat();
|
|
Chat chat = new Chat();
|
|
chat.parse_mode = "Markdown";
|
|
chat.parse_mode = "Markdown";
|
|
chat.text = "`"+e.getDeathMessage() + "`";
|
|
chat.text = "`"+e.getDeathMessage() + "`";
|
|
- Telegram.sendAll(chat);
|
|
|
|
|
|
+ telegramHook.sendAll(chat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@EventHandler
|
|
@EventHandler
|
|
public void onQuit(PlayerQuitEvent e){
|
|
public void onQuit(PlayerQuitEvent e){
|
|
if(!this.getConfig().getBoolean("enable-joinquitmessages")) return;
|
|
if(!this.getConfig().getBoolean("enable-joinquitmessages")) return;
|
|
- if(Telegram.connected){
|
|
|
|
|
|
+ if(telegramHook.connected){
|
|
Chat chat = new Chat();
|
|
Chat chat = new Chat();
|
|
chat.parse_mode = "Markdown";
|
|
chat.parse_mode = "Markdown";
|
|
chat.text = "`" + e.getPlayer().getName() + " left the game.`";
|
|
chat.text = "`" + e.getPlayer().getName() + " left the game.`";
|
|
System.out.println(chat.text);
|
|
System.out.println(chat.text);
|
|
- Telegram.sendAll(chat);
|
|
|
|
|
|
+ telegramHook.sendAll(chat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@EventHandler
|
|
@EventHandler
|
|
public void onChat(AsyncPlayerChatEvent e){
|
|
public void onChat(AsyncPlayerChatEvent e){
|
|
if(!this.getConfig().getBoolean("enable-chatmessages")) return;
|
|
if(!this.getConfig().getBoolean("enable-chatmessages")) return;
|
|
- if(Telegram.connected){
|
|
|
|
|
|
+ if(telegramHook.connected){
|
|
Chat chat = new Chat();
|
|
Chat chat = new Chat();
|
|
chat.parse_mode = "Markdown";
|
|
chat.parse_mode = "Markdown";
|
|
chat.text = e.getPlayer().getName() + ": _" + e.getMessage().replaceAll("§.", "") + "_";
|
|
chat.text = e.getPlayer().getName() + ": _" + e.getMessage().replaceAll("§.", "") + "_";
|
|
- Telegram.sendAll(chat);
|
|
|
|
|
|
+ telegramHook.sendAll(chat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|