2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2016-05-12 19:40:39 +00:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.bukkit.ChatColor;
|
2015-10-19 17:43:46 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2016-05-12 19:40:39 +00:00
|
|
|
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "mute")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_stfu extends FreedomCommand
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
if (args.length == 0)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-26 10:39:56 +00:00
|
|
|
if (args[0].equals("list"))
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Muted players:");
|
2015-10-19 17:43:46 +00:00
|
|
|
FPlayer info;
|
|
|
|
int count = 0;
|
|
|
|
for (Player mp : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
info = plugin.pl.getPlayer(mp);
|
|
|
|
if (info.isMuted())
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("- " + mp.getName());
|
2015-10-19 17:43:46 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count == 0)
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("- none");
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
|
|
|
|
return true;
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
|
2016-08-26 10:39:56 +00:00
|
|
|
if (args[0].equals("purge"))
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
|
|
|
|
FPlayer info;
|
|
|
|
int count = 0;
|
|
|
|
for (Player mp : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
info = plugin.pl.getPlayer(mp);
|
|
|
|
if (info.isMuted())
|
|
|
|
{
|
|
|
|
info.setMuted(false);
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Unmuted " + count + " players.");
|
2016-05-12 19:40:39 +00:00
|
|
|
return true;
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
|
2016-08-26 10:39:56 +00:00
|
|
|
if (args[0].equals("all"))
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
FUtil.adminAction(sender.getName(), "Muting all non-Superadmins", true);
|
|
|
|
|
|
|
|
FPlayer playerdata;
|
|
|
|
int counter = 0;
|
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (!plugin.al.isAdmin(player))
|
|
|
|
{
|
|
|
|
playerdata = plugin.pl.getPlayer(player);
|
|
|
|
playerdata.setMuted(true);
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Muted " + counter + " players.");
|
2016-05-12 19:40:39 +00:00
|
|
|
return true;
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
|
2016-08-26 10:39:56 +00:00
|
|
|
// -s option (smite)
|
2016-05-12 19:40:39 +00:00
|
|
|
boolean smite = args[0].equals("-s");
|
|
|
|
if (smite)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
args = ArrayUtils.subarray(args, 1, args.length);
|
2016-08-26 10:39:56 +00:00
|
|
|
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
|
|
|
if (player == null)
|
|
|
|
{
|
|
|
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
String reason = null;
|
|
|
|
if (args.length > 1)
|
|
|
|
{
|
|
|
|
reason = StringUtils.join(args, " ", 1, args.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
|
|
if (playerdata.isMuted())
|
|
|
|
{
|
|
|
|
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
|
|
|
playerdata.setMuted(false);
|
|
|
|
msg("Unmuted " + player.getName());
|
|
|
|
|
|
|
|
msg(player, "You have been unmuted.", ChatColor.RED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (plugin.al.isAdmin(player))
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
msg(player.getName() + " is a superadmin, and can't be muted.");
|
2015-10-19 17:43:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
|
|
|
playerdata.setMuted(true);
|
|
|
|
|
|
|
|
if (smite)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2017-12-23 04:07:36 +00:00
|
|
|
Command_smite.smite(sender, player, reason);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2017-12-23 04:07:36 +00:00
|
|
|
msg(player, "You have been muted.", ChatColor.RED);
|
2016-05-12 19:40:39 +00:00
|
|
|
msg("Muted " + player.getName());
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|