mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-18 05:16:12 +00:00
c4fce3f0f9
* 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
224 lines
7.5 KiB
Java
224 lines
7.5 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
|
@CommandParameters(description = "List, add, or remove master builders. Master builders can also clear their own IPs.", usage = "/<command> <list | clearip <ip> | clearips | <<add | remove> <username>>>")
|
|
public class Command_mbconfig extends FreedomCommand
|
|
{
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length < 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
switch (args[0])
|
|
{
|
|
case "list":
|
|
{
|
|
msg("Master Builders: " + StringUtils.join(plugin.pl.getMasterBuilderNames(), ", "), ChatColor.GOLD);
|
|
return true;
|
|
}
|
|
|
|
case "clearips":
|
|
{
|
|
if (args.length > 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (senderIsConsole)
|
|
{
|
|
msg("Only in-game players may use this command.", ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
PlayerData data = plugin.pl.getData(sender.getName());
|
|
if (!data.isMasterBuilder())
|
|
{
|
|
msg("You are not a master builder!", ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
int counter = data.getIps().size() - 1;
|
|
data.clearIps();
|
|
data.addIp(FUtil.getIp(playerSender));
|
|
plugin.sql.addPlayer(data);
|
|
msg(counter + " IPs removed.");
|
|
msg(data.getIps().get(0) + " is now your only IP address");
|
|
FUtil.adminAction(sender.getName(), "Clearing my IPs", true);
|
|
return true;
|
|
}
|
|
case "clearip":
|
|
{
|
|
if (args.length < 2)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (senderIsConsole)
|
|
{
|
|
msg("Only in-game players may use this command.", ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
PlayerData data = plugin.pl.getData(sender.getName());
|
|
final String targetIp = FUtil.getIp(playerSender);
|
|
|
|
if (!data.isMasterBuilder())
|
|
{
|
|
msg("You are not a master builder!", ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
if (targetIp.equals(args[1]))
|
|
{
|
|
msg("You cannot remove your current IP.");
|
|
return true;
|
|
}
|
|
data.removeIp(args[1]);
|
|
plugin.sql.addPlayer(data);
|
|
msg("Removed IP " + args[1]);
|
|
msg("Current IPs: " + StringUtils.join(data.getIps(), ", "));
|
|
return true;
|
|
}
|
|
case "add":
|
|
{
|
|
if (args.length < 2)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (plugin.pl.canManageMasterBuilders(sender.getName()))
|
|
{
|
|
return noPerms();
|
|
}
|
|
|
|
final Player player = getPlayer(args[1]);
|
|
|
|
PlayerData data = player != null ? plugin.pl.getData(player) : plugin.pl.getData(args[1]);
|
|
|
|
if (data == null)
|
|
{
|
|
msg(PLAYER_NOT_FOUND, ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
if (data.isMasterBuilder() && plugin.pl.isPlayerImpostor(player))
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Re-adding " + data.getName() + " to the Master Builder list", true);
|
|
|
|
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
|
|
{
|
|
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
|
|
}
|
|
if (player != null)
|
|
{
|
|
plugin.pl.verify(player, null);
|
|
plugin.rm.updateDisplay(player);
|
|
player.setOp(true);
|
|
msg(player, YOU_ARE_OP);
|
|
}
|
|
}
|
|
else if (!data.isMasterBuilder())
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Adding " + data.getName() + " to the Master Builder list", true);
|
|
data.setMasterBuilder(true);
|
|
data.setVerification(true);
|
|
plugin.pl.save(data);
|
|
if (player != null)
|
|
{
|
|
plugin.rm.updateDisplay(player);
|
|
}
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
msg("That player is already on the Master Builder list.");
|
|
return true;
|
|
}
|
|
}
|
|
case "remove":
|
|
{
|
|
if (args.length < 2)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (plugin.pl.canManageMasterBuilders(sender.getName()))
|
|
{
|
|
return noPerms();
|
|
}
|
|
|
|
Player player = getPlayer(args[1]);
|
|
PlayerData data = player != null ? plugin.pl.getData(player) : plugin.pl.getData(args[1]);
|
|
|
|
if (data == null || !data.isMasterBuilder())
|
|
{
|
|
msg("Master Builder not found: " + args[1]);
|
|
return true;
|
|
}
|
|
|
|
FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true);
|
|
data.setMasterBuilder(false);
|
|
if (data.getDiscordID() == null)
|
|
{
|
|
data.setVerification(false);
|
|
}
|
|
plugin.pl.save(data);
|
|
if (player != null)
|
|
{
|
|
plugin.rm.updateDisplay(player);
|
|
}
|
|
return true;
|
|
}
|
|
default:
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
{
|
|
if (args.length == 1)
|
|
{
|
|
return Arrays.asList("add", "remove", "list", "clearips", "clearip");
|
|
}
|
|
else if (args.length == 2)
|
|
{
|
|
if (args[0].equalsIgnoreCase("add"))
|
|
{
|
|
return FUtil.getPlayerList();
|
|
}
|
|
else if (args[0].equalsIgnoreCase("remove"))
|
|
{
|
|
return plugin.pl.getMasterBuilderNames();
|
|
}
|
|
else if (args[0].equalsIgnoreCase("clearip"))
|
|
{
|
|
PlayerData data = plugin.pl.getData(sender.getName());
|
|
if (data.isMasterBuilder())
|
|
{
|
|
return data.getIps();
|
|
}
|
|
return Collections.emptyList();
|
|
}
|
|
}
|
|
return Collections.emptyList();
|
|
}
|
|
}
|