Add /clearchat command

This commit is contained in:
JeremyStar™ 2024-04-30 22:30:55 +02:00
parent d776de46c7
commit 027b86d5f2
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
3 changed files with 41 additions and 0 deletions

View file

@ -109,4 +109,7 @@ public class Translation {
public static String MSG_NO_LAST_MESSAGED_PLAYER = "Du scheinst keinen Spieler in der letzten Zeit angeschrieben zu haben."; public static String MSG_NO_LAST_MESSAGED_PLAYER = "Du scheinst keinen Spieler in der letzten Zeit angeschrieben zu haben.";
public static String MSG_TO = "<gold><bold>%reciever% <reset><gold>« <bold>%sender% <reset><gold>» <reset>%message%"; public static String MSG_TO = "<gold><bold>%reciever% <reset><gold>« <bold>%sender% <reset><gold>» <reset>%message%";
public static String MSG_FROM = "<gold><bold>%reciever% <reset><gold>» <bold>%sender% <reset><gold>» <reset>%message%"; public static String MSG_FROM = "<gold><bold>%reciever% <reset><gold>» <bold>%sender% <reset><gold>» <reset>%message%";
// Command: /clearchat
public static String CLEARCHAT = "Der Chat wurde von %sender% geleert.";
} }

View file

@ -0,0 +1,30 @@
package de.pickshadow.plugin.commands;
import de.pickshadow.plugin.base.Translation;
import de.pickshadow.plugin.classes.CommandBase;
import de.pickshadow.plugin.utils.Miscellaneous;
import de.pickshadow.plugin.utils.TabCompletionHelper;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ClearChatCommand extends CommandBase {
public ClearChatCommand() {
commandNames = new String[]{ "clearchat" };
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
for (Player player : Bukkit.getOnlinePlayers()) player.sendMessage(MiniMessage.miniMessage().deserialize("\n".repeat(10000)).append(Miscellaneous.format(Translation.CLEARCHAT.replace("%sender%", sender.getName()))));
return true;
}
@Override
public TabCompleter getCompletion() {
return TabCompletionHelper.createEmptyCompletion();
}
}

View file

@ -62,6 +62,11 @@ commands:
usage: /reply <Nachricht> usage: /reply <Nachricht>
aliases: [ "r" ] aliases: [ "r" ]
permission: pickshadow.commands.reply permission: pickshadow.commands.reply
clearchat:
description: Löscht den Chatverlauf für den gesamten Server.
usage: /clearchat
aliases: [ "cc", "chatclear" ]
permission: pickshadow.commands.clearchat
permissions: permissions:
pickshadow.*: pickshadow.*:
@ -81,6 +86,7 @@ permissions:
- pickshadow.commands.broadcast - pickshadow.commands.broadcast
- pickshadow.commands.msg - pickshadow.commands.msg
- pickshadow.commands.reply - pickshadow.commands.reply
- pickshadow.commands.clearchat
pickshadow.commands.discord: pickshadow.commands.discord:
default: not op default: not op
pickshadow.commands.home: pickshadow.commands.home:
@ -97,3 +103,5 @@ permissions:
default: not op default: not op
pickshadow.commands.reply: pickshadow.commands.reply:
default: not op default: not op
pickshadow.commands.clearchat:
default: op