use of com.sk89q.worldedit.extent.NullExtent in project PlotSquared by IntellectualSites.
the class WESubscriber method onEditSession.
@Subscribe(priority = Priority.VERY_EARLY)
public void onEditSession(EditSessionEvent event) {
if (!Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
WorldEdit.getInstance().getEventBus().unregister(this);
return;
}
if (event.getStage() != EditSession.Stage.BEFORE_HISTORY) {
return;
}
World worldObj = event.getWorld();
if (worldObj == null) {
return;
}
String world = worldObj.getName();
Actor actor = event.getActor();
if (actor != null && actor.isPlayer()) {
String name = actor.getName();
final PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(name);
Set<CuboidRegion> mask;
if (plotPlayer == null) {
Player player = (Player) actor;
Location location = player.getLocation();
com.plotsquared.core.location.Location pLoc = com.plotsquared.core.location.Location.at(player.getWorld().getName(), location.toVector().toBlockPoint());
Plot plot = pLoc.getPlot();
if (plot == null) {
event.setExtent(new NullExtent());
return;
}
mask = plot.getRegions();
} else if (plotPlayer.getAttribute("worldedit")) {
return;
} else {
mask = WEManager.getMask(plotPlayer);
if (mask.isEmpty()) {
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
plotPlayer.sendMessage(TranslatableCaption.of("worldedit.worldedit_bypass"), Template.of("command", "/plot toggle worldedit"));
}
if (this.plotAreaManager.hasPlotArea(world)) {
event.setExtent(new NullExtent());
}
return;
}
}
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
if (this.plotAreaManager.hasPlotArea(world)) {
event.setExtent(new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(), event.getExtent(), this.worldUtil));
}
} else if (this.plotAreaManager.hasPlotArea(world)) {
event.setExtent(new WEExtent(mask, event.getExtent()));
}
}
}
use of com.sk89q.worldedit.extent.NullExtent in project FastAsyncWorldEdit by IntellectualSites.
the class LocalConfiguration method checkDisallowedBlocks.
public boolean checkDisallowedBlocks(BlockStateHolder holder) {
if (disallowedBlocks.isEmpty()) {
return false;
}
if (disallowedBlocksMask == null) {
BlockMaskBuilder builder = new BlockMaskBuilder();
for (String blockRegex : disallowedBlocks) {
try {
builder.addRegex(blockRegex);
} catch (InputParseException e) {
e.printStackTrace();
}
}
disallowedBlocksMask = builder.build(new NullExtent());
}
return disallowedBlocksMask.test(holder.toImmutableState());
}
use of com.sk89q.worldedit.extent.NullExtent in project PlotSquared by IntellectualSites.
the class ProcessedWEExtent method setBlock.
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
final boolean isTile = this.worldUtil.getTileEntityTypes().contains(block.getBlockType());
if (isTile) {
final Integer[] tileEntityCount = this.tileEntityCount.computeIfAbsent(getChunkKey(location), key -> new Integer[] { this.worldUtil.getTileEntityCount(world, BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4)) });
if (tileEntityCount[0] >= Settings.Chunk_Processor.MAX_TILES) {
return false;
} else {
tileEntityCount[0]++;
}
}
if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) {
if (this.count++ > this.max) {
if (this.parent != null) {
try {
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
field.setAccessible(true);
field.set(this.parent, new NullExtent());
} catch (Exception e) {
e.printStackTrace();
}
this.parent = null;
}
return false;
}
return super.setBlock(location, block);
}
return !isTile;
}
Aggregations