fix clearchat

This commit is contained in:
speed 2020-07-27 23:37:10 -04:00 committed by GitHub
parent 95e67f84ef
commit 8e8daa457b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,28 +1,30 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.stream.IntStream;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/<command>", aliases = "cc") @CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
public class Command_clearchat extends FreedomCommand public class Command_clearchat extends FreedomCommand
{ {
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!plugin.al.isAdmin(player)) if (!plugin.al.isAdmin(player))
{ {
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage); for (int i = 0; i < 100; i++)
{
player.sendMessage("");
}
} }
} }
FUtil.adminAction(sender.getName(), "Cleared chat", true);
return true; return true;
} }
} }