Search in sources :

Example 1 with PropertyRemap

use of com.fastasyncworldedit.core.limit.PropertyRemap in project FastAsyncWorldEdit by IntellectualSites.

the class Settings method getLimit.

public FaweLimit getLimit(Actor actor) {
    FaweLimit limit;
    if (actor.hasPermission("fawe.limit.*") || actor.hasPermission("fawe.bypass")) {
        limit = FaweLimit.MAX.copy();
    } else {
        limit = new FaweLimit();
    }
    ArrayList<String> keys = new ArrayList<>(LIMITS.getSections());
    if (keys.remove("default")) {
        keys.add("default");
    }
    boolean limitFound = false;
    for (String key : keys) {
        if (actor.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) {
            limitFound = true;
            LIMITS newLimit = LIMITS.get(key);
            limit.MAX_ACTIONS = Math.max(limit.MAX_ACTIONS, newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE);
            limit.MAX_CHANGES = Math.max(limit.MAX_CHANGES, newLimit.MAX_CHANGES != -1 ? newLimit.MAX_CHANGES : Long.MAX_VALUE);
            limit.MAX_BLOCKSTATES = Math.max(limit.MAX_BLOCKSTATES, newLimit.MAX_BLOCKSTATES != -1 ? newLimit.MAX_BLOCKSTATES : Integer.MAX_VALUE);
            limit.MAX_CHECKS = Math.max(limit.MAX_CHECKS, newLimit.MAX_CHECKS != -1 ? newLimit.MAX_CHECKS : Long.MAX_VALUE);
            limit.MAX_ENTITIES = Math.max(limit.MAX_ENTITIES, newLimit.MAX_ENTITIES != -1 ? newLimit.MAX_ENTITIES : Integer.MAX_VALUE);
            limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE);
            limit.MAX_ITERATIONS = Math.max(limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE);
            limit.MAX_HISTORY = Math.max(limit.MAX_HISTORY, newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE);
            limit.MAX_EXPRESSION_MS = Math.max(limit.MAX_EXPRESSION_MS, newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE);
            limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE);
            limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
            limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;
            limit.CONFIRM_LARGE &= newLimit.CONFIRM_LARGE;
            limit.RESTRICT_HISTORY_TO_REGIONS &= newLimit.RESTRICT_HISTORY_TO_REGIONS;
            if (limit.STRIP_NBT == null) {
                limit.STRIP_NBT = newLimit.STRIP_NBT.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.STRIP_NBT);
            } else if (limit.STRIP_NBT.isEmpty() || newLimit.STRIP_NBT.isEmpty()) {
                limit.STRIP_NBT = Collections.emptySet();
            } else {
                limit.STRIP_NBT = new HashSet<>(limit.STRIP_NBT);
                limit.STRIP_NBT.retainAll(newLimit.STRIP_NBT);
                if (limit.STRIP_NBT.isEmpty()) {
                    limit.STRIP_NBT = Collections.emptySet();
                }
            }
            limit.UNIVERSAL_DISALLOWED_BLOCKS &= newLimit.UNIVERSAL_DISALLOWED_BLOCKS;
            if (limit.DISALLOWED_BLOCKS == null) {
                limit.DISALLOWED_BLOCKS = newLimit.DISALLOWED_BLOCKS.isEmpty() ? Collections.emptySet() : new HashSet<>(newLimit.DISALLOWED_BLOCKS);
            } else if (limit.DISALLOWED_BLOCKS.isEmpty() || newLimit.DISALLOWED_BLOCKS.isEmpty()) {
                limit.DISALLOWED_BLOCKS = Collections.emptySet();
            } else {
                limit.DISALLOWED_BLOCKS = new HashSet<>(limit.DISALLOWED_BLOCKS);
                limit.DISALLOWED_BLOCKS.retainAll(newLimit.DISALLOWED_BLOCKS.stream().map(s -> s.contains(":") ? s.toLowerCase(Locale.ROOT) : ("minecraft:" + s).toLowerCase(Locale.ROOT)).collect(Collectors.toSet()));
                if (limit.DISALLOWED_BLOCKS.isEmpty()) {
                    limit.DISALLOWED_BLOCKS = Collections.emptySet();
                }
            }
            if (limit.REMAP_PROPERTIES == null) {
                limit.REMAP_PROPERTIES = newLimit.REMAP_PROPERTIES.isEmpty() ? Collections.emptySet() : newLimit.REMAP_PROPERTIES.stream().flatMap(s -> {
                    String propertyStr = s.substring(0, s.indexOf('['));
                    List<Property<?>> properties = BlockTypesCache.getAllProperties().get(propertyStr.toLowerCase(Locale.ROOT));
                    if (properties == null || properties.isEmpty()) {
                        return Stream.empty();
                    }
                    String[] mappings = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(",");
                    Set<PropertyRemap<?>> remaps = new HashSet<>();
                    for (Property<?> property : properties) {
                        for (String mapping : mappings) {
                            try {
                                String[] fromTo = mapping.split(":");
                                remaps.add(property.getRemap(property.getValueFor(fromTo[0]), property.getValueFor(fromTo[1])));
                            } catch (IllegalArgumentException ignored) {
                                // This property is unlikely to be the one being targeted.
                                break;
                            }
                        }
                    }
                    return remaps.stream();
                }).collect(Collectors.toSet());
            } else if (limit.REMAP_PROPERTIES.isEmpty() || newLimit.REMAP_PROPERTIES.isEmpty()) {
                limit.REMAP_PROPERTIES = Collections.emptySet();
            } else {
                limit.REMAP_PROPERTIES = new HashSet<>(limit.REMAP_PROPERTIES);
                limit.REMAP_PROPERTIES.retainAll(newLimit.REMAP_PROPERTIES.stream().flatMap(s -> {
                    String propertyStr = s.substring(0, s.indexOf('['));
                    List<Property<?>> properties = BlockTypesCache.getAllProperties().get(propertyStr.toLowerCase(Locale.ROOT));
                    if (properties == null || properties.isEmpty()) {
                        return Stream.empty();
                    }
                    String[] mappings = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(",");
                    Set<PropertyRemap<?>> remaps = new HashSet<>();
                    for (Property<?> property : properties) {
                        for (String mapping : mappings) {
                            try {
                                String[] fromTo = mapping.split(":");
                                remaps.add(property.getRemap(property.getValueFor(fromTo[0]), property.getValueFor(fromTo[1])));
                            } catch (IllegalArgumentException ignored) {
                                // This property is unlikely to be the one being targeted.
                                break;
                            }
                        }
                    }
                    return remaps.stream();
                }).collect(Collectors.toSet()));
                if (limit.REMAP_PROPERTIES.isEmpty()) {
                    limit.REMAP_PROPERTIES = Collections.emptySet();
                }
            }
        }
    }
    return limit;
}
Also used : Property(com.sk89q.worldedit.registry.state.Property) Arrays(java.util.Arrays) Set(java.util.Set) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) BlockTypesCache(com.sk89q.worldedit.world.block.BlockTypesCache) Collectors(java.util.stream.Collectors) PropertyRemap(com.fastasyncworldedit.core.limit.PropertyRemap) File(java.io.File) ArrayList(java.util.ArrayList) Actor(com.sk89q.worldedit.extension.platform.Actor) HashSet(java.util.HashSet) List(java.util.List) Stream(java.util.stream.Stream) Locale(java.util.Locale) Collections(java.util.Collections) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) ArrayList(java.util.ArrayList) List(java.util.List) Property(com.sk89q.worldedit.registry.state.Property) HashSet(java.util.HashSet)

Example 2 with PropertyRemap

use of com.fastasyncworldedit.core.limit.PropertyRemap in project FastAsyncWorldEdit by IntellectualSites.

the class DefaultBlockParser method parseProperties.

// FAWE start - make public
public static Map<Property<?>, Object> parseProperties(// FAWE end
BlockType type, String[] stateProperties, ParserContext context, // FAWE start - if null should be returned instead of throwing an error
boolean nullNotError) throws // FAWE end
NoMatchException {
    Map<Property<?>, Object> blockStates = new HashMap<>();
    // FAWE start - disallowed states
    if (context != null && context.getActor() != null && !context.getActor().getLimit().isUnlimited()) {
        for (String input : context.getActor().getLimit().DISALLOWED_BLOCKS) {
            if (input.indexOf('[') == -1 && input.indexOf(']') == -1) {
                continue;
            }
            if (!type.getId().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) {
                continue;
            }
            String[] properties = input.substring(input.indexOf('[') + 1, input.indexOf(']')).split(",");
            Set<String> blocked = Arrays.stream(properties).filter(s -> {
                for (String in : stateProperties) {
                    if (in.equalsIgnoreCase(s)) {
                        return true;
                    }
                }
                return false;
            }).collect(Collectors.toSet());
            if (!blocked.isEmpty()) {
                throw new DisallowedUsageException(Caption.of("fawe.error.limit.disallowed-block", TextComponent.of(input)));
            }
        }
    }
    if (stateProperties.length > 0) {
        // Parse the block data (optional)
        for (String parseableData : stateProperties) {
            try {
                String[] parts = parseableData.split("=");
                if (parts.length != 2) {
                    // FAWE start - if null should be returned instead of throwing an error
                    if (nullNotError) {
                        return null;
                    }
                    // FAWE end
                    throw new InputParseException(Caption.of("worldedit.error.parser.bad-state-format", TextComponent.of(parseableData)));
                }
                @SuppressWarnings("unchecked") Property<Object> propertyKey = (Property<Object>) type.getPropertyMap().get(parts[0]);
                if (propertyKey == null) {
                    // FAWE start - nullable context
                    if (context != null && context.getActor() != null) {
                        // FAWE start - if null should be returned instead of throwing an error
                        if (nullNotError) {
                            return null;
                        }
                        // FAWE end
                        throw new NoMatchException(Caption.of("worldedit.error.parser.unknown-property", TextComponent.of(parts[0]), TextComponent.of(type.getId())));
                    } else {
                        WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId());
                    }
                    return Maps.newHashMap();
                }
                if (blockStates.containsKey(propertyKey)) {
                    // FAWE start - if null should be returned instead of throwing an error
                    if (nullNotError) {
                        return null;
                    }
                    // FAWE end
                    throw new InputParseException(Caption.of("worldedit.error.parser.duplicate-property", TextComponent.of(parts[0])));
                }
                Object value;
                try {
                    value = propertyKey.getValueFor(parts[1]);
                } catch (IllegalArgumentException e) {
                    // FAWE start - if null should be returned instead of throwing an error
                    if (nullNotError) {
                        return null;
                    }
                    // FAWE end
                    throw new NoMatchException(Caption.of("worldedit.error.parser.unknown-value", TextComponent.of(parts[1]), TextComponent.of(propertyKey.getName())));
                }
                // FAWE start - blocked states
                if (context != null && context.getActor() != null && !context.getActor().getLimit().isUnlimited()) {
                    if (context.getActor().getLimit().REMAP_PROPERTIES != null && !context.getActor().getLimit().REMAP_PROPERTIES.isEmpty()) {
                        for (PropertyRemap remap : context.getActor().getLimit().REMAP_PROPERTIES) {
                            Object newValue = remap.apply(type, value);
                            if (newValue != value) {
                                value = newValue;
                                break;
                            }
                        }
                    }
                }
                // FAWE end
                blockStates.put(propertyKey, value);
            } catch (NoMatchException | DisallowedUsageException e) {
                // Pass-through
                throw e;
            } catch (Exception e) {
                // FAWE start - if null should be returned instead of throwing an error
                if (nullNotError) {
                    return null;
                }
                // FAWE end
                throw new InputParseException(Caption.of("worldedit.error.parser.bad-state-format", TextComponent.of(parseableData)));
            }
        }
    }
    return blockStates;
}
Also used : Property(com.sk89q.worldedit.registry.state.Property) Arrays(java.util.Arrays) SignBlock(com.sk89q.worldedit.blocks.SignBlock) BlockTypes(com.sk89q.worldedit.world.block.BlockTypes) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Player(com.sk89q.worldedit.entity.Player) World(com.sk89q.worldedit.world.World) Caption(com.fastasyncworldedit.core.configuration.Caption) SkullBlock(com.sk89q.worldedit.blocks.SkullBlock) EntityType(com.sk89q.worldedit.world.entity.EntityType) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) JSON2NBT(com.fastasyncworldedit.core.jnbt.JSON2NBT) Locale(java.util.Locale) DisallowedUsageException(com.sk89q.worldedit.extension.input.DisallowedUsageException) Map(java.util.Map) NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException) BlockStateHolder(com.sk89q.worldedit.world.block.BlockStateHolder) BlockType(com.sk89q.worldedit.world.block.BlockType) BaseItem(com.sk89q.worldedit.blocks.BaseItem) Set(java.util.Set) Collectors(java.util.stream.Collectors) BlockBag(com.sk89q.worldedit.extent.inventory.BlockBag) MathMan(com.fastasyncworldedit.core.util.MathMan) NotABlockException(com.sk89q.worldedit.NotABlockException) Stream(java.util.stream.Stream) InputParser(com.sk89q.worldedit.internal.registry.InputParser) LegacyMapper(com.sk89q.worldedit.world.registry.LegacyMapper) CompoundTag(com.sk89q.jnbt.CompoundTag) BaseBlock(com.sk89q.worldedit.world.block.BaseBlock) SuggestionHelper(com.sk89q.worldedit.command.util.SuggestionHelper) BlockCategories(com.sk89q.worldedit.world.block.BlockCategories) HashMap(java.util.HashMap) BlanketBaseBlock(com.fastasyncworldedit.core.world.block.BlanketBaseBlock) PropertyRemap(com.fastasyncworldedit.core.limit.PropertyRemap) ParserContext(com.sk89q.worldedit.extension.input.ParserContext) StringMan(com.fastasyncworldedit.core.util.StringMan) FuzzyBlockState(com.sk89q.worldedit.world.block.FuzzyBlockState) WorldEditException(com.sk89q.worldedit.WorldEditException) MobSpawnerBlock(com.sk89q.worldedit.blocks.MobSpawnerBlock) WorldEdit(com.sk89q.worldedit.WorldEdit) HandSide(com.sk89q.worldedit.util.HandSide) IncompleteRegionException(com.sk89q.worldedit.IncompleteRegionException) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) NBTException(com.fastasyncworldedit.core.jnbt.NBTException) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) Maps(com.google.common.collect.Maps) Actor(com.sk89q.worldedit.extension.platform.Actor) EntityTypes(com.sk89q.worldedit.world.entity.EntityTypes) SlottableBlockBag(com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag) Capability(com.sk89q.worldedit.extension.platform.Capability) BlockState(com.sk89q.worldedit.world.block.BlockState) HashMap(java.util.HashMap) PropertyRemap(com.fastasyncworldedit.core.limit.PropertyRemap) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) DisallowedUsageException(com.sk89q.worldedit.extension.input.DisallowedUsageException) NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException) NotABlockException(com.sk89q.worldedit.NotABlockException) WorldEditException(com.sk89q.worldedit.WorldEditException) IncompleteRegionException(com.sk89q.worldedit.IncompleteRegionException) NBTException(com.fastasyncworldedit.core.jnbt.NBTException) DisallowedUsageException(com.sk89q.worldedit.extension.input.DisallowedUsageException) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException) Property(com.sk89q.worldedit.registry.state.Property)

Example 3 with PropertyRemap

use of com.fastasyncworldedit.core.limit.PropertyRemap in project FastAsyncWorldEdit by IntellectualSites.

the class EditSessionBuilder method compile.

/**
 * Compile the builder to the settings given. Prepares history, limits, lighting, etc.
 */
public EditSessionBuilder compile() {
    if (compiled) {
        return this;
    }
    compiled = true;
    wrapped = false;
    if (event == null) {
        event = new EditSessionEvent(world, actor, -1, null);
    }
    if (actor == null && event.getActor() != null) {
        actor = event.getActor();
    }
    if (limit == null) {
        if (actor == null) {
            limit = FaweLimit.MAX;
        } else {
            limit = actor.getLimit();
        }
    }
    if (fastMode == null) {
        if (actor == null) {
            fastMode = !Settings.settings().HISTORY.ENABLE_FOR_CONSOLE;
        } else {
            fastMode = actor.getSession().hasFastMode();
        }
    }
    if (checkMemory == null) {
        checkMemory = actor != null && !this.fastMode;
    }
    if (checkMemory) {
        if (MemUtil.isMemoryLimitedSlow()) {
            if (Permission.hasPermission(actor, "worldedit.fast")) {
                actor.print(Caption.of("fawe.info.worldedit.oom.admin"));
            }
            throw FaweCache.LOW_MEMORY;
        }
    }
    // this.originalLimit = limit;
    this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
    this.limit = limit.copy();
    if (extent == null) {
        IQueueExtent<IQueueChunk> queue = null;
        World unwrapped = WorldWrapper.unwrap(world);
        boolean placeChunks = (this.fastMode || this.limit.FAST_PLACEMENT) && (wnaMode == null || !wnaMode);
        if (placeChunks) {
            wnaMode = false;
            if (unwrapped instanceof IQueueExtent) {
                extent = queue = (IQueueExtent) unwrapped;
            } else if (Settings.settings().QUEUE.PARALLEL_THREADS > 1 && !Fawe.isMainThread()) {
                ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.instance().getQueueHandler(), world, fastMode);
                queue = parallel.getExtent();
                extent = parallel;
            } else {
                extent = queue = Fawe.instance().getQueueHandler().getQueue(world);
            }
        } else {
            wnaMode = true;
            extent = world;
        }
        if (combineStages == null) {
            combineStages = // If it's enabled in the settings
            Settings.settings().HISTORY.COMBINE_STAGES && // If fast placement is disabled, it's slower to perform a copy on each chunk
            this.limit.FAST_PLACEMENT && // If the edit uses items from the inventory we can't use a delayed task
            this.blockBag == null;
        }
        extent = this.bypassAll = wrapExtent(extent, eventBus, event, EditSession.Stage.BEFORE_CHANGE);
        this.bypassHistory = this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER);
        if (!this.fastMode || changeSet != null) {
            if (changeSet == null) {
                if (Settings.settings().HISTORY.USE_DISK) {
                    UUID uuid = actor == null ? Identifiable.CONSOLE : actor.getUniqueId();
                    if (Settings.settings().HISTORY.USE_DATABASE) {
                        changeSet = new RollbackOptimizedHistory(world, uuid);
                    } else {
                        changeSet = new DiskStorageHistory(world, uuid);
                    }
                // } else if (combineStages && Settings.settings().HISTORY.COMPRESSION_LEVEL == 0) {
                // changeSet = new CPUOptimizedChangeSet(world);
                } else {
                    if (combineStages && Settings.settings().HISTORY.COMPRESSION_LEVEL == 0) {
                    // TODO add CPUOptimizedChangeSet
                    }
                    changeSet = new MemoryOptimizedHistory(world);
                }
            }
            if (this.limit.SPEED_REDUCTION > 0) {
                this.extent = this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
            }
            if (command != null && changeSet instanceof RollbackOptimizedHistory) {
                ((RollbackOptimizedHistory) changeSet).setCommand(this.command);
            }
            if (!(changeSet instanceof NullChangeSet)) {
                if (this.blockBag != null) {
                    // TODO implement block bag as IBatchProcessor
                    changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
                }
                if (combineStages) {
                    changeTask = changeSet;
                    this.extent = extent.enableHistory(changeSet);
                } else {
                    this.extent = new HistoryExtent(extent, changeSet);
                // if (this.blockBag != null) {
                // this.extent = new BlockBagExtent(this.extent, blockBag, limit.INVENTORY_MODE == 1);
                // }
                }
            }
        }
        if (allowedRegions == null && Settings.settings().REGION_RESTRICTIONS) {
            if (actor != null && !actor.hasPermission("fawe.bypass") && !actor.hasPermission("fawe.bypass.regions")) {
                if (actor instanceof Player) {
                    Player player = (Player) actor;
                    allowedRegions = player.getAllowedRegions();
                }
            }
        }
        if (disallowedRegions == null && Settings.settings().REGION_RESTRICTIONS && Settings.settings().REGION_RESTRICTIONS_OPTIONS.ALLOW_BLACKLISTS) {
            if (actor != null && !actor.hasPermission("fawe.bypass") && !actor.hasPermission("fawe.bypass.regions")) {
                if (actor instanceof Player) {
                    Player player = (Player) actor;
                    disallowedRegions = player.getDisallowedRegions();
                }
            }
        }
        FaweRegionExtent regionExtent = null;
        if (disallowedRegions != null) {
            // Always use MultiRegionExtent if we have blacklist regions
            regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions, disallowedRegions);
        } else if (allowedRegions == null) {
            allowedRegions = new Region[] { RegionWrapper.GLOBAL() };
        } else {
            if (allowedRegions.length == 0) {
                regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION);
            } else {
                if (allowedRegions.length == 1) {
                    regionExtent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
                } else {
                    regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions, null);
                }
            }
        }
        // There's no need to do lighting (and it'll also just be a pain to implement) if we're not placing chunks
        if (placeChunks) {
            if (((relightMode != null && relightMode != RelightMode.NONE) || (relightMode == null && Settings.settings().LIGHTING.MODE > 0))) {
                relighter = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getRelighterFactory().createRelighter(relightMode, world, queue);
                extent.addProcessor(new RelightProcessor(relighter));
            }
            extent.addProcessor(new HeightmapProcessor(world.getMinY(), world.getMaxY()));
        } else {
            relighter = NullRelighter.INSTANCE;
        }
        if (limit != null && !limit.isUnlimited() && regionExtent != null) {
            this.extent = new LimitExtent(regionExtent, limit);
        } else if (limit != null && !limit.isUnlimited()) {
            this.extent = new LimitExtent(this.extent, limit);
        } else if (regionExtent != null) {
            this.extent = regionExtent;
        }
        if (this.limit != null && this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
            if (placeChunks) {
                extent.addProcessor(new StripNBTExtent(this.extent, this.limit.STRIP_NBT));
            } else {
                this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
            }
        }
        if (this.limit != null && !this.limit.isUnlimited()) {
            Set<String> limitBlocks = new HashSet<>();
            if ((getActor() == null || getActor().hasPermission("worldedit.anyblock") && this.limit.UNIVERSAL_DISALLOWED_BLOCKS)) {
                limitBlocks.addAll(WorldEdit.getInstance().getConfiguration().disallowedBlocks);
            }
            if (this.limit.DISALLOWED_BLOCKS != null && !this.limit.DISALLOWED_BLOCKS.isEmpty()) {
                limitBlocks.addAll(this.limit.DISALLOWED_BLOCKS);
            }
            Set<PropertyRemap<?>> remaps = this.limit.REMAP_PROPERTIES;
            if (!limitBlocks.isEmpty() || (remaps != null && !remaps.isEmpty())) {
                if (placeChunks) {
                    extent.addProcessor(new DisallowedBlocksExtent(this.extent, limitBlocks, remaps));
                } else {
                    this.extent = new DisallowedBlocksExtent(this.extent, limitBlocks, remaps);
                }
            }
        }
        this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
    }
    return this;
}
Also used : LimitExtent(com.fastasyncworldedit.core.extent.LimitExtent) IQueueChunk(com.fastasyncworldedit.core.queue.IQueueChunk) BlockBagChangeSet(com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet) SingleRegionExtent(com.fastasyncworldedit.core.extent.SingleRegionExtent) PropertyRemap(com.fastasyncworldedit.core.limit.PropertyRemap) World(com.sk89q.worldedit.world.World) SlowExtent(com.fastasyncworldedit.core.extent.SlowExtent) DiskStorageHistory(com.fastasyncworldedit.core.history.DiskStorageHistory) MemoryOptimizedHistory(com.fastasyncworldedit.core.history.MemoryOptimizedHistory) MultiRegionExtent(com.fastasyncworldedit.core.extent.MultiRegionExtent) ParallelQueueExtent(com.fastasyncworldedit.core.queue.implementation.ParallelQueueExtent) UUID(java.util.UUID) RelightProcessor(com.fastasyncworldedit.core.extent.processor.lighting.RelightProcessor) HashSet(java.util.HashSet) Player(com.sk89q.worldedit.entity.Player) HeightmapProcessor(com.fastasyncworldedit.core.extent.processor.heightmap.HeightmapProcessor) StripNBTExtent(com.fastasyncworldedit.core.extent.StripNBTExtent) NullExtent(com.fastasyncworldedit.core.extent.NullExtent) NullChangeSet(com.fastasyncworldedit.core.history.changeset.NullChangeSet) FaweRegionExtent(com.fastasyncworldedit.core.extent.FaweRegionExtent) RollbackOptimizedHistory(com.fastasyncworldedit.core.history.RollbackOptimizedHistory) HistoryExtent(com.fastasyncworldedit.core.extent.HistoryExtent) IQueueExtent(com.fastasyncworldedit.core.queue.IQueueExtent) Region(com.sk89q.worldedit.regions.Region) EditSessionEvent(com.sk89q.worldedit.event.extent.EditSessionEvent) DisallowedBlocksExtent(com.fastasyncworldedit.core.extent.DisallowedBlocksExtent)

Aggregations

PropertyRemap (com.fastasyncworldedit.core.limit.PropertyRemap)3 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)2 Player (com.sk89q.worldedit.entity.Player)2 Actor (com.sk89q.worldedit.extension.platform.Actor)2 Property (com.sk89q.worldedit.registry.state.Property)2 World (com.sk89q.worldedit.world.World)2 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 Locale (java.util.Locale)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Caption (com.fastasyncworldedit.core.configuration.Caption)1 DisallowedBlocksExtent (com.fastasyncworldedit.core.extent.DisallowedBlocksExtent)1 FaweRegionExtent (com.fastasyncworldedit.core.extent.FaweRegionExtent)1 HistoryExtent (com.fastasyncworldedit.core.extent.HistoryExtent)1 LimitExtent (com.fastasyncworldedit.core.extent.LimitExtent)1 MultiRegionExtent (com.fastasyncworldedit.core.extent.MultiRegionExtent)1 NullExtent (com.fastasyncworldedit.core.extent.NullExtent)1 SingleRegionExtent (com.fastasyncworldedit.core.extent.SingleRegionExtent)1