本文整理匯總了Java中com.sk89q.worldguard.protection.managers.RegionManager.save方法的典型用法代碼示例。如果您正苦於以下問題:Java RegionManager.save方法的具體用法?Java RegionManager.save怎麽用?Java RegionManager.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sk89q.worldguard.protection.managers.RegionManager
的用法示例。
在下文中一共展示了RegionManager.save方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
RegionManager regionManager = WGBukkit.getRegionManager(world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
regionManager.removeRegion(name, RemovalStrategy.REMOVE_CHILDREN);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: addMembers
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
/**
* Adds a list of members to a region.
*
* @param world World were the region is.
* @param regionName The ID of the region.
* @param playerNames Players to be added.
* @return true on succes, false on failure.
*/
public boolean addMembers(World world, String regionName, String[] playerNames) {
RegionManager rm = wgp.getRegionManager(world);
if (rm == null) {
return false;
}
ProtectedRegion region = rm.getRegion(regionName);
if (region == null) {
return false;
}
DefaultDomain members = region.getMembers();
for (String playerName : playerNames) {
members.addPlayer(playerName);
}
region.setMembers(members);
try {
rm.save();
} catch (ProtectionDatabaseException ex) {
plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
return false;
}
return true;
}
示例3: removeMembers
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
/**
* Removes a list of members from a region.
*
* @param world World were the region is.
* @param regionName The ID of the region.
* @param playerNames Players to be added.
* @return true on succes, false on failure.
*/
public boolean removeMembers(World world, String regionName, String[] playerNames) {
RegionManager rm = wgp.getRegionManager(world);
if (rm == null) {
return false;
}
ProtectedRegion region = rm.getRegion(regionName);
if (region == null) {
return false;
}
DefaultDomain members = region.getMembers();
for (String playerName : playerNames) {
members.removePlayer(playerName);
}
region.setMembers(members);
try {
rm.save();
} catch (ProtectionDatabaseException ex) {
plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
return false;
}
return true;
}
示例4: execute
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
Location loc1 = (Location) this.loc1.getSingle(event);
Location loc2 = (Location) this.loc2.getSingle(event);
World world = (World) this.world.getSingle(event);
int x1 = loc1.getBlockX();
int y1 = loc1.getBlockY();
int z1 = loc1.getBlockZ();
int x2 = loc2.getBlockX();
int y2 = loc2.getBlockY();
int z2 = loc2.getBlockZ();
Vector p1 = new Vector(x1, y1, z1);
Vector p2 = new Vector(x2, y2, z2);
RegionManager regionManager = WGBukkit.getRegionManager(world);
ProtectedCuboidRegion region = new ProtectedCuboidRegion(name, p1.toBlockVector(), p2.toBlockVector());
regionManager.addRegion(region);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: saveWorldGuardRegions
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
/**
* Save all worldGuard regions that need saving.
*/
public void saveWorldGuardRegions() {
for(String world : worldRegionsRequireSaving) {
World bukkitWorld = Bukkit.getWorld(world);
if(bukkitWorld != null) {
RegionManager manager = plugin.getWorldGuard().getRegionManager(bukkitWorld);
if(manager != null) {
try {
if(plugin.getWorldGuard().getDescription().getVersion().startsWith("5.")) {
manager.save();
} else {
manager.saveChanges();
}
} catch(Exception e) {
AreaShop.warn("WorldGuard regions in world " + world + " could not be saved");
}
}
}
}
}
示例6: deletarTerreno
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
public static void deletarTerreno(String player, String nome) {
World w = TerrenosManager.getTerrenoWorld(player, nome);
RegionManager rm = wg.getRegionManager(w);
ProtectedRegion terreno = TerrenosManager.getTerreno(player, nome);
delTerreno(w, terreno.getMinimumPoint(),terreno.getMaximumPoint());
rm.removeRegion(player.toLowerCase() + "-" + nome);
FilesManager.getDataFile().set(player.toLowerCase() + "." + nome.toLowerCase(), null);
FilesManager.saveDataFile();
try {
rm.save();
} catch (Exception e) {
Utils.logError("Ocorreu um erro ao salvar os terrenos");
e.printStackTrace();
}
}
示例7: removeProtection
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
public boolean removeProtection(World world, ProtectedRegion pr) {
RegionManager rm = wgp.getRegionManager(world);
rm.removeRegion(pr.getId());
try {
rm.save();
} catch (ProtectionDatabaseException ex) {
plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
return false;
}
return true;
}
示例8: execute
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
if (world == null) {
for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
if (b.getKey().equals(name)) {
world = Bukkit.getWorld(a.getName());
break;
}
}
}
}
RegionManager regionManager = WGBukkit.getRegionManager(world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
DefaultDomain members = regionManager.getRegion(name).getMembers();
Object[] arrayOfObject;
int j = (arrayOfObject = this.players.getArray(event)).length;
for (int i = 0; i < j; i++) {
Object o = arrayOfObject[i];
if ((o instanceof Player)) {
if (mark == -1) {
members.addPlayer(((Player) o).getName());
} else if (mark == 1) {
members.addPlayer(((Player) o).getUniqueId());
} else if (mark == 0) {
members.addPlayer(((Player) o).getName());
}
} else if ((o instanceof OfflinePlayer)) {
if (mark == -1) {
members.addPlayer(((OfflinePlayer) o).getName());
} else if (mark == 1) {
members.addPlayer(((OfflinePlayer) o).getUniqueId());
} else if (mark == 0) {
members.addPlayer(((OfflinePlayer) o).getName());
}
} else {
members.addPlayer(o.toString());
}
}
regionManager.getRegion(name).setMembers(members);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: execute
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
if (world == null) {
for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
if (b.getKey().equals(name)) {
world = Bukkit.getWorld(a.getName());
break;
}
}
}
}
RegionManager regionManager = WGBukkit.getRegionManager(world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
DefaultDomain owners = regionManager.getRegion(name).getOwners();
Object[] arrayOfObject;
int j = (arrayOfObject = this.players.getArray(event)).length;
for (int i = 0; i < j; i++) {
Object o = arrayOfObject[i];
if ((o instanceof Player)) {
if (mark == -1) {
owners.removePlayer(((Player) o).getName());
} else if (mark == 1) {
owners.removePlayer(((Player) o).getUniqueId());
} else if (mark == 0) {
owners.removePlayer(((Player) o).getName());
}
} else if ((o instanceof OfflinePlayer)) {
if (mark == -1) {
owners.removePlayer(((OfflinePlayer) o).getName());
} else if (mark == 1) {
owners.removePlayer(((OfflinePlayer) o).getUniqueId());
} else if (mark == 0) {
owners.removePlayer(((OfflinePlayer) o).getName());
}
} else {
owners.removePlayer(o.toString());
}
}
regionManager.getRegion(name).setOwners(owners);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: execute
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
if (world == null) {
for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
if (b.getKey().equals(name)) {
world = Bukkit.getWorld(a.getName());
break;
}
}
}
}
RegionManager regionManager = WGBukkit.getRegionManager(world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
DefaultDomain members = regionManager.getRegion(name).getMembers();
Object[] arrayOfObject;
int j = (arrayOfObject = this.players.getArray(event)).length;
for (int i = 0; i < j; i++) {
Object o = arrayOfObject[i];
if ((o instanceof Player)) {
if (mark == -1) {
members.removePlayer(((Player) o).getName());
} else if (mark == 1) {
members.removePlayer(((Player) o).getUniqueId());
} else if (mark == 0) {
members.removePlayer(((Player) o).getName());
}
} else if ((o instanceof OfflinePlayer)) {
if (mark == -1) {
members.removePlayer(((OfflinePlayer) o).getName());
} else if (mark == 1) {
members.removePlayer(((OfflinePlayer) o).getUniqueId());
} else if (mark == 0) {
members.removePlayer(((OfflinePlayer) o).getName());
}
} else {
members.removePlayer(o.toString());
}
}
regionManager.getRegion(name).setMembers(members);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: execute
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
if (world == null) {
for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
if (b.getKey().equals(name)) {
world = Bukkit.getWorld(a.getName());
break;
}
}
}
}
RegionManager regionManager = WGBukkit.getRegionManager(world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
DefaultDomain owners = regionManager.getRegion(name).getOwners();
Object[] arrayOfObject;
int j = (arrayOfObject = this.players.getArray(event)).length;
for (int i = 0; i < j; i++) {
Object o = arrayOfObject[i];
if ((o instanceof Player)) {
if (mark == -1) {
owners.addPlayer(((Player) o).getName());
} else if (mark == 1) {
owners.addPlayer(((Player) o).getUniqueId());
} else if (mark == 0) {
owners.addPlayer(((Player) o).getName());
}
} else if ((o instanceof OfflinePlayer)) {
if (mark == -1) {
owners.addPlayer(((OfflinePlayer) o).getName());
} else if (mark == 1) {
owners.addPlayer(((OfflinePlayer) o).getUniqueId());
} else if (mark == 0) {
owners.addPlayer(((OfflinePlayer) o).getName());
}
} else {
owners.addPlayer(o.toString());
}
}
regionManager.getRegion(name).setOwners(owners);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: newBlock
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
public void newBlock(ProtectedCuboidRegion regionToProtect, Location location, Player player, ItemMeta dtMeta, Material material, Byte materialData) {
RegionManager rm = plugin.wgm.getRegionManager(location.getWorld());
if (rm.overlapsUnownedRegion(regionToProtect, plugin.wgm.wrapPlayer(player))) {
returnBlock(location, player, dtMeta);
player.sendMessage(ChatColor.RED + plugin.i18n.getText("overlaps"));
return;
}
if (plugin.config.ignoredWorldContains(location.getWorld())) {
returnBlock(location, player, dtMeta);
player.sendMessage(ChatColor.RED + plugin.i18n.getText("ignored_world"));
return;
}
if (protectionBlockMap.containsKey(location)) {
returnBlock(location, player, dtMeta);
player.sendMessage(ChatColor.RED + plugin.i18n.getText("protection_over"));
return;
}
int calculatedPriority = -1;
for (ProtectedRegion pr : rm.getApplicableRegions(regionToProtect)) {
if (pr.getPriority() > calculatedPriority) {
calculatedPriority = pr.getPriority();
}
}
regionToProtect.setPriority(calculatedPriority + 1);
rm.addRegion(regionToProtect);
player.sendMessage(ChatColor.GREEN + plugin.i18n.getText("pb_activated"));
addProtectionBlock(location, regionToProtect, material, false,
dtMeta.getDisplayName(), dtMeta.getLore(), materialData,
(int) new Date().getTime() / 1000);
try {
rm.save();
} catch (ProtectionDatabaseException ex) {
Logger.getLogger(ProtectionBlocks.class
.getName()).log(Level.SEVERE, null, ex);
}
if (player.getGameMode() == GameMode.CREATIVE) {
player.setItemInHand(new ItemStack(Material.AIR));
}
plugin.pc.removeAvailableId(dtMeta.getLore().get(2));
new FlagsProcessor(plugin, location).runTaskAsynchronously(plugin);
}
示例13: exec
import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
@Override
public Construct exec(Target t, Environment env, Construct... args) throws CancelCommandException, ConfigRuntimeException {
Static.checkPlugin("WorldGuard", t);
World world = null;
String region;
if (args.length == 1) {
region = args[0].val();
MCPlayer m = null;
if (env.getEnv(CommandHelperEnvironment.class).GetCommandSender() instanceof MCPlayer) {
m = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
}
if (m != null) {
world = Bukkit.getServer().getWorld(m.getWorld().getName());
}
} else {
region = args[1].val();
world = Bukkit.getServer().getWorld(args[0].val());
}
if (world == null) {
throw new CREInvalidWorldException("Unknown world specified", t);
}
RegionManager mgr = WorldGuardPlugin.inst().getRegionManager(world);
ProtectedRegion regionExists = mgr.getRegion(region);
if (regionExists == null) {
throw new CREPluginInternalException(String.format("The region (%s) does not exist in world (%s).", region, world.getName()), t);
}
mgr.removeRegion(region);
try {
mgr.save();
} catch (StorageException e) {
throw new CREPluginInternalException("Error while removing protected region", t, e);
}
return CVoid.VOID;
}