Search in sources :

Example 1 with EntityType

use of com.sk89q.worldedit.world.entity.EntityType in project FastAsyncWorldEdit by IntellectualSites.

the class MutableEntityChange method create.

public void create(UndoContext context) {
    Map<String, Tag> map = tag.getValue();
    Tag posTag = map.get("Pos");
    if (posTag == null) {
        LOGGER.warn("Missing pos tag: {}", tag);
        return;
    }
    List<DoubleTag> pos = (List<DoubleTag>) posTag.getValue();
    double x = pos.get(0).getValue();
    double y = pos.get(1).getValue();
    double z = pos.get(2).getValue();
    Extent extent = context.getExtent();
    Location location = new Location(extent, x, y, z, 0, 0);
    String id = tag.getString("Id");
    EntityType type = EntityTypes.parse(id);
    BaseEntity entity = new BaseEntity(type, tag);
    context.getExtent().createEntity(location, entity);
}
Also used : EntityType(com.sk89q.worldedit.world.entity.EntityType) Extent(com.sk89q.worldedit.extent.Extent) BaseEntity(com.sk89q.worldedit.entity.BaseEntity) List(java.util.List) DoubleTag(com.sk89q.jnbt.DoubleTag) CompoundTag(com.sk89q.jnbt.CompoundTag) Tag(com.sk89q.jnbt.Tag) LongTag(com.sk89q.jnbt.LongTag) DoubleTag(com.sk89q.jnbt.DoubleTag) Location(com.sk89q.worldedit.util.Location)

Example 2 with EntityType

use of com.sk89q.worldedit.world.entity.EntityType in project FastAsyncWorldEdit by IntellectualSites.

the class WorldEditPlugin method initializeRegistries.

@SuppressWarnings({ "deprecation", "unchecked" })
private void initializeRegistries() {
    // FAWE start - move Biomes to their own method. Initialize biomes twice to allow for the registry to be present for
    // plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
    setupBiomes(true);
    // Entity
    for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
        String mcid = entityType.getName();
        if (mcid != null) {
            String lowerCaseMcId = mcid.toLowerCase(Locale.ROOT);
            EntityType.REGISTRY.register("minecraft:" + lowerCaseMcId, new EntityType("minecraft:" + lowerCaseMcId));
        }
    }
    // ... :|
    GameModes.get("");
    WeatherTypes.get("");
}
Also used : EntityType(com.sk89q.worldedit.world.entity.EntityType)

Example 3 with EntityType

use of com.sk89q.worldedit.world.entity.EntityType 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 4 with EntityType

use of com.sk89q.worldedit.world.entity.EntityType in project WorldGuard by EngineHub.

the class EntityTypeFlag method parseInput.

@Override
public EntityType parseInput(FlagContext context) throws InvalidFlagFormat {
    String input = context.getUserInput();
    input = input.trim();
    EntityType entityType = unmarshal(input);
    if (entityType == null) {
        throw new InvalidFlagFormat("Unknown entity type: " + input);
    }
    return entityType;
}
Also used : EntityType(com.sk89q.worldedit.world.entity.EntityType)

Example 5 with EntityType

use of com.sk89q.worldedit.world.entity.EntityType in project WorldGuard by EngineHub.

the class BukkitWorldConfiguration method loadConfiguration.

/**
 * Load the configuration.
 */
@Override
public void loadConfiguration() {
    try {
        config.load();
    } catch (IOException e) {
        log.log(Level.SEVERE, "Error reading configuration for world " + worldName + ": ", e);
    } catch (YAMLException e) {
        log.severe("Error parsing configuration for world " + worldName + ". ");
        throw e;
    }
    boolean needParentSave = false;
    summaryOnStart = getBoolean("summary-on-start", true);
    opPermissions = getBoolean("op-permissions", true);
    buildPermissions = getBoolean("build-permission-nodes.enable", false);
    buildPermissionDenyMessage = CommandUtils.replaceColorMacros(getString("build-permission-nodes.deny-message", "&eSorry, but you are not permitted to do that here."));
    strictEntitySpawn = getBoolean("event-handling.block-entity-spawns-with-untraceable-cause", false);
    allowAllInteract = getTargetMatchers("event-handling.interaction-whitelist");
    blockUseAtFeet = getTargetMatchers("event-handling.emit-block-use-at-feet");
    ignoreHopperMoveEvents = getBoolean("event-handling.ignore-hopper-item-move-events", false);
    breakDeniedHoppers = getBoolean("event-handling.break-hoppers-on-denied-move", true);
    usePaperEntityOrigin = getBoolean("regions.use-paper-entity-origin", false);
    itemDurability = getBoolean("protection.item-durability", true);
    removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false);
    disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false);
    needParentSave |= removeProperty("protection.disable-obsidian-generators");
    useMaxPriorityAssociation = getBoolean("protection.use-max-priority-association", false);
    blockPotions = new HashSet<>();
    for (String potionName : getStringList("gameplay.block-potions", null)) {
        PotionEffectType effect = PotionEffectType.getByName(potionName);
        if (effect == null) {
            log.warning("Unknown potion effect type '" + potionName + "'");
        } else {
            blockPotions.add(effect);
        }
    }
    blockPotionsAlways = getBoolean("gameplay.block-potions-overly-reliably", false);
    disableConduitEffects = getBoolean("gameplay.disable-conduit-effects", false);
    simulateSponge = getBoolean("simulation.sponge.enable", false);
    spongeRadius = Math.max(1, getInt("simulation.sponge.radius", 3)) - 1;
    redstoneSponges = getBoolean("simulation.sponge.redstone", false);
    if (simulateSponge) {
        log.warning("Sponge simulation is deprecated for removal in a future version. We recommend using CraftBook's sponge simulation instead.");
    } else {
        needParentSave |= removeProperty("simulation");
    }
    pumpkinScuba = getBoolean("default.pumpkin-scuba", false);
    disableHealthRegain = getBoolean("default.disable-health-regain", false);
    noPhysicsGravel = getBoolean("physics.no-physics-gravel", false);
    noPhysicsSand = getBoolean("physics.no-physics-sand", false);
    ropeLadders = getBoolean("physics.vine-like-rope-ladders", false);
    allowPortalAnywhere = getBoolean("physics.allow-portal-anywhere", false);
    preventWaterDamage = new HashSet<>(convertLegacyBlocks(getStringList("physics.disable-water-damage-blocks", null)));
    blockTNTExplosions = getBoolean("ignition.block-tnt", false);
    blockTNTBlockDamage = getBoolean("ignition.block-tnt-block-damage", false);
    blockLighter = getBoolean("ignition.block-lighter", false);
    preventLavaFire = getBoolean("fire.disable-lava-fire-spread", false);
    disableFireSpread = getBoolean("fire.disable-all-fire-spread", false);
    disableFireSpreadBlocks = new HashSet<>(convertLegacyBlocks(getStringList("fire.disable-fire-spread-blocks", null)));
    allowedLavaSpreadOver = new HashSet<>(convertLegacyBlocks(getStringList("fire.lava-spread-blocks", null)));
    blockCreeperExplosions = getBoolean("mobs.block-creeper-explosions", false);
    blockCreeperBlockDamage = getBoolean("mobs.block-creeper-block-damage", false);
    blockWitherExplosions = getBoolean("mobs.block-wither-explosions", false);
    blockWitherBlockDamage = getBoolean("mobs.block-wither-block-damage", false);
    blockWitherSkullExplosions = getBoolean("mobs.block-wither-skull-explosions", false);
    blockWitherSkullBlockDamage = getBoolean("mobs.block-wither-skull-block-damage", false);
    blockEnderDragonBlockDamage = getBoolean("mobs.block-enderdragon-block-damage", false);
    blockEnderDragonPortalCreation = getBoolean("mobs.block-enderdragon-portal-creation", false);
    blockFireballExplosions = getBoolean("mobs.block-fireball-explosions", false);
    blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false);
    antiWolfDumbness = getBoolean("mobs.anti-wolf-dumbness", false);
    allowTamedSpawns = getBoolean("mobs.allow-tamed-spawns", true);
    disableEndermanGriefing = getBoolean("mobs.disable-enderman-griefing", false);
    disableSnowmanTrails = getBoolean("mobs.disable-snowman-trails", false);
    blockEntityPaintingDestroy = getBoolean("mobs.block-painting-destroy", false);
    blockEntityItemFrameDestroy = getBoolean("mobs.block-item-frame-destroy", false);
    blockEntityArmorStandDestroy = getBoolean("mobs.block-armor-stand-destroy", false);
    blockPluginSpawning = getBoolean("mobs.block-plugin-spawning", true);
    blockGroundSlimes = getBoolean("mobs.block-above-ground-slimes", false);
    blockOtherExplosions = getBoolean("mobs.block-other-explosions", false);
    blockZombieDoorDestruction = getBoolean("mobs.block-zombie-door-destruction", false);
    blockEntityVehicleEntry = getBoolean("mobs.block-vehicle-entry", false);
    disableFallDamage = getBoolean("player-damage.disable-fall-damage", false);
    disableLavaDamage = getBoolean("player-damage.disable-lava-damage", false);
    disableFireDamage = getBoolean("player-damage.disable-fire-damage", false);
    disableLightningDamage = getBoolean("player-damage.disable-lightning-damage", false);
    disableDrowningDamage = getBoolean("player-damage.disable-drowning-damage", false);
    disableSuffocationDamage = getBoolean("player-damage.disable-suffocation-damage", false);
    disableContactDamage = getBoolean("player-damage.disable-contact-damage", false);
    teleportOnSuffocation = getBoolean("player-damage.teleport-on-suffocation", false);
    disableVoidDamage = getBoolean("player-damage.disable-void-damage", false);
    teleportOnVoid = getBoolean("player-damage.teleport-on-void-falling", false);
    safeFallOnVoid = getBoolean("player-damage.reset-fall-on-void-teleport", false);
    disableExplosionDamage = getBoolean("player-damage.disable-explosion-damage", false);
    disableMobDamage = getBoolean("player-damage.disable-mob-damage", false);
    disableDeathMessages = getBoolean("player-damage.disable-death-messages", false);
    signChestProtection = getBoolean("chest-protection.enable", false);
    disableSignChestProtectionCheck = getBoolean("chest-protection.disable-off-check", false);
    if (signChestProtection) {
        log.warning("Sign-based chest protection is deprecated for removal in a future version. See https://worldguard.enginehub.org/en/latest/chest-protection/ for details.");
    } else {
        needParentSave |= removeProperty("chest-protection");
    }
    disableCreatureCropTrampling = getBoolean("crops.disable-creature-trampling", false);
    disablePlayerCropTrampling = getBoolean("crops.disable-player-trampling", false);
    disableCreatureTurtleEggTrampling = getBoolean("turtle-egg.disable-creature-trampling", false);
    disablePlayerTurtleEggTrampling = getBoolean("turtle-egg.disable-player-trampling", false);
    disallowedLightningBlocks = new HashSet<>(convertLegacyBlocks(getStringList("weather.prevent-lightning-strike-blocks", null)));
    preventLightningFire = getBoolean("weather.disable-lightning-strike-fire", false);
    disableThunder = getBoolean("weather.disable-thunderstorm", false);
    disableWeather = getBoolean("weather.disable-weather", false);
    disablePigZap = getBoolean("weather.disable-pig-zombification", false);
    disableVillagerZap = getBoolean("weather.disable-villager-witchification", false);
    disableCreeperPower = getBoolean("weather.disable-powered-creepers", false);
    alwaysRaining = getBoolean("weather.always-raining", false);
    alwaysThundering = getBoolean("weather.always-thundering", false);
    disableMushroomSpread = getBoolean("dynamics.disable-mushroom-spread", false);
    disableIceMelting = getBoolean("dynamics.disable-ice-melting", false);
    disableSnowMelting = getBoolean("dynamics.disable-snow-melting", false);
    disableSnowFormation = getBoolean("dynamics.disable-snow-formation", false);
    disableIceFormation = getBoolean("dynamics.disable-ice-formation", false);
    disableLeafDecay = getBoolean("dynamics.disable-leaf-decay", false);
    disableGrassGrowth = getBoolean("dynamics.disable-grass-growth", false);
    disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
    disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
    disableRockGrowth = getBoolean("dynamics.disable-rock-growth", false);
    disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false);
    disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
    disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false);
    allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
    useRegions = getBoolean("regions.enable", true);
    regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
    regionCancelEmptyChatEvents = getBoolean("regions.cancel-chat-without-recipients", true);
    regionNetherPortalProtection = getBoolean("regions.nether-portal-protection", true);
    // note: technically not region-specific, but we only use it for the title flags
    forceDefaultTitleTimes = config.getBoolean("regions.titles-always-use-default-times", true);
    fakePlayerBuildOverride = getBoolean("regions.fake-player-build-override", true);
    explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
    highFreqFlags = getBoolean("regions.high-frequency-flags", false);
    checkLiquidFlow = getBoolean("regions.protect-against-liquid-flow", false);
    regionWand = convertLegacyItem(getString("regions.wand", ItemTypes.LEATHER.getId()));
    maxClaimVolume = getInt("regions.max-claim-volume", 30000);
    claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false);
    setParentOnClaim = getString("regions.set-parent-on-claim", "");
    boundedLocationFlags = getBoolean("regions.location-flags-only-inside-regions", false);
    maxRegionCountPerPlayer = getInt("regions.max-region-count-per-player.default", 7);
    maxRegionCounts = new HashMap<>();
    maxRegionCounts.put(null, maxRegionCountPerPlayer);
    for (String key : getKeys("regions.max-region-count-per-player")) {
        if (!key.equalsIgnoreCase("default")) {
            Object val = getProperty("regions.max-region-count-per-player." + key);
            if (val instanceof Number) {
                maxRegionCounts.put(key, ((Number) val).intValue());
            }
        }
    }
    // useiConomy = getBoolean("iconomy.enable", false);
    // buyOnClaim = getBoolean("iconomy.buy-on-claim", false);
    // buyOnClaimPrice = getDouble("iconomy.buy-on-claim-price", 1.0);
    blockCreatureSpawn = new HashSet<>();
    for (String creatureName : getStringList("mobs.block-creature-spawn", null)) {
        EntityType creature = EntityTypes.get(creatureName.toLowerCase());
        if (creature == null) {
            log.warning("Unknown entity type '" + creatureName + "'");
        } else {
            blockCreatureSpawn.add(creature);
        }
    }
    boolean useBlacklistAsWhitelist = getBoolean("blacklist.use-as-whitelist", false);
    // Console log configuration
    boolean logConsole = getBoolean("blacklist.logging.console.enable", true);
    // Database log configuration
    boolean logDatabase = getBoolean("blacklist.logging.database.enable", false);
    String dsn = getString("blacklist.logging.database.dsn", "jdbc:mysql://localhost:3306/minecraft");
    String user = getString("blacklist.logging.database.user", "root");
    String pass = getString("blacklist.logging.database.pass", "");
    String table = getString("blacklist.logging.database.table", "blacklist_events");
    // File log configuration
    boolean logFile = getBoolean("blacklist.logging.file.enable", false);
    String logFilePattern = getString("blacklist.logging.file.path", "worldguard/logs/%Y-%m-%d.log");
    int logFileCacheSize = Math.max(1, getInt("blacklist.logging.file.open-files", 10));
    // Load the blacklist
    try {
        // If there was an existing blacklist, close loggers
        if (blacklist != null) {
            blacklist.getLogger().close();
        }
        // First load the blacklist data from worldguard-blacklist.txt
        Blacklist blist = new Blacklist(useBlacklistAsWhitelist);
        blist.load(blacklistFile);
        // and save some resources
        if (blist.isEmpty()) {
            this.blacklist = null;
        } else {
            this.blacklist = blist;
            if (summaryOnStart) {
                log.log(Level.INFO, "({0}) Blacklist loaded with {1} entries.", new Object[] { worldName, blacklist.getItemCount() });
            }
            BlacklistLoggerHandler blacklistLogger = blist.getLogger();
            if (logDatabase) {
                blacklistLogger.addHandler(new DatabaseHandler(dsn, user, pass, table, worldName, log));
            }
            if (logConsole) {
                blacklistLogger.addHandler(new ConsoleHandler(worldName, log));
            }
            if (logFile) {
                FileHandler handler = new FileHandler(logFilePattern, logFileCacheSize, worldName, log);
                blacklistLogger.addHandler(handler);
            }
        }
    } catch (FileNotFoundException e) {
        log.log(Level.WARNING, "WorldGuard blacklist does not exist.");
    } catch (IOException e) {
        log.log(Level.WARNING, "Could not load WorldGuard blacklist: " + e.getMessage());
    }
    // Print an overview of settings
    if (summaryOnStart) {
        log.log(Level.INFO, blockTNTExplosions ? "(" + worldName + ") TNT ignition is blocked." : "(" + worldName + ") TNT ignition is PERMITTED.");
        log.log(Level.INFO, blockLighter ? "(" + worldName + ") Lighters are blocked." : "(" + worldName + ") Lighters are PERMITTED.");
        log.log(Level.INFO, preventLavaFire ? "(" + worldName + ") Lava fire is blocked." : "(" + worldName + ") Lava fire is PERMITTED.");
        if (disableFireSpread) {
            log.log(Level.INFO, "(" + worldName + ") All fire spread is disabled.");
        } else {
            if (!disableFireSpreadBlocks.isEmpty()) {
                log.log(Level.INFO, "(" + worldName + ") Fire spread is limited to " + disableFireSpreadBlocks.size() + " block types.");
            } else {
                log.log(Level.INFO, "(" + worldName + ") Fire spread is UNRESTRICTED.");
            }
        }
    }
    config.setHeader(CONFIG_HEADER);
    config.save();
    if (needParentSave) {
        parentConfig.save();
    }
}
Also used : PotionEffectType(org.bukkit.potion.PotionEffectType) FileNotFoundException(java.io.FileNotFoundException) YAMLException(org.yaml.snakeyaml.error.YAMLException) IOException(java.io.IOException) ConsoleHandler(com.sk89q.worldguard.blacklist.logger.ConsoleHandler) FileHandler(com.sk89q.worldguard.blacklist.logger.FileHandler) EntityType(com.sk89q.worldedit.world.entity.EntityType) DatabaseHandler(com.sk89q.worldguard.blacklist.logger.DatabaseHandler) BlacklistLoggerHandler(com.sk89q.worldguard.blacklist.BlacklistLoggerHandler) Blacklist(com.sk89q.worldguard.blacklist.Blacklist)

Aggregations

EntityType (com.sk89q.worldedit.world.entity.EntityType)7 CompoundTag (com.sk89q.jnbt.CompoundTag)4 Tag (com.sk89q.jnbt.Tag)3 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)3 Location (com.sk89q.worldedit.util.Location)3 ByteArrayTag (com.sk89q.jnbt.ByteArrayTag)2 IntTag (com.sk89q.jnbt.IntTag)2 ListTag (com.sk89q.jnbt.ListTag)2 NamedTag (com.sk89q.jnbt.NamedTag)2 ShortTag (com.sk89q.jnbt.ShortTag)2 StringTag (com.sk89q.jnbt.StringTag)2 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)2 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)2 BlockState (com.sk89q.worldedit.world.block.BlockState)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 SlottableBlockBag (com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag)1 NBTException (com.fastasyncworldedit.core.jnbt.NBTException)1 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)1 BlanketBaseBlock (com.fastasyncworldedit.core.world.block.BlanketBaseBlock)1