mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
clearinventory
This commit is contained in:
parent
dffd9f8c3c
commit
6187c9c068
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
@ -12,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
|
@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
|
public class Command_verifynoadmin extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -75,4 +77,23 @@ public class Command_verifynoadmin extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user