Search in sources :

Example 31 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method initialize.

public static boolean initialize() {
    // Enable WorldGuard
    if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null)
        return false;
    Bukkit.getLogger().info("[EliteMobs] WorldGuard detected.");
    FlagRegistry registry = null;
    try {
        registry = WorldGuard.getInstance().getFlagRegistry();
    } catch (Exception ex) {
        new WarningMessage("Something went wrong while loading WorldGuard. Are you using the right WorldGuard version?");
        return false;
    }
    Bukkit.getLogger().info("[EliteMobs] Enabling flags:");
    try {
        ELITEMOBS_SPAWN_FLAG = new StateFlag("elitemob-spawning", true);
        registry.register(ELITEMOBS_SPAWN_FLAG);
        Bukkit.getLogger().info("[EliteMobs] - elitemob-spawning");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-spawning already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_SPAWN_FLAG = (StateFlag) registry.get("elitemob-spawning");
    }
    try {
        ELITEMOBS_ONLY_SPAWN_FLAG = new StateFlag("elitemob-only-spawning", false);
        registry.register(ELITEMOBS_ONLY_SPAWN_FLAG);
        Bukkit.getLogger().info("[EliteMobs] - elitemob-only-spawning");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-only-spawning already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_ONLY_SPAWN_FLAG = (StateFlag) registry.get("elitemob-only-spawning");
    }
    try {
        ELITEMOBS_ANTIEXPLOIT = new StateFlag("elitemobs-antiexploit", true);
        registry.register(ELITEMOBS_ANTIEXPLOIT);
        Bukkit.getLogger().info("[EliteMobs] - elitemobs-antiexploit");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-antiexploit already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_ANTIEXPLOIT = (StateFlag) registry.get("elitemobs-antiexploit");
    }
    try {
        ELITEMOBS_DUNGEON = new StateFlag("elitemobs-dungeon", false);
        registry.register(ELITEMOBS_DUNGEON);
        Bukkit.getLogger().info("[EliteMobs] - elitemobs-dungeon");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-dungeon already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_DUNGEON = (StateFlag) registry.get("elitemobs-dungeon");
    }
    try {
        ELITEMOBS_EVENTS = new StateFlag("elitemobs-events", true);
        registry.register(ELITEMOBS_EVENTS);
        Bukkit.getLogger().info("[EliteMobs] - elitemobs-events");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-events already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_EVENTS = (StateFlag) registry.get("elitemobs-events");
    }
    try {
        ELITEMOBS_MINIMUM_LEVEL = new IntegerFlag("elitemobs-minimum-level");
        registry.register(ELITEMOBS_MINIMUM_LEVEL);
        Bukkit.getLogger().info("[EliteMobs] - elitemobs-minimum-level");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-minimum-level already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_MINIMUM_LEVEL = (IntegerFlag) registry.get("elitemobs-minimum-level");
    }
    try {
        ELITEMOBS_MAXIMUM_LEVEL = new IntegerFlag("elitemobs-maximum-level");
        registry.register(ELITEMOBS_MAXIMUM_LEVEL);
        Bukkit.getLogger().info("[EliteMobs] - elitemobs-maximum-level");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-maximum-level already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_MAXIMUM_LEVEL = (IntegerFlag) registry.get("elitemobs-maximum-level");
    }
    try {
        ELITEMOBS_EXPLOSION_REGEN = new StateFlag("elitemobs-explosion-regen", true);
        registry.register(ELITEMOBS_EXPLOSION_REGEN);
        Bukkit.getLogger().info("[EliteMobs] - elitemobs-explosion-regen");
    } catch (FlagConflictException | IllegalStateException e) {
        Bukkit.getLogger().warning("[EliteMobs] Warning: flag elitemob-explosion-regen already exists! This is normal if you've just now reloaded EliteMobs.");
        ELITEMOBS_EXPLOSION_REGEN = (StateFlag) registry.get("elitemobs-explosion-regen");
    }
    return true;
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException) FlagRegistry(com.sk89q.worldguard.protection.flags.registry.FlagRegistry) StateFlag(com.sk89q.worldguard.protection.flags.StateFlag) IntegerFlag(com.sk89q.worldguard.protection.flags.IntegerFlag) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Example 32 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method protectWorldMinidugeonArea.

public static void protectWorldMinidugeonArea(Location location, Minidungeon minidungeon) {
    try {
        RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regions = container.get(BukkitAdapter.adapt(location.getWorld()));
        ProtectedRegion global = regions.getRegion("__global__");
        if (global == null) {
            // But we want a __global__, so let's create one
            global = new GlobalProtectedRegion("__global__");
            regions.addRegion(global);
        }
        protectMinidungeonArea(global, minidungeon);
        DefaultDomain members = global.getMembers();
        members.addPlayer(UUID.fromString("198c4123-cafc-45df-ba79-02a421eb8ce7"));
        global.setOwners(members);
    } catch (Exception ex) {
        new WarningMessage("Failed to protect minidungeon world area!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) DefaultDomain(com.sk89q.worldguard.domains.DefaultDomain) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Example 33 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method protectWorldMinidugeonArea.

public static void protectWorldMinidugeonArea(Location location) {
    try {
        RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regions = container.get(BukkitAdapter.adapt(location.getWorld()));
        ProtectedRegion global = regions.getRegion("__global__");
        if (global == null) {
            // But we want a __global__, so let's create one
            global = new GlobalProtectedRegion("__global__");
            regions.addRegion(global);
        }
        protectMinidungeonArea(global);
        DefaultDomain members = global.getMembers();
        members.addPlayer(UUID.fromString("198c4123-cafc-45df-ba79-02a421eb8ce7"));
        global.setOwners(members);
    } catch (Exception ex) {
        new WarningMessage("Failed to protect minidungeon world area!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) DefaultDomain(com.sk89q.worldguard.domains.DefaultDomain) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Example 34 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method defineMinidungeon.

/**
 * Automatically creates a worldguard region protected as an EliteMobs minidungeon using two x y z vectors for the
 * locations of the diagonally opposed locations
 *
 * @param corner1
 * @param corner2
 */
public static void defineMinidungeon(Location corner1, Location corner2, Location anchorLocation, String schematicName, Minidungeon minidungeon) {
    try {
        RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regionManager = regionContainer.get(BukkitAdapter.adapt(anchorLocation.getWorld()));
        BlockVector3 min = BlockVector3.at(corner1.getBlockX(), corner1.getBlockY(), corner1.getBlockZ());
        BlockVector3 max = BlockVector3.at(corner2.getBlockX(), corner2.getBlockY(), corner2.getBlockZ());
        ProtectedRegion region = new ProtectedCuboidRegion(schematicName.replace(".schem", ""), min, max);
        protectMinidungeonArea(region, minidungeon);
        regionManager.addRegion(region);
    } catch (Exception ex) {
        new WarningMessage("Failed to add Minidungeon WorldGuard zone!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) GlobalProtectedRegion(com.sk89q.worldguard.protection.regions.GlobalProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ProtectedCuboidRegion(com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion) BlockVector3(com.sk89q.worldedit.math.BlockVector3) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Example 35 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class WorldGuardCompatibility method removeMinidungeon.

public static void removeMinidungeon(String schematicName, Location anchorLocation) {
    try {
        RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
        RegionManager regionManager = regionContainer.get(BukkitAdapter.adapt(anchorLocation.getWorld()));
        regionManager.removeRegion(schematicName.replace(".schem", ""));
    } catch (Exception ex) {
        new WarningMessage("Failed to remove Minidungeon WorldGuard zone!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) FlagConflictException(com.sk89q.worldguard.protection.flags.registry.FlagConflictException)

Aggregations

WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)76 InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)11 Vector (org.bukkit.util.Vector)11 Item (org.bukkit.entity.Item)10 File (java.io.File)9 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)8 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)7 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 ArrayList (java.util.ArrayList)6 ZipFile (com.magmaguy.elitemobs.utils.ZipFile)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)5 Location (org.bukkit.Location)5 ItemStack (org.bukkit.inventory.ItemStack)5 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)3 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)3 IOException (java.io.IOException)3 Material (org.bukkit.Material)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3