Skip to content

Commit

Permalink
Merge pull request #24 from Arthessia/master
Browse files Browse the repository at this point in the history
Silent Update
  • Loading branch information
mastercake10 authored Dec 12, 2022
2 parents 0f395cd + ab920e7 commit bf29315
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
*.class
/target
*.iml
.project
.classpath
.settings/
*.prefs
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.spaceio</groupId>
<artifactId>telegramchat</artifactId>
<version>1.0.19-SNAPSHOT</version>
<version>1.0.20-SNAPSHOT</version>
<name>TelegramChat</name>
<url>https://www.spigotmc.org/resources/telegramchat.16576/</url>

Expand Down
1 change: 0 additions & 1 deletion src/main/java/de/Linus122/Handlers/BanHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/de/Linus122/Handlers/CommandHandler.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/de/Linus122/Telegram/Telegram.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ public void handleUserMessage(String text, Update update) {
}
}
} else {
this.sendMsg(chat.getId(), Utils.formatMSG("need-to-link")[0]);
boolean skipIfNeedToLinkSilent = TelegramChat.getInstance().getConfig().getBoolean("omit-messages-need-to-link");
if (!skipIfNeedToLinkSilent) {
this.sendMsg(chat.getId(), Utils.formatMSG("need-to-link")[0]);
}
}
}

Expand All @@ -172,6 +175,8 @@ public void sendMsg(ChatMessageToTelegram chat) {
for (TelegramActionListener actionListener : listeners) {
actionListener.onSendToTelegram(chat);
}
chat.disable_notification = TelegramChat.getInstance().getConfig().getBoolean("turn-to-silent-notification");

Gson gson = new Gson();
if(!chat.isCancelled()){
post("sendMessage", gson.toJson(chat, ChatMessageToTelegram.class));
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/de/Linus122/TelegramChat/LinkTelegramCmd.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/de/Linus122/TelegramChat/TelegramChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class ChatMessageToTelegram extends Cancellable {
public String text;
public Boolean disable_notification;
public long chat_id;
public String parse_mode;
}
6 changes: 6 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +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
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit bf29315

Please sign in to comment.