Search in sources :

Example 1 with ConfigurationManager

use of com.sk89q.worldguard.config.ConfigurationManager in project WorldGuard by EngineHub.

the class RegionContainer method autoMigrate.

/**
 * Execute auto-migration.
 */
protected void autoMigrate() {
    ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
    if (config.migrateRegionsToUuid) {
        RegionDriver driver = getDriver();
        UUIDMigration migrator = new UUIDMigration(driver, WorldGuard.getInstance().getProfileService(), WorldGuard.getInstance().getFlagRegistry());
        migrator.setKeepUnresolvedNames(config.keepUnresolvedNames);
        try {
            migrate(migrator);
            WorldGuard.logger.info("Regions saved after UUID migration! This won't happen again unless " + "you change the relevant configuration option in WorldGuard's config.");
            config.disableUuidMigration();
        } catch (MigrationException e) {
            WorldGuard.logger.log(Level.WARNING, "Failed to execute the migration", e);
        }
    }
}
Also used : MigrationException(com.sk89q.worldguard.protection.managers.migration.MigrationException) RegionDriver(com.sk89q.worldguard.protection.managers.storage.RegionDriver) ConfigurationManager(com.sk89q.worldguard.config.ConfigurationManager) UUIDMigration(com.sk89q.worldguard.protection.managers.migration.UUIDMigration)

Example 2 with ConfigurationManager

use of com.sk89q.worldguard.config.ConfigurationManager in project WorldGuard by EngineHub.

the class RegionContainer method initialize.

/**
 * Initialize the region container.
 */
public void initialize() {
    ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
    container = new RegionContainerImpl(config.selectedRegionStoreDriver, WorldGuard.getInstance().getFlagRegistry());
    loadWorlds();
    // Migrate to UUIDs
    autoMigrate();
}
Also used : RegionContainerImpl(com.sk89q.worldguard.protection.managers.RegionContainerImpl) ConfigurationManager(com.sk89q.worldguard.config.ConfigurationManager)

Example 3 with ConfigurationManager

use of com.sk89q.worldguard.config.ConfigurationManager in project WorldGuard by EngineHub.

the class Session method initialize.

/**
 * Initialize the session.
 *
 * @param player The player
 */
public void initialize(LocalPlayer player) {
    RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
    Location location = player.getLocation();
    ApplicableRegionSet set = query.getApplicableRegions(location);
    lastValid = location;
    lastRegionSet = set.getRegions();
    ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
    disableBypass = cfg.disableDefaultBypass;
    if (cfg.announceBypassStatus && player.hasPermission("worldguard.region.toggle-bypass")) {
        player.printInfo(TextComponent.of("You are " + (disableBypass ? "not" : "") + " bypassing region protection. " + "You can toggle this with /rg bypass", TextColor.DARK_PURPLE));
    }
    for (Handler handler : handlers.values()) {
        handler.initialize(player, location, set);
    }
}
Also used : RegionQuery(com.sk89q.worldguard.protection.regions.RegionQuery) Handler(com.sk89q.worldguard.session.handler.Handler) ConfigurationManager(com.sk89q.worldguard.config.ConfigurationManager) Location(com.sk89q.worldedit.util.Location) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Example 4 with ConfigurationManager

use of com.sk89q.worldguard.config.ConfigurationManager in project WorldGuard by EngineHub.

the class WorldGuardBlockListener method onBlockExplode.

@EventHandler(ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent event) {
    ConfigurationManager cfg = getConfig();
    if (cfg.activityHaltToggle) {
        event.setCancelled(true);
        return;
    }
    WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
    if (wcfg.blockOtherExplosions) {
        event.setCancelled(true);
    }
}
Also used : BukkitWorldConfiguration(com.sk89q.worldguard.bukkit.BukkitWorldConfiguration) WorldConfiguration(com.sk89q.worldguard.config.WorldConfiguration) ConfigurationManager(com.sk89q.worldguard.config.ConfigurationManager) EventHandler(org.bukkit.event.EventHandler)

Example 5 with ConfigurationManager

use of com.sk89q.worldguard.config.ConfigurationManager in project WorldGuard by EngineHub.

the class WorldGuardBlockListener method onLeavesDecay.

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onLeavesDecay(LeavesDecayEvent event) {
    ConfigurationManager cfg = getConfig();
    if (cfg.activityHaltToggle) {
        event.setCancelled(true);
        return;
    }
    WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
    if (wcfg.disableLeafDecay) {
        event.setCancelled(true);
        return;
    }
    if (wcfg.useRegions) {
        if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.LEAF_DECAY))) {
            event.setCancelled(true);
        }
    }
}
Also used : BukkitWorldConfiguration(com.sk89q.worldguard.bukkit.BukkitWorldConfiguration) WorldConfiguration(com.sk89q.worldguard.config.WorldConfiguration) ConfigurationManager(com.sk89q.worldguard.config.ConfigurationManager) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ConfigurationManager (com.sk89q.worldguard.config.ConfigurationManager)26 EventHandler (org.bukkit.event.EventHandler)18 BukkitWorldConfiguration (com.sk89q.worldguard.bukkit.BukkitWorldConfiguration)13 WorldConfiguration (com.sk89q.worldguard.config.WorldConfiguration)13 LocalPlayer (com.sk89q.worldguard.LocalPlayer)10 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)6 Player (org.bukkit.entity.Player)6 Command (com.sk89q.minecraft.util.commands.Command)4 Material (org.bukkit.Material)4 World (org.bukkit.World)4 Block (org.bukkit.block.Block)4 Entity (org.bukkit.entity.Entity)4 CommandException (com.sk89q.minecraft.util.commands.CommandException)3 RegionAssociable (com.sk89q.worldguard.protection.association.RegionAssociable)3 MigrationException (com.sk89q.worldguard.protection.managers.migration.MigrationException)3 RegionDriver (com.sk89q.worldguard.protection.managers.storage.RegionDriver)3 LoggerToChatHandler (com.sk89q.worldguard.util.logging.LoggerToChatHandler)3 Logger (java.util.logging.Logger)3 HumanEntity (org.bukkit.entity.HumanEntity)3 CommandPermissions (com.sk89q.minecraft.util.commands.CommandPermissions)2