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;
}
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!");
}
}
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!");
}
}
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!");
}
}
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!");
}
}
Aggregations