src/main/java/dev/viper/telegramchat/TelegramCommand.java aktualisiert
This commit is contained in:
@@ -1,65 +1,83 @@
|
||||
package dev.viper.telegramchat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TelegramCommand implements CommandExecutor {
|
||||
private final TelegramChatBridge plugin;
|
||||
private final ChatModeManager chatModeManager;
|
||||
|
||||
public TelegramCommand(TelegramChatBridge plugin, ChatModeManager manager) {
|
||||
this.plugin = plugin;
|
||||
this.chatModeManager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(ChatColor.RED + "Dieser Befehl kann nur von einem Spieler ausgeführt werden.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
// Wechsel in Telegram-Chatmodus
|
||||
chatModeManager.setMode(player.getUniqueId(), ChatModeManager.ChatMode.TELEGRAM);
|
||||
String msg = plugin.getConfig().getString("messages.mode-set-telegram", "Du bist jetzt im Telegram-Chatmodus.");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
String sub = args[0].toLowerCase();
|
||||
|
||||
if (sub.equals("info")) {
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "=== TelegramChatBridge Info ===");
|
||||
player.sendMessage(ChatColor.GRAY + "Version: " + ChatColor.WHITE + plugin.getDescription().getVersion());
|
||||
player.sendMessage(ChatColor.GRAY + "Ersteller: " + ChatColor.WHITE + "M_Viper");
|
||||
|
||||
String chatId = plugin.getChatId();
|
||||
String chatType = "Unbekannt";
|
||||
if (chatId != null) {
|
||||
if (chatId.startsWith("-")) {
|
||||
chatType = "Gruppenchat";
|
||||
} else {
|
||||
chatType = "Privat Chat";
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.GRAY + "Chat-Typ: " + ChatColor.WHITE + chatType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sub.equals("help")) {
|
||||
player.sendMessage(ChatColor.GREEN + "=== TelegramChatBridge Befehle ===");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg" + ChatColor.WHITE + " - Wechsel in Telegram-Chatmodus");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg info" + ChatColor.WHITE + " - Plugin-Informationen anzeigen");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg help" + ChatColor.WHITE + " - Diese Hilfe anzeigen");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED + "Unbekannter Unterbefehl. Nutze /tg help");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package dev.viper.telegramchat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TelegramCommand implements CommandExecutor {
|
||||
private final TelegramChatBridge plugin;
|
||||
private final ChatModeManager chatModeManager;
|
||||
|
||||
public TelegramCommand(TelegramChatBridge plugin, ChatModeManager manager) {
|
||||
this.plugin = plugin;
|
||||
this.chatModeManager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(ChatColor.RED + "Dieser Befehl kann nur von einem Spieler ausgeführt werden.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Wenn keine Argumente angegeben wurden, standardmäßig den Telegram-Modus aktivieren
|
||||
if (args.length == 0) {
|
||||
chatModeManager.setMode(player.getUniqueId(), ChatModeManager.ChatMode.TELEGRAM);
|
||||
String msg = plugin.getConfig().getString("messages.mode-set-telegram", "Du bist jetzt im Telegram-Chatmodus.");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
String sub = args[0].toLowerCase();
|
||||
|
||||
// Befehl: /tg on
|
||||
if (sub.equals("on")) {
|
||||
chatModeManager.setMode(player.getUniqueId(), ChatModeManager.ChatMode.TELEGRAM);
|
||||
String msg = plugin.getConfig().getString("messages.mode-set-telegram", "Du bist jetzt im Telegram-Chatmodus.");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Befehl: /tg off
|
||||
if (sub.equals("off")) {
|
||||
chatModeManager.setMode(player.getUniqueId(), ChatModeManager.ChatMode.MINECRAFT);
|
||||
String msg = plugin.getConfig().getString("messages.mode-set-minecraft", "Du bist jetzt im Minecraft-Chatmodus.");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sub.equals("info")) {
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "=== TelegramChatBridge Info ===");
|
||||
player.sendMessage(ChatColor.GRAY + "Version: " + ChatColor.WHITE + plugin.getDescription().getVersion());
|
||||
player.sendMessage(ChatColor.GRAY + "Ersteller: " + ChatColor.WHITE + "M_Viper");
|
||||
|
||||
String chatId = plugin.getChatId();
|
||||
String chatType = "Unbekannt";
|
||||
if (chatId != null) {
|
||||
if (chatId.startsWith("-")) {
|
||||
chatType = "Gruppenchat";
|
||||
} else {
|
||||
chatType = "Privat Chat";
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.GRAY + "Chat-Typ: " + ChatColor.WHITE + chatType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sub.equals("help")) {
|
||||
player.sendMessage(ChatColor.GREEN + "=== TelegramChatBridge Befehle ===");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg" + ChatColor.WHITE + " - Wechsel in Telegram-Chatmodus");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg on" + ChatColor.WHITE + " - Aktiviert den Telegram-Chatmodus");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg off" + ChatColor.WHITE + " - Deaktiviert den Telegram-Chatmodus (Normaler Chat)");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg info" + ChatColor.WHITE + " - Plugin-Informationen anzeigen");
|
||||
player.sendMessage(ChatColor.YELLOW + "/tg help" + ChatColor.WHITE + " - Diese Hilfe anzeigen");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED + "Unbekannter Unterbefehl. Nutze /tg help");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user