2011-02-25 16:42:48 +01:00
/ *
2014-07-13 04:29:29 +02:00
* WorldGuard , a suite of tools for Minecraft
* Copyright ( C ) sk89q < http : //www.sk89q.com>
* Copyright ( C ) WorldGuard team and contributors
2011-02-25 16:42:48 +01:00
*
2014-07-13 04:29:29 +02:00
* This program is free software : you can redistribute it and / or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation , either version 3 of the License , or
2011-02-25 16:42:48 +01:00
* ( at your option ) any later version .
*
2014-07-13 04:29:29 +02:00
* This program is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU Lesser General Public License
* for more details .
2011-02-25 16:42:48 +01:00
*
2014-07-13 04:29:29 +02:00
* You should have received a copy of the GNU Lesser General Public License
2011-02-25 16:42:48 +01:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2011-03-08 19:01:03 +01:00
* /
2011-02-25 16:42:48 +01:00
package com.sk89q.worldguard.bukkit ;
2014-07-13 06:14:26 +02:00
import com.sk89q.util.yaml.YAMLFormat ;
import com.sk89q.util.yaml.YAMLProcessor ;
2018-07-19 16:06:02 +02:00
import com.sk89q.worldedit.util.Location ;
2018-08-15 04:49:25 +02:00
import com.sk89q.worldedit.util.report.Unreported ;
import com.sk89q.worldedit.world.entity.EntityType ;
import com.sk89q.worldedit.world.entity.EntityTypes ;
2018-07-22 05:06:01 +02:00
import com.sk89q.worldedit.world.item.ItemTypes ;
2018-07-19 16:06:02 +02:00
import com.sk89q.worldguard.LocalPlayer ;
2014-07-13 06:14:26 +02:00
import com.sk89q.worldguard.blacklist.Blacklist ;
2014-07-29 00:58:07 +02:00
import com.sk89q.worldguard.blacklist.BlacklistLoggerHandler ;
2014-07-28 23:37:52 +02:00
import com.sk89q.worldguard.blacklist.logger.ConsoleHandler ;
import com.sk89q.worldguard.blacklist.logger.DatabaseHandler ;
import com.sk89q.worldguard.blacklist.logger.FileHandler ;
2014-09-01 04:17:05 +02:00
import com.sk89q.worldguard.blacklist.target.TargetMatcherParseException ;
import com.sk89q.worldguard.blacklist.target.TargetMatcherParser ;
2018-08-07 03:44:19 +02:00
import com.sk89q.worldguard.bukkit.chest.BukkitSignChestProtection ;
2014-12-31 10:53:28 +01:00
import com.sk89q.worldguard.bukkit.internal.TargetMatcherSet ;
2018-08-15 04:49:25 +02:00
import com.sk89q.worldguard.chest.ChestProtection ;
2018-12-26 05:32:35 +01:00
import com.sk89q.worldguard.commands.CommandUtils ;
2018-07-19 16:06:02 +02:00
import com.sk89q.worldguard.config.YamlWorldConfiguration ;
2014-07-13 06:14:26 +02:00
import org.bukkit.potion.PotionEffectType ;
2020-08-16 08:55:19 +02:00
import org.yaml.snakeyaml.error.YAMLException ;
2014-07-13 06:14:26 +02:00
2013-01-12 00:37:46 +01:00
import java.io.File ;
import java.io.FileNotFoundException ;
import java.io.IOException ;
2018-07-19 16:06:02 +02:00
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.HashSet ;
import java.util.List ;
import java.util.Set ;
2013-01-12 00:37:46 +01:00
import java.util.logging.Level ;
2011-02-25 16:42:48 +01:00
/ * *
2011-03-28 08:49:30 +02:00
* Holds the configuration for individual worlds .
2011-04-03 11:48:32 +02:00
*
2011-03-28 08:49:30 +02:00
* @author sk89q
2011-02-25 16:42:48 +01:00
* @author Michael
* /
2018-07-19 16:06:02 +02:00
public class BukkitWorldConfiguration extends YamlWorldConfiguration {
2011-02-25 16:42:48 +01:00
2014-09-01 04:17:05 +02:00
private static final TargetMatcherParser matcherParser = new TargetMatcherParser ( ) ;
2014-08-22 07:22:28 +02:00
2014-12-31 10:18:23 +01:00
@Unreported private String worldName ;
2011-02-25 16:42:48 +01:00
2018-08-07 03:44:19 +02:00
@Unreported private ChestProtection chestProtection = new BukkitSignChestProtection ( ) ;
2011-02-25 16:42:48 +01:00
/* Configuration data start */
2012-11-04 22:42:55 +01:00
public Set < PotionEffectType > blockPotions ;
2014-09-01 04:17:05 +02:00
public TargetMatcherSet allowAllInteract ;
2016-12-23 05:38:28 +01:00
public TargetMatcherSet blockUseAtFeet ;
2019-08-02 05:47:27 +02:00
public boolean usePaperEntityOrigin ;
2011-03-08 19:01:03 +01:00
/* Configuration data end */
2011-02-25 16:42:48 +01:00
2011-03-28 08:49:30 +02:00
/ * *
* Construct the object .
2011-04-03 11:48:32 +02:00
*
2012-01-28 06:54:53 +01:00
* @param plugin The WorldGuardPlugin instance
2018-07-19 16:06:02 +02:00
* @param worldName The world name that this BukkitWorldConfiguration is for .
2012-01-28 06:54:53 +01:00
* @param parentConfig The parent configuration to read defaults from
2011-03-28 08:49:30 +02:00
* /
2018-07-19 16:06:02 +02:00
public BukkitWorldConfiguration ( WorldGuardPlugin plugin , String worldName , YAMLProcessor parentConfig ) {
2011-03-28 08:49:30 +02:00
File baseFolder = new File ( plugin . getDataFolder ( ) , " worlds/ " + worldName ) ;
2012-02-21 00:14:55 +01:00
File configFile = new File ( baseFolder , " config.yml " ) ;
2011-03-28 08:49:30 +02:00
blacklistFile = new File ( baseFolder , " blacklist.txt " ) ;
2011-04-03 11:48:32 +02:00
2011-02-25 16:42:48 +01:00
this . worldName = worldName ;
2012-01-28 06:54:53 +01:00
this . parentConfig = parentConfig ;
2011-04-03 11:48:32 +02:00
2011-09-29 04:01:46 +02:00
plugin . createDefaultConfiguration ( configFile , " config_world.yml " ) ;
plugin . createDefaultConfiguration ( blacklistFile , " blacklist.txt " ) ;
2011-03-08 19:01:03 +01:00
2012-02-21 00:14:55 +01:00
config = new YAMLProcessor ( configFile , true , YAMLFormat . EXTENDED ) ;
2011-02-25 16:42:48 +01:00
loadConfiguration ( ) ;
2011-03-28 08:49:30 +02:00
2013-01-13 23:21:51 +01:00
if ( summaryOnStart ) {
2014-08-22 07:22:28 +02:00
log . info ( " Loaded configuration for world ' " + worldName + " ' " ) ;
2013-01-13 23:21:51 +01:00
}
2011-02-25 16:42:48 +01:00
}
2014-09-01 04:17:05 +02:00
private TargetMatcherSet getTargetMatchers ( String node ) {
TargetMatcherSet set = new TargetMatcherSet ( ) ;
List < String > inputs = parentConfig . getStringList ( node , null ) ;
2019-05-07 01:22:42 +02:00
if ( inputs = = null | | inputs . isEmpty ( ) ) {
2014-09-01 04:17:05 +02:00
parentConfig . setProperty ( node , new ArrayList < String > ( ) ) ;
2020-06-01 21:52:16 +02:00
}
if ( config . getProperty ( node ) ! = null ) {
inputs = config . getStringList ( node , null ) ;
}
if ( inputs = = null | | inputs . isEmpty ( ) ) {
2014-09-01 04:17:05 +02:00
return set ;
}
for ( String input : inputs ) {
try {
set . add ( matcherParser . fromInput ( input ) ) ;
} catch ( TargetMatcherParseException e ) {
log . warning ( " Failed to parse the block / item type specified as ' " + input + " ' " ) ;
}
}
return set ;
}
2011-02-25 16:42:48 +01:00
/ * *
* Load the configuration .
* /
2018-07-19 16:06:02 +02:00
@Override
public void loadConfiguration ( ) {
2012-01-24 01:45:52 +01:00
try {
config . load ( ) ;
2012-01-28 06:54:53 +01:00
} catch ( IOException e ) {
2019-05-07 01:22:42 +02:00
log . log ( Level . SEVERE , " Error reading configuration for world " + worldName + " : " , e ) ;
2020-08-16 08:55:19 +02:00
} catch ( YAMLException e ) {
2014-12-19 13:55:18 +01:00
log . severe ( " Error parsing configuration for world " + worldName + " . " ) ;
throw e ;
2012-01-28 06:54:53 +01:00
}
2011-04-03 11:48:32 +02:00
2022-02-27 23:51:52 +01:00
boolean needParentSave = false ;
2013-01-13 23:21:51 +01:00
summaryOnStart = getBoolean ( " summary-on-start " , true ) ;
2011-06-26 11:24:50 +02:00
opPermissions = getBoolean ( " op-permissions " , true ) ;
2014-08-25 00:53:45 +02:00
2014-08-24 11:03:38 +02:00
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. " ) ) ;
2011-06-26 11:24:50 +02:00
2014-09-01 04:17:05 +02:00
strictEntitySpawn = getBoolean ( " event-handling.block-entity-spawns-with-untraceable-cause " , false ) ;
allowAllInteract = getTargetMatchers ( " event-handling.interaction-whitelist " ) ;
2014-09-01 04:30:14 +02:00
blockUseAtFeet = getTargetMatchers ( " event-handling.emit-block-use-at-feet " ) ;
2017-10-14 20:41:58 +02:00
ignoreHopperMoveEvents = getBoolean ( " event-handling.ignore-hopper-item-move-events " , false ) ;
2020-06-24 16:42:12 +02:00
breakDeniedHoppers = getBoolean ( " event-handling.break-hoppers-on-denied-move " , true ) ;
2014-08-25 00:53:45 +02:00
2019-08-02 05:47:27 +02:00
usePaperEntityOrigin = getBoolean ( " regions.use-paper-entity-origin " , false ) ;
2011-06-26 11:24:50 +02:00
itemDurability = getBoolean ( " protection.item-durability " , true ) ;
removeInfiniteStacks = getBoolean ( " protection.remove-infinite-stacks " , false ) ;
2011-09-21 22:48:56 +02:00
disableExpDrops = getBoolean ( " protection.disable-xp-orb-drops " , false ) ;
2022-02-27 23:51:52 +01:00
needParentSave | = removeProperty ( " protection.disable-obsidian-generators " ) ;
2011-06-26 11:24:50 +02:00
2020-08-01 13:54:27 +02:00
useMaxPriorityAssociation = getBoolean ( " protection.use-max-priority-association " , false ) ;
2020-07-30 20:24:18 +02:00
2018-07-19 16:06:02 +02:00
blockPotions = new HashSet < > ( ) ;
2012-11-04 22:42:55 +01:00
for ( String potionName : getStringList ( " gameplay.block-potions " , null ) ) {
PotionEffectType effect = PotionEffectType . getByName ( potionName ) ;
if ( effect = = null ) {
2014-08-22 07:22:28 +02:00
log . warning ( " Unknown potion effect type ' " + potionName + " ' " ) ;
2012-11-04 22:42:55 +01:00
} else {
blockPotions . add ( effect ) ;
}
}
2012-11-04 23:46:36 +01:00
blockPotionsAlways = getBoolean ( " gameplay.block-potions-overly-reliably " , false ) ;
2019-01-02 05:25:43 +01:00
disableConduitEffects = getBoolean ( " gameplay.disable-conduit-effects " , false ) ;
2012-11-04 22:42:55 +01:00
2014-08-18 21:32:28 +02:00
simulateSponge = getBoolean ( " simulation.sponge.enable " , false ) ;
2011-06-26 11:24:50 +02:00
spongeRadius = Math . max ( 1 , getInt ( " simulation.sponge.radius " , 3 ) ) - 1 ;
redstoneSponges = getBoolean ( " simulation.sponge.redstone " , false ) ;
2022-02-27 22:34:27 +01:00
if ( simulateSponge ) {
log . warning ( " Sponge simulation is deprecated for removal in a future version. We recommend using CraftBook's sponge simulation instead. " ) ;
} else {
2022-02-27 23:51:52 +01:00
needParentSave | = removeProperty ( " simulation " ) ;
2022-02-27 22:34:27 +01:00
}
2011-06-26 11:24:50 +02:00
2011-09-26 05:31:21 +02:00
pumpkinScuba = getBoolean ( " default.pumpkin-scuba " , false ) ;
2011-06-27 04:16:00 +02:00
disableHealthRegain = getBoolean ( " default.disable-health-regain " , false ) ;
2011-06-26 11:24:50 +02:00
noPhysicsGravel = getBoolean ( " physics.no-physics-gravel " , false ) ;
noPhysicsSand = getBoolean ( " physics.no-physics-sand " , false ) ;
2012-11-05 20:32:40 +01:00
ropeLadders = getBoolean ( " physics.vine-like-rope-ladders " , false ) ;
2011-06-26 11:24:50 +02:00
allowPortalAnywhere = getBoolean ( " physics.allow-portal-anywhere " , false ) ;
2018-08-03 12:30:08 +02:00
preventWaterDamage = new HashSet < > ( convertLegacyBlocks ( getStringList ( " physics.disable-water-damage-blocks " , null ) ) ) ;
2011-06-26 11:24:50 +02:00
2011-08-10 02:37:15 +02:00
blockTNTExplosions = getBoolean ( " ignition.block-tnt " , false ) ;
blockTNTBlockDamage = getBoolean ( " ignition.block-tnt-block-damage " , false ) ;
2011-06-26 11:24:50 +02:00
blockLighter = getBoolean ( " ignition.block-lighter " , false ) ;
2019-06-15 17:31:40 +02:00
preventLavaFire = getBoolean ( " fire.disable-lava-fire-spread " , false ) ;
2011-06-26 11:24:50 +02:00
disableFireSpread = getBoolean ( " fire.disable-all-fire-spread " , false ) ;
2018-08-03 12:30:08 +02:00
disableFireSpreadBlocks = new HashSet < > ( convertLegacyBlocks ( getStringList ( " fire.disable-fire-spread-blocks " , null ) ) ) ;
allowedLavaSpreadOver = new HashSet < > ( convertLegacyBlocks ( getStringList ( " fire.lava-spread-blocks " , null ) ) ) ;
2011-06-26 11:24:50 +02:00
blockCreeperExplosions = getBoolean ( " mobs.block-creeper-explosions " , false ) ;
blockCreeperBlockDamage = getBoolean ( " mobs.block-creeper-block-damage " , false ) ;
2012-10-29 03:58:48 +01:00
blockWitherExplosions = getBoolean ( " mobs.block-wither-explosions " , false ) ;
2012-10-28 21:52:33 +01:00
blockWitherBlockDamage = getBoolean ( " mobs.block-wither-block-damage " , false ) ;
2012-10-29 03:58:48 +01:00
blockWitherSkullExplosions = getBoolean ( " mobs.block-wither-skull-explosions " , false ) ;
blockWitherSkullBlockDamage = getBoolean ( " mobs.block-wither-skull-block-damage " , false ) ;
2011-12-18 23:16:12 +01:00
blockEnderDragonBlockDamage = getBoolean ( " mobs.block-enderdragon-block-damage " , false ) ;
2012-11-24 08:17:34 +01:00
blockEnderDragonPortalCreation = getBoolean ( " mobs.block-enderdragon-portal-creation " , false ) ;
2011-08-20 07:58:46 +02:00
blockFireballExplosions = getBoolean ( " mobs.block-fireball-explosions " , false ) ;
2011-06-28 06:58:13 +02:00
blockFireballBlockDamage = getBoolean ( " mobs.block-fireball-block-damage " , false ) ;
2011-06-26 11:24:50 +02:00
antiWolfDumbness = getBoolean ( " mobs.anti-wolf-dumbness " , false ) ;
2013-08-20 20:58:46 +02:00
allowTamedSpawns = getBoolean ( " mobs.allow-tamed-spawns " , true ) ;
2011-09-18 02:49:03 +02:00
disableEndermanGriefing = getBoolean ( " mobs.disable-enderman-griefing " , false ) ;
2013-06-02 22:22:12 +02:00
disableSnowmanTrails = getBoolean ( " mobs.disable-snowman-trails " , false ) ;
2012-04-07 22:45:46 +02:00
blockEntityPaintingDestroy = getBoolean ( " mobs.block-painting-destroy " , false ) ;
2012-11-02 06:35:10 +01:00
blockEntityItemFrameDestroy = getBoolean ( " mobs.block-item-frame-destroy " , false ) ;
2016-12-23 05:38:28 +01:00
blockEntityArmorStandDestroy = getBoolean ( " mobs.block-armor-stand-destroy " , false ) ;
2012-07-01 22:02:24 +02:00
blockPluginSpawning = getBoolean ( " mobs.block-plugin-spawning " , true ) ;
2012-11-07 03:47:31 +01:00
blockGroundSlimes = getBoolean ( " mobs.block-above-ground-slimes " , false ) ;
2013-01-12 00:37:46 +01:00
blockOtherExplosions = getBoolean ( " mobs.block-other-explosions " , false ) ;
2013-01-12 04:02:15 +01:00
blockZombieDoorDestruction = getBoolean ( " mobs.block-zombie-door-destruction " , false ) ;
2020-12-31 01:51:49 +01:00
blockEntityVehicleEntry = getBoolean ( " mobs.block-vehicle-entry " , false ) ;
2011-06-26 11:24:50 +02:00
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 ) ;
2019-07-28 03:57:49 +02:00
safeFallOnVoid = getBoolean ( " player-damage.reset-fall-on-void-teleport " , false ) ;
2011-06-26 11:24:50 +02:00
disableExplosionDamage = getBoolean ( " player-damage.disable-explosion-damage " , false ) ;
disableMobDamage = getBoolean ( " player-damage.disable-mob-damage " , false ) ;
2011-09-21 22:48:56 +02:00
disableDeathMessages = getBoolean ( " player-damage.disable-death-messages " , false ) ;
2011-06-26 11:24:50 +02:00
signChestProtection = getBoolean ( " chest-protection.enable " , false ) ;
2022-03-24 15:01:17 +01:00
disableSignChestProtectionCheck = getBoolean ( " chest-protection.disable-off-check " , true ) ;
2022-02-27 22:34:27 +01:00
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 {
2022-02-27 23:51:52 +01:00
needParentSave | = removeProperty ( " chest-protection " ) ;
2022-02-27 22:34:27 +01:00
}
2011-06-26 11:24:50 +02:00
disableCreatureCropTrampling = getBoolean ( " crops.disable-creature-trampling " , false ) ;
disablePlayerCropTrampling = getBoolean ( " crops.disable-player-trampling " , false ) ;
2020-07-30 19:25:55 +02:00
disableCreatureTurtleEggTrampling = getBoolean ( " turtle-egg.disable-creature-trampling " , false ) ;
2020-07-30 19:22:17 +02:00
disablePlayerTurtleEggTrampling = getBoolean ( " turtle-egg.disable-player-trampling " , false ) ;
2023-06-08 21:38:37 +02:00
disableCreatureSnifferEggTrampling = getBoolean ( " sniffer-egg.disable-creature-trampling " , false ) ;
disablePlayerSnifferEggTrampling = getBoolean ( " sniffer-egg.disable-player-trampling " , false ) ;
2020-07-30 19:22:17 +02:00
2018-08-03 12:30:08 +02:00
disallowedLightningBlocks = new HashSet < > ( convertLegacyBlocks ( getStringList ( " weather.prevent-lightning-strike-blocks " , null ) ) ) ;
2011-06-26 11:24:50 +02:00
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 ) ;
2019-07-01 01:58:10 +02:00
disableVillagerZap = getBoolean ( " weather.disable-villager-witchification " , false ) ;
2011-06-26 11:24:50 +02:00
disableCreeperPower = getBoolean ( " weather.disable-powered-creepers " , false ) ;
alwaysRaining = getBoolean ( " weather.always-raining " , false ) ;
alwaysThundering = getBoolean ( " weather.always-thundering " , false ) ;
2011-06-27 05:34:18 +02:00
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 ) ;
2011-09-25 04:51:36 +02:00
disableGrassGrowth = getBoolean ( " dynamics.disable-grass-growth " , false ) ;
2012-11-03 23:31:16 +01:00
disableMyceliumSpread = getBoolean ( " dynamics.disable-mycelium-spread " , false ) ;
2013-01-30 20:02:45 +01:00
disableVineGrowth = getBoolean ( " dynamics.disable-vine-growth " , false ) ;
2021-11-25 18:32:24 +01:00
disableRockGrowth = getBoolean ( " dynamics.disable-rock-growth " , false ) ;
2022-06-11 16:47:44 +02:00
disableSculkGrowth = getBoolean ( " dynamics.disable-sculk-growth " , false ) ;
2019-05-28 02:42:17 +02:00
disableCropGrowth = getBoolean ( " dynamics.disable-crop-growth " , false ) ;
2013-08-13 00:06:31 +02:00
disableSoilDehydration = getBoolean ( " dynamics.disable-soil-dehydration " , false ) ;
2020-05-03 01:08:33 +02:00
disableCoralBlockFade = getBoolean ( " dynamics.disable-coral-block-fade " , false ) ;
2023-03-19 16:56:46 +01:00
disableCopperBlockFade = getBoolean ( " dynamics.disable-copper-block-fade " , false ) ;
2018-08-03 12:30:08 +02:00
allowedSnowFallOver = new HashSet < > ( convertLegacyBlocks ( getStringList ( " dynamics.snow-fall-blocks " , null ) ) ) ;
2011-06-27 05:34:18 +02:00
2011-06-26 11:24:50 +02:00
useRegions = getBoolean ( " regions.enable " , true ) ;
2011-06-27 22:41:27 +02:00
regionInvinciblityRemovesMobs = getBoolean ( " regions.invincibility-removes-mobs " , false ) ;
2019-03-04 23:44:54 +01:00
regionCancelEmptyChatEvents = getBoolean ( " regions.cancel-chat-without-recipients " , true ) ;
2020-02-15 19:31:38 +01:00
regionNetherPortalProtection = getBoolean ( " regions.nether-portal-protection " , true ) ;
2020-02-15 22:04:47 +01:00
forceDefaultTitleTimes = config . getBoolean ( " regions.titles-always-use-default-times " , true ) ; // note: technically not region-specific, but we only use it for the title flags
2014-08-23 04:32:03 +02:00
fakePlayerBuildOverride = getBoolean ( " regions.fake-player-build-override " , true ) ;
2013-09-12 01:07:20 +02:00
explosionFlagCancellation = getBoolean ( " regions.explosion-flags-block-entity-damage " , true ) ;
2011-06-26 11:24:50 +02:00
highFreqFlags = getBoolean ( " regions.high-frequency-flags " , false ) ;
2014-08-22 22:37:02 +02:00
checkLiquidFlow = getBoolean ( " regions.protect-against-liquid-flow " , false ) ;
2018-07-22 05:06:01 +02:00
regionWand = convertLegacyItem ( getString ( " regions.wand " , ItemTypes . LEATHER . getId ( ) ) ) ;
2011-06-26 11:24:50 +02:00
maxClaimVolume = getInt ( " regions.max-claim-volume " , 30000 ) ;
claimOnlyInsideExistingRegions = getBoolean ( " regions.claim-only-inside-existing-regions " , false ) ;
2022-01-02 16:07:00 +01:00
setParentOnClaim = getString ( " regions.set-parent-on-claim " , " " ) ;
2015-08-02 09:42:13 +02:00
boundedLocationFlags = getBoolean ( " regions.location-flags-only-inside-regions " , false ) ;
2012-04-07 22:45:46 +02:00
2011-12-04 09:54:33 +01:00
maxRegionCountPerPlayer = getInt ( " regions.max-region-count-per-player.default " , 7 ) ;
2018-07-19 16:06:02 +02:00
maxRegionCounts = new HashMap < > ( ) ;
2011-12-04 09:54:33 +01:00
maxRegionCounts . put ( null , maxRegionCountPerPlayer ) ;
2012-04-07 22:45:46 +02:00
2011-12-04 09:54:33 +01:00
for ( String key : getKeys ( " regions.max-region-count-per-player " ) ) {
if ( ! key . equalsIgnoreCase ( " default " ) ) {
Object val = getProperty ( " regions.max-region-count-per-player. " + key ) ;
2018-07-19 16:06:02 +02:00
if ( val instanceof Number ) {
2011-12-04 09:54:33 +01:00
maxRegionCounts . put ( key , ( ( Number ) val ) . intValue ( ) ) ;
}
}
}
2012-01-12 03:04:14 +01:00
2011-09-26 05:31:21 +02:00
// useiConomy = getBoolean("iconomy.enable", false);
// buyOnClaim = getBoolean("iconomy.buy-on-claim", false);
// buyOnClaimPrice = getDouble("iconomy.buy-on-claim-price", 1.0);
2011-02-25 17:28:08 +01:00
2018-07-19 16:06:02 +02:00
blockCreatureSpawn = new HashSet < > ( ) ;
2011-06-26 11:24:50 +02:00
for ( String creatureName : getStringList ( " mobs.block-creature-spawn " , null ) ) {
2018-08-15 04:49:25 +02:00
EntityType creature = EntityTypes . get ( creatureName . toLowerCase ( ) ) ;
2011-04-03 11:48:32 +02:00
2011-03-08 19:01:03 +01:00
if ( creature = = null ) {
2018-08-15 04:49:25 +02:00
log . warning ( " Unknown entity type ' " + creatureName + " ' " ) ;
2011-03-08 19:01:03 +01:00
} else {
blockCreatureSpawn . add ( creature ) ;
}
2011-02-25 16:42:48 +01:00
}
2011-06-26 11:24:50 +02:00
boolean useBlacklistAsWhitelist = getBoolean ( " blacklist.use-as-whitelist " , false ) ;
2011-02-27 17:48:07 +01:00
2011-02-25 16:42:48 +01:00
// Console log configuration
2011-06-26 11:24:50 +02:00
boolean logConsole = getBoolean ( " blacklist.logging.console.enable " , true ) ;
2011-02-25 16:42:48 +01:00
// Database log configuration
2011-06-26 11:24:50 +02:00
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 " ) ;
2011-02-25 16:42:48 +01:00
// File log configuration
2011-06-26 11:24:50 +02:00
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 ) ) ;
2011-02-25 16:42:48 +01:00
// 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
2018-07-19 16:06:02 +02:00
Blacklist blist = new Blacklist ( useBlacklistAsWhitelist ) ;
2011-02-25 16:42:48 +01:00
blist . load ( blacklistFile ) ;
// If the blacklist is empty, then set the field to null
// and save some resources
if ( blist . isEmpty ( ) ) {
this . blacklist = null ;
} else {
this . blacklist = blist ;
2013-01-13 23:21:51 +01:00
if ( summaryOnStart ) {
2019-04-20 05:14:14 +02:00
log . log ( Level . INFO , " ({0}) Blacklist loaded with {1} entries. " ,
new Object [ ] { worldName , blacklist . getItemCount ( ) } ) ;
2013-01-13 23:21:51 +01:00
}
2011-02-25 16:42:48 +01:00
2014-07-29 00:58:07 +02:00
BlacklistLoggerHandler blacklistLogger = blist . getLogger ( ) ;
2011-02-25 16:42:48 +01:00
if ( logDatabase ) {
2014-08-22 07:22:28 +02:00
blacklistLogger . addHandler ( new DatabaseHandler ( dsn , user , pass , table , worldName , log ) ) ;
2011-02-25 16:42:48 +01:00
}
if ( logConsole ) {
2014-08-22 07:22:28 +02:00
blacklistLogger . addHandler ( new ConsoleHandler ( worldName , log ) ) ;
2011-02-25 16:42:48 +01:00
}
if ( logFile ) {
2014-07-28 23:37:52 +02:00
FileHandler handler =
2014-08-22 07:22:28 +02:00
new FileHandler ( logFilePattern , logFileCacheSize , worldName , log ) ;
2011-02-25 16:42:48 +01:00
blacklistLogger . addHandler ( handler ) ;
}
}
} catch ( FileNotFoundException e ) {
2014-08-22 07:22:28 +02:00
log . log ( Level . WARNING , " WorldGuard blacklist does not exist. " ) ;
2011-02-25 16:42:48 +01:00
} catch ( IOException e ) {
2014-08-22 07:22:28 +02:00
log . log ( Level . WARNING , " Could not load WorldGuard blacklist: "
2011-02-25 16:42:48 +01:00
+ e . getMessage ( ) ) ;
}
// Print an overview of settings
2013-01-13 23:21:51 +01:00
if ( summaryOnStart ) {
2014-08-22 07:22:28 +02:00
log . log ( Level . INFO , blockTNTExplosions
2012-02-11 20:51:57 +01:00
? " ( " + worldName + " ) TNT ignition is blocked. "
: " ( " + worldName + " ) TNT ignition is PERMITTED. " ) ;
2014-08-22 07:22:28 +02:00
log . log ( Level . INFO , blockLighter
2012-02-11 20:51:57 +01:00
? " ( " + worldName + " ) Lighters are blocked. "
: " ( " + worldName + " ) Lighters are PERMITTED. " ) ;
2014-08-22 07:22:28 +02:00
log . log ( Level . INFO , preventLavaFire
2012-02-11 20:51:57 +01:00
? " ( " + worldName + " ) Lava fire is blocked. "
: " ( " + worldName + " ) Lava fire is PERMITTED. " ) ;
2011-04-03 11:48:32 +02:00
2011-02-25 16:42:48 +01:00
if ( disableFireSpread ) {
2014-08-22 07:22:28 +02:00
log . log ( Level . INFO , " ( " + worldName + " ) All fire spread is disabled. " ) ;
2011-02-25 16:42:48 +01:00
} else {
2019-05-07 01:22:42 +02:00
if ( ! disableFireSpreadBlocks . isEmpty ( ) ) {
2014-08-22 07:22:28 +02:00
log . log ( Level . INFO , " ( " + worldName
2011-03-08 19:01:03 +01:00
+ " ) Fire spread is limited to "
2011-02-25 16:42:48 +01:00
+ disableFireSpreadBlocks . size ( ) + " block types. " ) ;
} else {
2014-08-22 07:22:28 +02:00
log . log ( Level . INFO , " ( " + worldName
2011-03-08 19:01:03 +01:00
+ " ) Fire spread is UNRESTRICTED. " ) ;
2011-02-25 16:42:48 +01:00
}
}
}
2011-06-26 11:24:50 +02:00
2012-02-21 00:14:55 +01:00
config . setHeader ( CONFIG_HEADER ) ;
2011-06-27 05:59:40 +02:00
2011-06-26 11:24:50 +02:00
config . save ( ) ;
2022-02-27 23:51:52 +01:00
if ( needParentSave ) {
parentConfig . save ( ) ;
}
}
private boolean removeProperty ( String prop ) {
if ( config . getProperty ( prop ) ! = null ) {
config . removeProperty ( prop ) ;
}
if ( parentConfig . getProperty ( prop ) ! = null ) {
parentConfig . removeProperty ( prop ) ;
return true ;
}
return false ;
2011-02-25 16:42:48 +01:00
}
2011-03-08 19:01:03 +01:00
2018-07-19 16:06:02 +02:00
public boolean isChestProtected ( Location block , LocalPlayer player ) {
2011-04-11 19:13:42 +02:00
if ( ! signChestProtection ) {
return false ;
}
2018-07-19 16:06:02 +02:00
if ( player . hasPermission ( " worldguard.chest-protection.override " )
| | player . hasPermission ( " worldguard.override.chest-protection " ) ) {
2011-04-11 19:13:42 +02:00
return false ;
}
return chestProtection . isProtected ( block , player ) ;
}
2011-09-27 12:13:19 +02:00
2018-07-19 16:06:02 +02:00
public boolean isChestProtected ( Location block ) {
2012-11-03 05:19:20 +01:00
return signChestProtection & & chestProtection . isProtected ( block , null ) ;
2011-04-11 19:13:42 +02:00
}
2011-09-27 12:13:19 +02:00
2018-07-19 16:06:02 +02:00
public boolean isChestProtectedPlacement ( Location block , LocalPlayer player ) {
2011-05-04 10:24:38 +02:00
if ( ! signChestProtection ) {
return false ;
}
2018-07-19 16:06:02 +02:00
if ( player . hasPermission ( " worldguard.chest-protection.override " )
| | player . hasPermission ( " worldguard.override.chest-protection " ) ) {
2011-05-04 10:24:38 +02:00
return false ;
}
return chestProtection . isProtectedPlacement ( block , player ) ;
}
2011-02-25 16:42:48 +01:00
2018-07-19 16:06:02 +02:00
public boolean isAdjacentChestProtected ( Location block , LocalPlayer player ) {
2011-05-20 06:13:07 +02:00
if ( ! signChestProtection ) {
return false ;
}
2018-07-19 16:06:02 +02:00
if ( player . hasPermission ( " worldguard.chest-protection.override " )
| | player . hasPermission ( " worldguard.override.chest-protection " ) ) {
2011-05-20 06:13:07 +02:00
return false ;
}
return chestProtection . isAdjacentChestProtected ( block , player ) ;
}
2011-05-20 17:41:48 +02:00
public ChestProtection getChestProtection ( ) {
2011-05-20 06:13:07 +02:00
return chestProtection ;
}
2012-04-07 22:45:46 +02:00
2011-02-25 16:42:48 +01:00
}