clearinventory

This commit is contained in:
ZeroEpoch1969 2019-08-03 20:31:25 -07:00
parent dffd9f8c3c
commit 6187c9c068
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
2 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,79 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Clear your inventory", usage = "/<command> [player]", aliases = "ci,clear")
public class Command_clearinventory extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
if (senderIsConsole)
{
return false;
}
playerSender.getInventory().clear();
msg("Cleared your inventory");
}
else
{
if (plugin.al.isAdmin(sender))
{
if (args[0].equals("-a"))
{
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
for (Player player : server.getOnlinePlayers())
{
player.getInventory().clear();
}
msg("Cleared everyone's inventory");
}
else
{
Player player = getPlayer(args[0]);
if (player == null)
{
msg(PLAYER_NOT_FOUND);
return true;
}
player.getInventory().clear();
msg("Cleared " + player.getName() + "'s inventory");
player.sendMessage(sender.getName() + " has cleared your inventory");
}
}
else
{
return noPerms();
}
}
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(playerSender))
{
List<String> players = FUtil.getPlayerList();
players.add("-a");
return players;
}
return Collections.emptyList();
}
}

View File

@ -1,6 +1,8 @@
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.rank.Rank;
@ -12,7 +14,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Warns a player.", usage = "/<command> <player>", aliases = "vna")
@CommandParameters(description = "Verify an admin without giving them admin perms.", usage = "/<command> <player>", aliases = "vna")
public class Command_verifynoadmin extends FreedomCommand
{
@ -75,4 +77,23 @@ public class Command_verifynoadmin extends FreedomCommand
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
List<String> adminImposters = new ArrayList<>();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdminImpostor(player))
{
adminImposters.add(player.getName());
}
}
return adminImposters;
}
return Collections.emptyList();
}
}