use of com.sk89q.worldedit.bukkit.selections.CuboidSelection in project PixelsSkyblock by dudullle.
the class WEManager method count_entities.
public static List<? extends Entity> count_entities(World world, Location loc1, Location loc2) {
EditSession es = new EditSessionBuilder(FaweAPI.getWorld("world")).fastmode(true).build();
CuboidSelection cbs = new CuboidSelection(world, loc1, loc2);
Region r = null;
try {
r = cbs.getRegionSelector().getRegion();
} catch (IncompleteRegionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return es.getEntities(r);
}
use of com.sk89q.worldedit.bukkit.selections.CuboidSelection in project PixelsSkyblock by dudullle.
the class WEManager method count.
public static List<Countable<Integer>> count(World world, Location loc1, Location loc2) {
EditSession es = new EditSessionBuilder(FaweAPI.getWorld("world")).fastmode(true).build();
CuboidSelection cbs = new CuboidSelection(world, loc1, loc2);
Region r = null;
try {
r = cbs.getRegionSelector().getRegion();
} catch (IncompleteRegionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return es.getBlockDistribution(r);
}
use of com.sk89q.worldedit.bukkit.selections.CuboidSelection in project AreaShop by NLthijs48.
the class AddsignCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
if (!sender.hasPermission("areashop.addsign")) {
plugin.message(sender, "addsign-noPermission");
return;
}
if (!(sender instanceof Player)) {
plugin.message(sender, "cmd-onlyByPlayer");
return;
}
Player player = (Player) sender;
// Get the sign
Block block = null;
BlockIterator blockIterator = new BlockIterator(player, 100);
while (blockIterator.hasNext() && block == null) {
Block next = blockIterator.next();
if (next.getType() != Material.AIR) {
block = next;
}
}
if (block == null || !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
plugin.message(sender, "addsign-noSign");
return;
}
GeneralRegion region;
if (args.length > 1) {
// Get region by argument
region = plugin.getFileManager().getRegion(args[1]);
if (region == null) {
plugin.message(sender, "cmd-notRegistered", args[1]);
return;
}
} else {
// Get region by sign position
List<GeneralRegion> regions = Utils.getRegionsInSelection(new CuboidSelection(block.getWorld(), block.getLocation(), block.getLocation()));
if (regions.isEmpty()) {
plugin.message(sender, "addsign-noRegions");
return;
} else if (regions.size() > 1) {
plugin.message(sender, "addsign-couldNotDetect", regions.get(0).getName(), regions.get(1).getName());
return;
}
region = regions.get(0);
}
Sign sign = (Sign) block.getState().getData();
String profile = null;
if (args.length > 2) {
profile = args[2];
Set<String> profiles = plugin.getConfig().getConfigurationSection("signProfiles").getKeys(false);
if (!profiles.contains(profile)) {
plugin.message(sender, "addsign-wrongProfile", Utils.createCommaSeparatedList(profiles), region);
return;
}
}
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
if (regionSign != null) {
plugin.message(sender, "addsign-alreadyRegistered", regionSign.getRegion());
return;
}
region.getSignsFeature().addSign(block.getLocation(), block.getType(), sign.getFacing(), profile);
if (profile == null) {
plugin.message(sender, "addsign-success", region);
} else {
plugin.message(sender, "addsign-successProfile", profile, region);
}
region.update();
}
use of com.sk89q.worldedit.bukkit.selections.CuboidSelection in project RedProtect by FabioZumbi12.
the class WEListener method regenRegion.
public static void regenRegion(final br.net.fabiozumbi12.RedProtect.Bukkit.Region r, final World w, final Location p1, final Location p2, final int delay, final CommandSender sender, final boolean remove) {
Bukkit.getScheduler().scheduleSyncDelayedTask(RedProtect.get(), () -> {
if (RPUtil.stopRegen) {
return;
}
CuboidSelection csel = new CuboidSelection(w, p1, p2);
Region wreg = null;
try {
wreg = csel.getRegionSelector().getRegion();
} catch (IncompleteRegionException e1) {
e1.printStackTrace();
}
EditSession esession = new EditSession(LocalWorldAdapter.adapt(wreg.getWorld()), -1);
eSessions.put(r.getID(), esession);
int delayCount = 1 + delay / 10;
if (sender != null) {
if (wreg.getWorld().regenerate(wreg, esession)) {
RPLang.sendMessage(sender, "[" + delayCount + "]" + " &aRegion " + r.getID().split("@")[0] + " regenerated with success!");
} else {
RPLang.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) {
RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(r.getWorld()));
}
if (RPConfig.getInt("purge.regen.stop-server-every") > 0 && delayCount > RPConfig.getInt("purge.regen.stop-server-every")) {
Bukkit.getScheduler().cancelTasks(RedProtect.get());
RedProtect.get().rm.saveAll();
Bukkit.getServer().shutdown();
}
}, delay);
}
use of com.sk89q.worldedit.bukkit.selections.CuboidSelection in project RedProtect by FabioZumbi12.
the class AWEListener method regenRegion.
public static void regenRegion(final br.net.fabiozumbi12.RedProtect.Bukkit.Region r, final World w, final Location p1, final Location p2, final int delay, final CommandSender sender, final boolean remove) {
Bukkit.getScheduler().scheduleSyncDelayedTask(RedProtect.get(), () -> {
if (RPUtil.stopRegen) {
return;
}
CuboidSelection csel = new CuboidSelection(w, p1, p2);
Region wreg;
try {
wreg = csel.getRegionSelector().getRegion();
} catch (IncompleteRegionException e1) {
e1.printStackTrace();
return;
}
AsyncWorldEditBukkit aweMain = (AsyncWorldEditBukkit) Bukkit.getPluginManager().getPlugin("AsyncWorldEdit");
IBlockPlacer bPlacer = aweMain.getBlockPlacer();
final IBlockPlacerListener listener = new IBlockPlacerListener() {
@Override
public void jobAdded(IJobEntry job) {
/*if (job.getPlayer().getName().equals("redprotect")){
String name = job.getName();
//job.addStateChangedListener(stateListener);
RedProtect.get().logger.warning("JobAdded: " + name + " of region " + r.getName() + " - " + job.getStatus() + ": " + job.isTaskDone());
}*/
}
@Override
public void jobRemoved(IJobEntry job) {
if (job.getPlayer().getName().equals("redprotect")) {
String name = job.getName();
// job.addStateChangedListener(stateListener);
if (RPConfig.getBool("purge.regen.awe-logs") && job.isTaskDone()) {
RedProtect.get().logger.sucess("JobDone: " + name + " of region " + r.getName() + " - " + job.getStatus() + ": " + job.getStatusString());
}
}
}
};
bPlacer.addListener(listener);
AsyncEditSessionFactory factory = (AsyncEditSessionFactory) WorldEdit.getInstance().getEditSessionFactory();
EditSession ess = factory.getEditSession(wreg.getWorld(), -1);
eSessions.put(r.getID(), ess);
int delayCount = 1 + delay / 10;
if (sender != null) {
if (AsyncWorld.wrap(wreg.getWorld(), new PlayerManager(aweMain).createFakePlayer("redprotect", UUID.randomUUID())).regenerate(wreg, ess)) {
RPLang.sendMessage(sender, "[" + delayCount + "]" + " &aRegion " + r.getID().split("@")[0] + " regenerated with success!");
} else {
RPLang.sendMessage(sender, "[" + delayCount + "]" + " &cTheres an error when regen the region " + r.getID().split("@")[0] + "!");
}
} else {
if (AsyncWorld.wrap(wreg.getWorld(), new PlayerManager(aweMain).createFakePlayer("redprotect", UUID.randomUUID())).regenerate(wreg, ess)) {
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) {
RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(r.getWorld()));
}
if (RPConfig.getInt("purge.regen.stop-server-every") > 0 && delayCount > RPConfig.getInt("purge.regen.stop-server-every")) {
Bukkit.getScheduler().cancelTasks(RedProtect.get());
RedProtect.get().rm.saveAll();
Bukkit.getServer().shutdown();
}
}, delay);
}
Aggregations