Search in sources :

Example 31 with PlayerRegion

use of br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion in project RedProtect by FabioZumbi12.

the class DefineCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        HandleHelpPage(sender, 1);
        return true;
    }
    Player player = (Player) sender;
    if (args.length == 0) {
        PlayerRegion serverName = new PlayerRegion(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader, RedProtect.get().getConfigManager().configRoot().region_settings.default_leader);
        String name = RedProtect.get().getUtil().nameGen(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader, player.getWorld().getName());
        RedProtect.get().getLanguageManager().sendMessage(player, "regionbuilder.creating");
        // Run claim async
        Bukkit.getScheduler().runTaskAsynchronously(RedProtect.get(), () -> {
            RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new HashSet<>(), true);
            if (rb2.ready()) {
                Region r2 = rb2.build();
                RedProtect.get().getLanguageManager().sendMessage(player, RedProtect.get().getLanguageManager().get("cmdmanager.region.created") + " " + r2.getName() + ".");
                RedProtect.get().getRegionManager().add(r2, player.getWorld().getName());
                RedProtect.get().firstLocationSelections.remove(player);
                RedProtect.get().secondLocationSelections.remove(player);
                RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
            }
        });
        return true;
    }
    if (args.length == 1) {
        PlayerRegion serverName = new PlayerRegion(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader, RedProtect.get().getConfigManager().configRoot().region_settings.default_leader);
        RedProtect.get().getLanguageManager().sendMessage(player, "regionbuilder.creating");
        // Run claim async
        Bukkit.getScheduler().runTaskAsynchronously(RedProtect.get(), () -> {
            RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), args[0], serverName, new HashSet<>(), true);
            if (rb2.ready()) {
                Region r2 = rb2.build();
                RedProtect.get().getLanguageManager().sendMessage(player, RedProtect.get().getLanguageManager().get("cmdmanager.region.created") + " " + r2.getName() + ".");
                RedProtect.get().getRegionManager().add(r2, player.getWorld().getName());
                RedProtect.get().firstLocationSelections.remove(player);
                RedProtect.get().secondLocationSelections.remove(player);
                RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
            }
        });
        return true;
    }
    RedProtect.get().getLanguageManager().sendCommandHelp(sender, "define", true);
    return true;
}
Also used : PlayerRegion(br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion) Player(org.bukkit.entity.Player) PlayerRegion(br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) DefineRegionBuilder(br.net.fabiozumbi12.RedProtect.Bukkit.actions.DefineRegionBuilder) DefineRegionBuilder(br.net.fabiozumbi12.RedProtect.Bukkit.actions.DefineRegionBuilder) RegionBuilder(br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionBuilder) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Aggregations

PlayerRegion (br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion)31 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)11 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)6 World (org.spongepowered.api.world.World)6 DefineRegionBuilder (br.net.fabiozumbi12.RedProtect.Bukkit.actions.DefineRegionBuilder)4 RegionBuilder (br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionBuilder)4 File (java.io.File)4 IOException (java.io.IOException)4 Player (org.bukkit.entity.Player)4 CoreUtil (br.net.fabiozumbi12.RedProtect.Core.helpers.CoreUtil)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 Location (org.bukkit.Location)3 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)3 RedProtect (br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect)2 LogLevel (br.net.fabiozumbi12.RedProtect.Core.helpers.LogLevel)2 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)2 ClipboardFormat (com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat)2 ClipboardReader (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader)2 Operation (com.sk89q.worldedit.function.operation.Operation)2