mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-04-16 07:33:01 +00:00
* Command_adminworld.java * Command_adventure.java * Command_banip.java * Command_blockedit.java * Command_blockpvp.java * Command_cage.java * Command_cartsit.java * Command_clearchat.java * Command_clearinventory.java * Command_commandlist.java * Command_creative.java * Command_deop.java * Command_deopall.java * Command_dispfill.java * Command_doom.java * Command_gcmd.java * Command_hubworld.java * Command_inspect.java * Command_list.java * Command_lockup.java * Command_manageshop.java * Command_manuallyverify.java * Command_masterbuilderworld.java * Command_mbconfig.java * Command_moblimiter.java * Command_mp44.java * Command_mute.java * Command_nickfilter.java * Command_op.java * Command_opall.java * Command_opme.java * Command_potion.java (Also corrected the inconsistent "player not found" message's color) * Command_rank.java * Command_ride.java * Command_saconfig.java * Command_scare.java * Command_setplayerlimit.java * Command_settotalvotes.java * Command_smite.java * Command_spectator.java * Command_survival.java * Command_unblockcmd.java * Command_uncage.java * Command_unmute.java * Command_verifynoadmin.java Here are some commands I added functionality to: * Command_dispfill.java: Added some code that hooks into the CoreProtect API to log the items being removed from and added into the dispensers. * Command_setlever.java: Added some code that hooks into the CoreProtect API to log the levers being interacted with. Here's a command I fixed a critical bug in: * Command_setlever.java
181 lines
5.6 KiB
Java
181 lines
5.6 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
|
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-s | -q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
|
public class Command_mute extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("list"))
|
|
{
|
|
msg("Muted players:");
|
|
FPlayer info;
|
|
int count = 0;
|
|
for (Player mp : server.getOnlinePlayers())
|
|
{
|
|
info = plugin.pl.getPlayer(mp);
|
|
if (info.isMuted())
|
|
{
|
|
msg("- " + mp.getName());
|
|
count++;
|
|
}
|
|
}
|
|
if (count == 0)
|
|
{
|
|
msg("- none");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("purge"))
|
|
{
|
|
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);
|
|
mp.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
|
count++;
|
|
}
|
|
}
|
|
plugin.mu.MUTED_PLAYERS.clear();
|
|
msg("Unmuted " + count + " players.");
|
|
return true;
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("all"))
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
|
|
|
|
FPlayer playerdata;
|
|
int counter = 0;
|
|
for (Player player : server.getOnlinePlayers())
|
|
{
|
|
if (!plugin.al.isAdmin(player))
|
|
{
|
|
player.sendTitle(ChatColor.RED + "You've been muted globally.", ChatColor.YELLOW + "Please be patient and you will be unmuted shortly.", 20, 100, 60);
|
|
playerdata = plugin.pl.getPlayer(player);
|
|
playerdata.setMuted(true);
|
|
counter++;
|
|
}
|
|
}
|
|
|
|
msg("Muted " + counter + " players.");
|
|
return true;
|
|
}
|
|
|
|
// -s option (smite)
|
|
boolean smite = args[0].equals("-s");
|
|
// -q option (shadowmute)
|
|
boolean quiet = args[0].equals("-q");
|
|
if (smite || quiet)
|
|
{
|
|
args = ArrayUtils.subarray(args, 1, args.length);
|
|
|
|
if (args.length < 1)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
final Player player = getPlayer(args[0]);
|
|
if (player == null)
|
|
{
|
|
msg(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 (plugin.al.isAdmin(player))
|
|
{
|
|
msg(player.getName() + " is an admin, and can't be muted.");
|
|
return true;
|
|
}
|
|
|
|
if (!playerdata.isMuted())
|
|
{
|
|
playerdata.setMuted(true);
|
|
player.sendTitle(ChatColor.RED + "You've been muted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
|
if (reason != null)
|
|
{
|
|
msg(player, ChatColor.RED + "Reason: " + ChatColor.YELLOW + reason);
|
|
}
|
|
if (quiet)
|
|
{
|
|
msg("Muted " + player.getName() + " quietly");
|
|
return true;
|
|
}
|
|
|
|
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
|
|
|
if (smite)
|
|
{
|
|
Command_smite.smite(sender, player, reason);
|
|
}
|
|
|
|
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
|
msg("Muted " + player.getName());
|
|
|
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
|
}
|
|
else
|
|
{
|
|
msg(ChatColor.RED + "That player is already muted.");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
{
|
|
if (!plugin.al.isAdmin(sender))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (args.length == 1)
|
|
{
|
|
List<String> arguments = new ArrayList<>();
|
|
arguments.addAll(FUtil.getPlayerList());
|
|
arguments.addAll(Arrays.asList("list", "purge", "all"));
|
|
return arguments;
|
|
}
|
|
|
|
return Collections.emptyList();
|
|
}
|
|
} |