Search in sources :

Example 1 with RegionSelector

use of com.sk89q.worldedit.regions.RegionSelector in project RedProtect by FabioZumbi12.

the class WEHook method regenRegion.

public static void regenRegion(final Region r, final World w, final Location<World> p1, final Location<World> p2, final int delay, final CommandSource sender, final boolean remove) {
    Sponge.getScheduler().createSyncExecutor(RedProtect.get().container).schedule(() -> {
        if (RedProtect.get().getUtil().stopRegen) {
            return;
        }
        RegionSelector regs = new LocalSession().getRegionSelector(SpongeWorldEdit.inst().getWorld(w));
        regs.selectPrimary(new Vector(p1.getX(), p1.getY(), p1.getZ()), null);
        regs.selectSecondary(new Vector(p2.getX(), p2.getY(), p2.getZ()), null);
        com.sk89q.worldedit.regions.Region wreg = null;
        try {
            wreg = regs.getRegion();
        } catch (IncompleteRegionException e1) {
            e1.printStackTrace();
        }
        EditSession esession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(SpongeWorldEdit.inst().getWorld(w), -1);
        eSessions.put(r.getID(), esession);
        int delayCount = 1 + delay / 10;
        if (sender != null) {
            if (wreg.getWorld().regenerate(wreg, esession)) {
                RedProtect.get().getLanguageManager().sendMessage(sender, "[" + delayCount + "]" + " &aRegion " + r.getID().split("@")[0] + " regenerated with success!");
            } else {
                RedProtect.get().getLanguageManager().sendMessage(sender, "[" + delayCount + "]" + " &cTheres an error when regen the region " + r.getID().split("@")[0] + "!");
            }
        } else {
            if (wreg.getWorld().regenerate(wreg, esession)) {
                RedProtect.get().logger.warning("[" + delayCount + "]" + " &aRegion " + r.getID().split("@")[0] + " regenerated with success!");
            } else {
                RedProtect.get().logger.warning("[" + delayCount + "]" + " &cTheres an error when regen the region " + r.getID().split("@")[0] + "!");
            }
        }
        if (remove) {
            r.notifyRemove();
            RedProtect.get().getRegionManager().remove(r, r.getWorld());
        }
        if (delayCount % 50 == 0) {
            RedProtect.get().getRegionManager().saveAll(true);
        }
        if (RedProtect.get().getConfigManager().configRoot().purge.regen.stop_server_every > 0 && delayCount > RedProtect.get().getConfigManager().configRoot().purge.regen.stop_server_every) {
            Sponge.getScheduler().getScheduledTasks(RedProtect.get().container).forEach(Task::cancel);
            RedProtect.get().getRegionManager().saveAll(false);
            Sponge.getServer().shutdown();
        }
    }, delay, TimeUnit.MILLISECONDS);
}
Also used : RegionSelector(com.sk89q.worldedit.regions.RegionSelector) Task(org.spongepowered.api.scheduler.Task)

Example 2 with RegionSelector

use of com.sk89q.worldedit.regions.RegionSelector in project RedProtect by FabioZumbi12.

the class WEHook method setSelection.

private static void setSelection(SpongeWorld ws, Player p, Location pos1, Location pos2) {
    RegionSelector regs = SpongeWorldEdit.inst().getSession(p).getRegionSelector(ws);
    regs.selectPrimary(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), null);
    regs.selectSecondary(new Vector(pos2.getX(), pos2.getY(), pos2.getZ()), null);
    SpongeWorldEdit.inst().getSession(p).setRegionSelector(ws, regs);
    SpongeWorldEdit.inst().getSession(p).dispatchCUISelection(SpongeWorldEdit.inst().wrapPlayer(p));
}
Also used : RegionSelector(com.sk89q.worldedit.regions.RegionSelector)

Example 3 with RegionSelector

use of com.sk89q.worldedit.regions.RegionSelector in project RedProtect by FabioZumbi12.

the class WEHook method setSelection.

private static void setSelection(BukkitWorld ws, Player p, Location pos1, Location pos2) {
    WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
    RegionSelector regs = worldEdit.getSession(p).getRegionSelector(ws);
    regs.selectPrimary(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), null);
    regs.selectSecondary(BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()), null);
    worldEdit.getSession(p).setRegionSelector(ws, regs);
    worldEdit.getSession(p).dispatchCUISelection(worldEdit.wrapPlayer(p));
}
Also used : RegionSelector(com.sk89q.worldedit.regions.RegionSelector) WorldEditPlugin(com.sk89q.worldedit.bukkit.WorldEditPlugin)

Example 4 with RegionSelector

use of com.sk89q.worldedit.regions.RegionSelector in project FastAsyncWorldEdit by IntellectualSites.

the class DistanceWand method actPrimary.

@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
    Location target = getTarget(player);
    if (target == null) {
        return true;
    }
    RegionSelector selector = session.getRegionSelector(player.getWorld());
    BlockVector3 blockPoint = target.toVector().toBlockPoint();
    if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
        selector.explainSecondarySelection(player, session, blockPoint);
    }
    return true;
}
Also used : RegionSelector(com.sk89q.worldedit.regions.RegionSelector) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Location(com.sk89q.worldedit.util.Location)

Example 5 with RegionSelector

use of com.sk89q.worldedit.regions.RegionSelector in project FastAsyncWorldEdit by IntellectualSites.

the class AbstractPlayerActor method setSelection.

@Override
public void setSelection(Region region) {
    RegionSelector selector;
    if (region instanceof ConvexPolyhedralRegion) {
        selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
    } else if (region instanceof CylinderRegion) {
        selector = new CylinderRegionSelector((CylinderRegion) region);
    } else if (region instanceof Polygonal2DRegion) {
        selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
    } else {
        selector = new CuboidRegionSelector(null, region.getMinimumPoint(), region.getMaximumPoint());
    }
    selector.setWorld(region.getWorld());
    getSession().setRegionSelector(getWorld(), selector);
}
Also used : CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) RegionSelector(com.sk89q.worldedit.regions.RegionSelector) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) Polygonal2DRegion(com.sk89q.worldedit.regions.Polygonal2DRegion) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) ConvexPolyhedralRegion(com.sk89q.worldedit.regions.ConvexPolyhedralRegion) CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector)

Aggregations

RegionSelector (com.sk89q.worldedit.regions.RegionSelector)12 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)6 CuboidRegionSelector (com.sk89q.worldedit.regions.selector.CuboidRegionSelector)6 Location (com.sk89q.worldedit.util.Location)4 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)3 LocalSession (com.sk89q.worldedit.LocalSession)3 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)3 Logging (com.sk89q.worldedit.command.util.Logging)3 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)3 Region (com.sk89q.worldedit.regions.Region)3 Polygonal2DRegionSelector (com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector)3 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)3 Command (org.enginehub.piston.annotation.Command)3 DiskOptimizedClipboard (com.fastasyncworldedit.core.extent.clipboard.DiskOptimizedClipboard)2 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)2 ReadOnlyClipboard (com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard)2 ConvexPolyhedralRegionSelector (com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector)2 CylinderRegionSelector (com.sk89q.worldedit.regions.selector.CylinderRegionSelector)2 Component (com.sk89q.worldedit.util.formatting.text.Component)2 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)2