TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wiperegions.java

75 lines
2.1 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.command;
2019-01-29 04:57:41 +00:00
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
2019-01-28 01:49:07 +00:00
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Wipe all WorldGuard regions for a specified world.", usage = "/<command> <world>")
public class Command_wiperegions extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.wgb.isEnabled())
{
msg("WorldGuard is not enabled.");
return true;
}
if (args.length != 1)
{
return false;
}
World world = server.getWorld(args[0]);
if (world == null)
{
2019-01-28 01:49:07 +00:00
msg("There is no world named \"" + args[0] + "\"", ChatColor.RED);
return true;
}
2019-01-28 01:49:07 +00:00
int regionsWiped = plugin.wgb.wipeRegions(world);
if (regionsWiped != 0)
{
2019-01-28 01:49:07 +00:00
FUtil.adminAction(sender.getName(), "Wiped all regions in " + world.getName(), true);
msg("Wiped " + regionsWiped + " regions in " + world.getName());
return true;
}
else
{
2019-01-28 01:49:07 +00:00
msg(ChatColor.RED + "No regions were found in \"" + world.getName() + "\"");
return true;
}
}
2019-01-29 04:57:41 +00:00
public List<String> getAllWorldNames()
{
List<String> names = new ArrayList<>();
for (World world : server.getWorlds())
{
names.add(world.getName());
}
return names;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
return getAllWorldNames();
}
return Collections.emptyList();
}
}