Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
CommandClearChat: add clear for all players
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 14, 2023
1 parent 21bb74d commit d3d466f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/net/flectone/commands/CommandClearChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.flectone.misc.commands.FCommand;
import net.flectone.misc.commands.FTabCompleter;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
Expand All @@ -20,6 +21,10 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command

if (fCommand.isHaveCD()) return true;

if (commandSender.hasPermission("flectonechat.clear-chat.other") && strings.length == 1) {
Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage(clearedString));
}

commandSender.sendMessage(clearedString);
fCommand.sendMeMessage("command.clear-chat.message");

Expand All @@ -29,6 +34,14 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
wordsList.clear();

if (!commandSender.hasPermission("flectonechat.clear-chat.other")) return wordsList;

if (strings.length == 1) {
isStartsWith(strings[0], "all");
}

return wordsList;
}

Expand Down

0 comments on commit d3d466f

Please sign in to comment.