use of com.sk89q.worldedit.entity.Entity in project PixelsSkyblock by dudullle.
the class OnislandObjective method check.
@Override
public boolean check(Player p, Island i) {
if (!type) {
List<Countable<Integer>> blocks = WEManager.count(Bukkit.getWorld("world"), i.getEdges().get(0), i.getEdges().get(1));
for (Countable<Integer> b : blocks) {
if (b.getID() == mat_ID && b.getAmount() >= quantity) {
return true;
} else if (b.getID() == mat_ID) {
calculated_nb = b.getAmount();
}
}
return false;
} else {
try {
List<Entity> es = (List<Entity>) WEManager.count_entities(Bukkit.getWorld("world"), i.getEdges().get(0), i.getEdges().get(1));
int qte = 0;
for (Entity e : es) {
try {
if (e.getState().getTypeId().toString().equalsIgnoreCase(it_name)) {
qte += 1;
}
} catch (Exception ex) {
}
}
calculated_nb = qte;
if (qte >= quantity) {
return true;
}
} catch (Exception ex) {
}
}
return false;
}
use of com.sk89q.worldedit.entity.Entity in project FastAsyncWorldEdit by IntellectualSites.
the class TracingExtent method createEntity.
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
BlockVector3 blockVector3 = location.toVector().toBlockPoint();
touchedLocations.add(blockVector3);
Entity result = super.createEntity(location, entity);
if (result == null) {
failedActions.put(blockVector3, Action.CREATE_ENTITY);
}
return result;
}
use of com.sk89q.worldedit.entity.Entity in project FastAsyncWorldEdit by IntellectualSites.
the class ConsumeBindings method baseBlock.
@Binding
public BaseBlock baseBlock(Actor actor, String argument) {
ParserContext parserContext = new ParserContext();
parserContext.setActor(actor);
if (actor instanceof Entity) {
Extent extent = ((Entity) actor).getExtent();
if (extent instanceof World) {
parserContext.setWorld((World) extent);
}
}
parserContext.setSession(getWorldEdit().getSessionManager().get(actor));
try {
return getWorldEdit().getBlockFactory().parseFromInput(argument, parserContext);
} catch (NoMatchException e) {
throw new InputParseException(TextComponent.of(e.getMessage()));
}
}
use of com.sk89q.worldedit.entity.Entity in project bteConoSurCore by BTEConoSur.
the class Polywall method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equals("/polywalls")) {
if (sender instanceof Player) {
Player p = (Player) sender;
//
// GET REGION
Region region = null;
try {
region = getSelection(p);
} catch (IncompleteRegionException e) {
p.sendMessage(wePrefix + "Selecciona un área primero.");
return true;
}
if (args.length > 0) {
// PARSE PATTERN
com.sk89q.worldedit.entity.Player actor = new BukkitPlayer((WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"), ((WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit")).getServerInterface(), p);
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(actor);
Mask mask = localSession.getMask();
ParserContext parserContext = new ParserContext();
parserContext.setActor(actor);
Extent extent = ((Entity) actor).getExtent();
if (extent instanceof World) {
parserContext.setWorld((World) extent);
}
parserContext.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
Pattern pattern;
try {
pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(args[0], parserContext);
} catch (InputParseException e) {
p.sendMessage(wePrefix + "Patrón inválido.");
return true;
}
// GET POINTS
List<BlockVector2D> points = new ArrayList<>();
int maxY;
int minY;
if (region instanceof CuboidRegion) {
CuboidRegion cuboidRegion = (CuboidRegion) region;
Vector first = cuboidRegion.getPos1();
Vector second = cuboidRegion.getPos2();
maxY = cuboidRegion.getMaximumY();
minY = cuboidRegion.getMinimumY();
points.add(new BlockVector2D(first.getX(), first.getZ()));
points.add(new BlockVector2D(second.getX(), first.getZ()));
points.add(new BlockVector2D(second.getX(), second.getZ()));
points.add(new BlockVector2D(first.getX(), second.getZ()));
} else if (region instanceof Polygonal2DRegion) {
maxY = ((Polygonal2DRegion) region).getMaximumY();
minY = ((Polygonal2DRegion) region).getMinimumY();
points = ((Polygonal2DRegion) region).getPoints();
} else {
p.sendMessage(wePrefix + "Debes seleccionar una region cúbica o poligonal.");
return true;
}
if (points.size() < 3) {
p.sendMessage(wePrefix + "Selecciona un área primero.");
return true;
}
List<BlockVector2D> pointsFinal = new ArrayList<>(points);
pointsFinal.add(points.get(0));
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession((World) new BukkitWorld(mainWorld), WorldEdit.getInstance().getSessionManager().get(actor).getBlockChangeLimit());
for (int i = minY; i <= maxY; i++) {
for (int j = 0; j < pointsFinal.size() - 1; j++) {
BlockVector2D v1 = pointsFinal.get(j);
BlockVector2D v2 = pointsFinal.get(j + 1);
setBlocksInLine(p, actor, editSession, pattern, mask, v1.toVector(i), v2.toVector(i));
}
}
p.sendMessage(wePrefix + "Paredes de la selección creadas.");
} else {
p.sendMessage(wePrefix + "Introduce un patrón de bloques.");
}
}
}
return true;
}
Aggregations