Search in sources :

Example 1 with FaweLimit

use of com.fastasyncworldedit.core.limit.FaweLimit 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 FaweLimit

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

the class DefaultBlockParser method parseLogic.

private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
    // FAWE start
    String[] blockAndExtraData = input.trim().split("\\|", 2);
    blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
    Map<Property<?>, Object> blockStates = new HashMap<>();
    // FAWE end
    BlockState state = null;
    // Legacy matcher
    if (context.isTryingLegacy()) {
        try {
            String[] split = blockAndExtraData[0].split(":", 2);
            if (split.length == 0) {
                throw new InputParseException(Caption.of("worldedit.error.parser.invalid-colon"));
            } else if (split.length == 1) {
                state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
            } else if (MathMan.isInteger(split[0])) {
                int id = Integer.parseInt(split[0]);
                int data = Integer.parseInt(split[1]);
                // FAWE start
                if (data < 0 || data >= 16) {
                    throw new InputParseException(Caption.of("fawe.error.parser.invalid-data", TextComponent.of(data)));
                }
                state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
            } else {
                BlockType type = BlockTypes.get(split[0].toLowerCase(Locale.ROOT));
                if (type != null) {
                    int data = Integer.parseInt(split[1]);
                    if (data < 0 || data >= 16) {
                        throw new InputParseException(Caption.of("fawe.error.parser.invalid-data", TextComponent.of(data)));
                    }
                    state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
                }
            }
        } catch (NumberFormatException ignored) {
        }
    }
    CompoundTag nbt = null;
    // FAWE end
    if (state == null) {
        String typeString;
        String stateString = null;
        int stateStart = blockAndExtraData[0].indexOf('[');
        if (stateStart == -1) {
            typeString = blockAndExtraData[0];
        } else {
            typeString = blockAndExtraData[0].substring(0, stateStart);
            if (stateStart + 1 >= blockAndExtraData[0].length()) {
                throw new InputParseException(Caption.of("worldedit.error.parser.hanging-lbracket", TextComponent.of(stateStart)));
            }
            int stateEnd = blockAndExtraData[0].lastIndexOf(']');
            if (stateEnd < 0) {
                throw new InputParseException(Caption.of("worldedit.error.parser.missing-rbracket"));
            }
            stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
        }
        String[] stateProperties = EMPTY_STRING_ARRAY;
        if (stateString != null) {
            stateProperties = stateString.split(",");
        }
        if (typeString.isEmpty()) {
            throw new InputParseException(Caption.of("worldedit.error.parser.bad-state-format", TextComponent.of(blockAndExtraData[0])));
        }
        if ("hand".equalsIgnoreCase(typeString)) {
            // Get the block type from the item in the user's hand.
            final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
            // FAWE start
            state = blockInHand.toBlockState();
            nbt = blockInHand.getNbtData();
        // FAWE end
        } else if ("offhand".equalsIgnoreCase(typeString)) {
            // Get the block type from the item in the user's off hand.
            final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
            // FAWE start
            state = blockInHand.toBlockState();
            nbt = blockInHand.getNbtData();
        // FAWE end
        } else if (typeString.matches("pos[0-9]+")) {
            int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
            // Get the block type from the "primary position"
            final World world = context.requireWorld();
            final BlockVector3 primaryPosition;
            try {
                primaryPosition = context.requireSession().getRegionSelector(world).getVertices().get(index - 1);
            } catch (IncompleteRegionException e) {
                throw new InputParseException(Caption.of("worldedit.error.incomplete-region"));
            }
            state = world.getBlock(primaryPosition);
            nbt = state.getNbtData();
        // FAWE start
        } else if (typeString.matches("slot[0-9]+")) {
            int slot = Integer.parseInt(typeString.substring(4)) - 1;
            Actor actor = context.requireActor();
            if (!(actor instanceof Player)) {
                throw new InputParseException(Caption.of("worldedit.command.player-only"));
            }
            Player player = (Player) actor;
            BlockBag bag = player.getInventoryBlockBag();
            if (!(bag instanceof SlottableBlockBag)) {
                throw new InputParseException(Caption.of("fawe.error.unsupported"));
            }
            SlottableBlockBag slottable = (SlottableBlockBag) bag;
            BaseItem item = slottable.getItem(slot);
            if (!item.getType().hasBlockType()) {
                throw new InputParseException(Caption.of("worldedit.error.not-a-block"));
            }
            state = item.getType().getBlockType().getDefaultState();
            nbt = item.getNbtData();
        } else {
            BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
            if (type != null) {
                state = type.getDefaultState();
            }
            if (state == null) {
                throw new NoMatchException(Caption.of("fawe.error.invalid-block-type", TextComponent.of(input)));
            }
        }
        // FAWE end
        // FAWE start -  Not null if nullNotError false.
        blockStates.putAll(parseProperties(state.getBlockType(), stateProperties, context, false));
        // FAWE end
        if (context.isPreferringWildcard()) {
            if (stateString == null || stateString.isEmpty()) {
                state = new FuzzyBlockState(state);
            } else {
                FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder();
                fuzzyBuilder.type(state.getBlockType());
                for (Map.Entry<Property<?>, Object> blockState : blockStates.entrySet()) {
                    @SuppressWarnings("unchecked") Property<Object> objProp = (Property<Object>) blockState.getKey();
                    fuzzyBuilder.withProperty(objProp, blockState.getValue());
                }
                state = fuzzyBuilder.build();
            }
        } else {
            for (Map.Entry<Property<?>, Object> blockState : blockStates.entrySet()) {
                @SuppressWarnings("unchecked") Property<Object> objProp = (Property<Object>) blockState.getKey();
                state = state.with(objProp, blockState.getValue());
            }
        }
    }
    // this should be impossible but IntelliJ isn't that smart
    if (state == null) {
        throw new NoMatchException(Caption.of("worldedit.error.unknown-block", TextComponent.of(input)));
    }
    // FAWE start
    if (blockAndExtraData.length > 1 && blockAndExtraData[1].startsWith("{")) {
        String joined = StringMan.join(Arrays.copyOfRange(blockAndExtraData, 1, blockAndExtraData.length), "|");
        try {
            nbt = JSON2NBT.getTagFromJson(joined);
        } catch (NBTException e) {
            throw new NoMatchException(TextComponent.of(e.getMessage()));
        }
    }
    // FAWE end
    // Check if the item is allowed
    BlockType blockType = state.getBlockType();
    if (context.isRestricted()) {
        Actor actor = context.requireActor();
        // FAWE start - per-limit disallowed blocks
        if (actor != null) {
            if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
                throw new DisallowedUsageException(Caption.of("worldedit.error.disallowed-block", TextComponent.of(blockType.getId())));
            }
            FaweLimit limit = actor.getLimit();
            if (!limit.isUnlimited()) {
                // during contains.
                if (limit.DISALLOWED_BLOCKS.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
                    throw new DisallowedUsageException(Caption.of("fawe.error.limit.disallowed-block", TextComponent.of(blockType.getId())));
                }
            }
        }
    // FAWE end
    }
    if (nbt != null) {
        BaseBlock result = blockStates.size() > 0 ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt);
        return validate(context, result);
    }
    if (blockType == BlockTypes.SIGN || blockType == BlockTypes.WALL_SIGN || BlockCategories.SIGNS.contains(blockType)) {
        // Allow special sign text syntax
        String[] text = new String[4];
        text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
        text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
        text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
        text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
        return validate(context, new SignBlock(state, text));
    } else if (blockType == BlockTypes.SPAWNER) {
        // Allow setting mob spawn type
        if (blockAndExtraData.length > 1) {
            String mobName = blockAndExtraData[1];
            EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
            if (ent == null) {
                throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
            }
            mobName = ent.getId();
            if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
                throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
            }
            return validate(context, new MobSpawnerBlock(state, mobName));
        } else {
            // noinspection ConstantConditions
            return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
        }
    } else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
        // allow setting type/player/rotation
        if (blockAndExtraData.length <= 1) {
            return validate(context, new SkullBlock(state));
        }
        String type = blockAndExtraData[1];
        // valid MC usernames
        return validate(context, new SkullBlock(state, type.replace(" ", "_")));
    } else {
        // FAWE start
        nbt = state.getNbtData();
        BaseBlock result;
        if (nbt != null) {
            result = blockStates.size() > 0 ? state.toBaseBlock(nbt) : new BlanketBaseBlock(state, nbt);
        } else {
            result = blockStates.size() > 0 ? new BaseBlock(state) : state.toBaseBlock();
        }
        return validate(context, result);
    // FAWE end
    }
}
Also used : SkullBlock(com.sk89q.worldedit.blocks.SkullBlock) HashMap(java.util.HashMap) SignBlock(com.sk89q.worldedit.blocks.SignBlock) IncompleteRegionException(com.sk89q.worldedit.IncompleteRegionException) World(com.sk89q.worldedit.world.World) BlanketBaseBlock(com.fastasyncworldedit.core.world.block.BlanketBaseBlock) BaseBlock(com.sk89q.worldedit.world.block.BaseBlock) BlanketBaseBlock(com.fastasyncworldedit.core.world.block.BlanketBaseBlock) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) MobSpawnerBlock(com.sk89q.worldedit.blocks.MobSpawnerBlock) Actor(com.sk89q.worldedit.extension.platform.Actor) Property(com.sk89q.worldedit.registry.state.Property) BaseItem(com.sk89q.worldedit.blocks.BaseItem) CompoundTag(com.sk89q.jnbt.CompoundTag) Player(com.sk89q.worldedit.entity.Player) BlockBag(com.sk89q.worldedit.extent.inventory.BlockBag) SlottableBlockBag(com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag) FuzzyBlockState(com.sk89q.worldedit.world.block.FuzzyBlockState) BlockVector3(com.sk89q.worldedit.math.BlockVector3) EntityType(com.sk89q.worldedit.world.entity.EntityType) DisallowedUsageException(com.sk89q.worldedit.extension.input.DisallowedUsageException) FuzzyBlockState(com.sk89q.worldedit.world.block.FuzzyBlockState) BlockState(com.sk89q.worldedit.world.block.BlockState) BlockType(com.sk89q.worldedit.world.block.BlockType) SlottableBlockBag(com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag) NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException) Map(java.util.Map) HashMap(java.util.HashMap) NBTException(com.fastasyncworldedit.core.jnbt.NBTException)

Example 3 with FaweLimit

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

the class ClipboardCommands method copy.

@Command(name = "/copy", aliases = "/cp", desc = "Copy the selection to the clipboard")
@CommandPermissions("worldedit.clipboard.copy")
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void copy(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Switch(name = 'e', desc = "Also copy entities") boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, // FAWE start
@Switch(name = 'c', desc = "Set the origin of the clipboard to the center of the region, at the region's lowest " + "y-level.") boolean centerClipboard, @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") Mask mask) throws WorldEditException {
    BlockVector3 min = region.getMinimumPoint();
    BlockVector3 max = region.getMaximumPoint();
    long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
    FaweLimit limit = actor.getLimit();
    if (volume >= limit.MAX_CHECKS) {
        throw FaweCache.MAX_CHECKS;
    }
    session.setClipboard(null);
    Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
    clipboard.setOrigin(centerClipboard ? region.getCenter().toBlockPoint().withY(region.getMinimumY()) : session.getPlacementPosition(actor));
    ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
    copy.setCopyingEntities(copyEntities);
    copy.setCopyingBiomes(copyBiomes);
    Mask sourceMask = editSession.getSourceMask();
    Region[] regions = editSession.getAllowedRegions();
    Region allowedRegion;
    if (regions == null || regions.length == 0) {
        allowedRegion = new NullRegion();
    } else {
        allowedRegion = new RegionIntersection(regions);
    }
    final Mask firstSourceMask = mask != null ? mask : sourceMask;
    final Mask finalMask = MaskIntersection.of(firstSourceMask, new RegionMask(allowedRegion)).optimize();
    if (finalMask != Masks.alwaysTrue()) {
        copy.setSourceMask(finalMask);
    }
    if (sourceMask != null) {
        editSession.setSourceMask(null);
        new MaskTraverser(sourceMask).reset(editSession);
        editSession.setSourceMask(null);
    }
    try {
        Operations.completeLegacy(copy);
    } catch (Throwable e) {
        throw e;
    } finally {
        clipboard.flush();
    }
    session.setClipboard(new ClipboardHolder(clipboard));
    copy.getStatusMessages().forEach(actor::print);
// FAWE end
}
Also used : BlockArrayClipboard(com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard) MultiClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder) URIClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) RegionMask(com.sk89q.worldedit.function.mask.RegionMask) ClipboardMask(com.sk89q.worldedit.internal.annotation.ClipboardMask) Mask(com.sk89q.worldedit.function.mask.Mask) RegionMask(com.sk89q.worldedit.function.mask.RegionMask) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) BlockVector3(com.sk89q.worldedit.math.BlockVector3) ForwardExtentCopy(com.sk89q.worldedit.function.operation.ForwardExtentCopy) NullRegion(com.sk89q.worldedit.regions.NullRegion) RegionIntersection(com.sk89q.worldedit.regions.RegionIntersection) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) NullRegion(com.sk89q.worldedit.regions.NullRegion) Region(com.sk89q.worldedit.regions.Region) DiskOptimizedClipboard(com.fastasyncworldedit.core.extent.clipboard.DiskOptimizedClipboard) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) BlockArrayClipboard(com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard) ReadOnlyClipboard(com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 4 with FaweLimit

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

the class EditSession method getLimitUsed.

/**
 * Returns a new limit representing how much of this edit's limit has been used so far.
 *
 * @return Limit remaining
 */
public FaweLimit getLimitUsed() {
    FaweLimit newLimit = new FaweLimit();
    newLimit.MAX_ACTIONS = originalLimit.MAX_ACTIONS - limit.MAX_ACTIONS;
    newLimit.MAX_CHANGES = originalLimit.MAX_CHANGES - limit.MAX_CHANGES;
    newLimit.MAX_FAILS = originalLimit.MAX_FAILS - limit.MAX_FAILS;
    newLimit.MAX_CHECKS = originalLimit.MAX_CHECKS - limit.MAX_CHECKS;
    newLimit.MAX_ITERATIONS = originalLimit.MAX_ITERATIONS - limit.MAX_ITERATIONS;
    newLimit.MAX_BLOCKSTATES = originalLimit.MAX_BLOCKSTATES - limit.MAX_BLOCKSTATES;
    newLimit.MAX_ENTITIES = originalLimit.MAX_ENTITIES - limit.MAX_ENTITIES;
    newLimit.MAX_HISTORY = limit.MAX_HISTORY;
    return newLimit;
}
Also used : FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit)

Example 5 with FaweLimit

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

the class EditSessionBuilder method limitUnprocessed.

/**
 * Unlimited in regions/block changes, but uses the given {@link Actor}'s inventory mode.
 */
public EditSessionBuilder limitUnprocessed(@Nonnull Actor player) {
    limitUnlimited();
    FaweLimit tmp = player.getLimit();
    limit.INVENTORY_MODE = tmp.INVENTORY_MODE;
    return setDirty();
}
Also used : FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit)

Aggregations

FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)11 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)6 Command (org.enginehub.piston.annotation.Command)6 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)5 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)3 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)3 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)3 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)3 Preload (com.sk89q.worldedit.command.util.annotation.Preload)3 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)2 ReadOnlyClipboard (com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard)2 SnowSmoothBrush (com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush)2 Logging (com.sk89q.worldedit.command.util.Logging)2 Player (com.sk89q.worldedit.entity.Player)2 Actor (com.sk89q.worldedit.extension.platform.Actor)2 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)2 Mask (com.sk89q.worldedit.function.mask.Mask)2 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)2 ForwardExtentCopy (com.sk89q.worldedit.function.operation.ForwardExtentCopy)2 ClipboardMask (com.sk89q.worldedit.internal.annotation.ClipboardMask)2