use of com.sk89q.worldguard.protection.managers.storage.StorageException in project TARDIS by eccentricdevotion.
the class TARDISWorldGuardUtils method removeRegion.
/**
* Removes the WorldGuard region when the TARDIS is deleted.
*
* @param world the world the region is located in
* @param name the player's name
*/
public void removeRegion(World world, String name) {
RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(world));
Set<ProtectedRegion> regions = rm.removeRegion("TARDIS_" + name);
if (regions.size() == 0 && TARDISFloodgate.isFloodgateEnabled()) {
// try sanitised name
rm.removeRegion("TARDIS_" + TARDISFloodgate.sanitisePlayerName(name));
}
try {
rm.save();
} catch (StorageException e) {
plugin.getLogger().log(Level.INFO, "Could not remove WorldGuard Protection for TARDIS! " + e.getMessage());
}
}
use of com.sk89q.worldguard.protection.managers.storage.StorageException in project TARDIS by eccentricdevotion.
the class TARDISWorldGuardUtils method addWGProtection.
/**
* Adds a WorldGuard protected region for a TIPS slot. This stops other players and mobs from griefing the TARDIS
* :)
*
* @param name the player to assign as the owner of the region
* @param data a TIPS Data container
* @param world the world we are creating the region in
*/
public void addWGProtection(UUID uuid, String name, TARDISTIPSData data, World world) {
RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(world));
BlockVector3 b1 = BlockVector3.at(data.getMinX(), 0, data.getMinZ());
BlockVector3 b2 = BlockVector3.at(data.getMaxX(), 256, data.getMaxZ());
String region_id = "TARDIS_" + name;
ProtectedCuboidRegion region = new ProtectedCuboidRegion(region_id, b1, b2);
DefaultDomain dd = new DefaultDomain();
dd.addPlayer(uuid);
region.setOwners(dd);
HashMap<Flag<?>, Object> flags = new HashMap<>();
if (name.length() != 36 && !plugin.getConfig().getBoolean("preferences.open_door_policy")) {
flags.put(Flags.ENTRY, State.DENY);
}
flags.put(Flags.FIRE_SPREAD, State.DENY);
flags.put(Flags.LAVA_FIRE, State.DENY);
flags.put(Flags.LAVA_FLOW, State.DENY);
flags.put(Flags.LIGHTER, State.DENY);
flags.put(Flags.USE, State.ALLOW);
region.setFlags(flags);
rm.addRegion(region);
// deny exit to all
// usage = "<id> <flag> [-w world] [-g group] [value]",
plugin.getServer().dispatchCommand(plugin.getConsole(), "rg flag " + region_id + " exit -w " + world.getName() + " deny");
try {
rm.save();
} catch (StorageException e) {
plugin.getLogger().log(Level.INFO, "Could not create WorldGuard Protection for TARDIS! " + e.getMessage());
}
}
use of com.sk89q.worldguard.protection.managers.storage.StorageException in project TARDIS by eccentricdevotion.
the class TARDISWorldGuardUtils method removeRechargerRegion.
/**
* Removes the WorldGuard region when the recharger is removed.
*
* @param name the name of the recharger to remove
*/
public void removeRechargerRegion(String name) {
World w = TARDISAliasResolver.getWorldFromAlias(plugin.getConfig().getString("rechargers." + name + ".world"));
RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(w));
rm.removeRegion("tardis_recharger_" + name);
try {
rm.save();
} catch (StorageException e) {
plugin.getLogger().log(Level.INFO, "Could not remove recharger WorldGuard Protection for recharger! " + e.getMessage());
}
}
use of com.sk89q.worldguard.protection.managers.storage.StorageException in project TARDIS by eccentricdevotion.
the class TARDISWorldGuardUtils method unlockContainers.
/**
* Sets a player's CHEST_ACCESS flag to ALLOW in their TARDIS region.
*
* @param world the world the region is located in
* @param owner the player whose region it is
*/
public void unlockContainers(World world, String owner) {
RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(world));
ProtectedRegion region = null;
if (rm.hasRegion("TARDIS_" + owner)) {
region = rm.getRegion("TARDIS_" + owner);
} else if (TARDISFloodgate.isFloodgateEnabled()) {
String sanitised = TARDISFloodgate.sanitisePlayerName(owner);
if (rm.hasRegion("TARDIS_" + sanitised)) {
region = rm.getRegion("TARDIS_" + sanitised);
}
}
if (region != null) {
region.setFlag(Flags.CHEST_ACCESS, State.ALLOW);
region.setFlag(Flags.CHEST_ACCESS.getRegionGroupFlag(), RegionGroup.ALL);
try {
rm.save();
} catch (StorageException e) {
plugin.getLogger().log(Level.INFO, "Could not set WorldGuard CHEST_ACCESS flag to ALLOW! " + e.getMessage());
}
}
}
use of com.sk89q.worldguard.protection.managers.storage.StorageException in project TARDIS by eccentricdevotion.
the class TARDISWorldGuardUtils method addWGProtection.
/**
* Adds a WorldGuard protected region for a TIPS slot. This stops other players and mobs from griefing the TARDIS
* :)
*
* @param player the player to assign as the owner of the region
* @param data a TIPS Data container
* @param world the world we are creating the region in
*/
public void addWGProtection(Player player, TARDISTIPSData data, World world, boolean junk) {
RegionManager rm = wg.getRegionContainer().get(new BukkitWorld(world));
BlockVector3 b1 = BlockVector3.at(data.getMinX(), 0, data.getMinZ());
BlockVector3 b2 = BlockVector3.at(data.getMaxX(), 256, data.getMaxZ());
UUID uuid;
String name;
if (junk) {
uuid = UUID.fromString("00000000-aaaa-bbbb-cccc-000000000000");
name = "junk";
} else {
uuid = player.getUniqueId();
// check floodgate for region name
name = (TARDISFloodgate.isFloodgateEnabled() && TARDISFloodgate.isBedrockPlayer(player.getUniqueId())) ? TARDISFloodgate.sanitisePlayerName(player.getName()) : player.getName();
}
String region_id = "TARDIS_" + name;
ProtectedCuboidRegion region = new ProtectedCuboidRegion(region_id, b1, b2);
DefaultDomain dd = new DefaultDomain();
dd.addPlayer(uuid);
region.setOwners(dd);
HashMap<Flag<?>, Object> flags = new HashMap<>();
if (!junk && !plugin.getConfig().getBoolean("preferences.open_door_policy")) {
flags.put(Flags.ENTRY, State.DENY);
}
flags.put(Flags.FIRE_SPREAD, State.DENY);
flags.put(Flags.LAVA_FIRE, State.DENY);
flags.put(Flags.LAVA_FLOW, State.DENY);
flags.put(Flags.LIGHTER, State.DENY);
flags.put(Flags.USE, State.ALLOW);
region.setFlags(flags);
rm.addRegion(region);
if (!junk) {
// deny exit to all
// usage = "<id> <flag> [-w world] [-g group] [value]",
plugin.getServer().dispatchCommand(plugin.getConsole(), "rg flag " + region_id + " exit -w " + world.getName() + " deny");
}
try {
rm.save();
} catch (StorageException e) {
plugin.getLogger().log(Level.INFO, "Could not create WorldGuard Protection for TARDIS! " + e.getMessage());
}
}
Aggregations