Search in sources :

Example 11 with RegionBuilder

use of br.net.fabiozumbi12.RedProtect.Sponge.region.RegionBuilder 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

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)7 DefineRegionBuilder (br.net.fabiozumbi12.RedProtect.Bukkit.actions.DefineRegionBuilder)5 RegionBuilder (br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionBuilder)5 PlayerRegion (br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion)5 Player (org.bukkit.entity.Player)5 World (org.spongepowered.api.world.World)4 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)3 IOException (java.io.IOException)3 World (org.bukkit.World)3 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)3 Player (org.spongepowered.api.entity.living.player.Player)3 RegionBuilder (br.net.fabiozumbi12.RedProtect.Bukkit.RegionBuilder)2 EncompassRegionBuilder (br.net.fabiozumbi12.RedProtect.Bukkit.actions.EncompassRegionBuilder)2 DefineRegionBuilder (br.net.fabiozumbi12.RedProtect.Sponge.actions.DefineRegionBuilder)2 EncompassRegionBuilder (br.net.fabiozumbi12.RedProtect.Sponge.actions.EncompassRegionBuilder)2 RegionBuilder (br.net.fabiozumbi12.RedProtect.Sponge.region.RegionBuilder)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