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);
}
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));
}
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));
}
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;
}
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);
}
Aggregations