use of com.sk89q.worldguard.protection.regions.RegionContainer 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.sk89q.worldguard.protection.regions.RegionContainer 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.sk89q.worldguard.protection.regions.RegionContainer 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.sk89q.worldguard.protection.regions.RegionContainer 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!");
}
}
use of com.sk89q.worldguard.protection.regions.RegionContainer in project EliteMobs by MagmaGuy.
the class WorldGuardCompatibility method protectMinidungeonArea.
public static boolean protectMinidungeonArea(String regionName, Location location, Minidungeon minidungeon) {
try {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = container.get(BukkitAdapter.adapt(location.getWorld()));
ProtectedRegion protectedRegion = regions.getRegion(regionName);
if (protectedRegion == null) {
new WarningMessage("The region name picked did not exist!");
return false;
}
protectMinidungeonArea(protectedRegion, minidungeon);
return true;
} catch (Exception ex) {
new WarningMessage("Failed to protect region " + regionName + " !");
return false;
}
}
Aggregations