mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 23:27:35 +01:00
Some initial code reorganization. Todo: Have CSVDatabase handle flags so they can be ported over, and do the commands system a cleaner way.
This commit is contained in:
parent
eda7db7aca
commit
81eb2cad1a
@ -79,6 +79,9 @@ public boolean isEmpty() {
|
||||
|
||||
/**
|
||||
* Get the entries for an item or list.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public List<BlacklistEntry> getEntries(int id) {
|
||||
return blacklist.get(id);
|
||||
@ -119,7 +122,6 @@ public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent)
|
||||
* Load the blacklist.
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public void load(File file) throws IOException {
|
||||
@ -242,6 +244,7 @@ public BlacklistEvent getLastEvent() {
|
||||
* Notify administrators.
|
||||
*
|
||||
* @param event
|
||||
* @param comment
|
||||
*/
|
||||
public void notify(BlacklistEvent event, String comment) {
|
||||
lastEvent = event;
|
||||
@ -272,8 +275,6 @@ public void forgetPlayer(LocalPlayer player) {
|
||||
|
||||
/**
|
||||
* Forget all players.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void forgetAllPlayers() {
|
||||
lastAffected.clear();
|
||||
|
@ -107,7 +107,7 @@ public String[] getDestroyWithActions() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* @param actions
|
||||
*/
|
||||
public void setDestroyWithActions(String[] actions) {
|
||||
this.destroyWithActions = actions;
|
||||
@ -266,6 +266,7 @@ private String[] getActions(BlacklistEvent event) {
|
||||
/**
|
||||
* Method to handle the event.
|
||||
*
|
||||
* @param useAsWhitelist
|
||||
* @param event
|
||||
* @param forceRepeat
|
||||
* @param silent
|
||||
|
@ -55,8 +55,6 @@ public void removeHandler(BlacklistLoggerHandler handler) {
|
||||
|
||||
/**
|
||||
* Add a handler.
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
public void clearHandlers() {
|
||||
handlers.clear();
|
||||
@ -65,7 +63,6 @@ public void clearHandlers() {
|
||||
/**
|
||||
* Log an event.
|
||||
*
|
||||
* @param player
|
||||
* @param event
|
||||
*/
|
||||
public void logEvent(BlacklistEvent event, String comment) {
|
||||
|
@ -32,7 +32,7 @@ public class BlacklistTrackedEvent {
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
* @param event
|
||||
* @param time
|
||||
*/
|
||||
public BlacklistTrackedEvent(BlacklistEvent event, long time) {
|
||||
|
@ -32,6 +32,7 @@ public BlockBreakBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "break";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public BlockInteractBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "interact with";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public BlockPlaceBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "place";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public DestroyWithBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "destroy with";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public ItemAcquireBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "acquire";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public ItemDropBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "drop";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public ItemUseBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "use";
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ public ConsoleLoggerHandler(String worldName)
|
||||
/**
|
||||
* Log an event.
|
||||
*
|
||||
* @param player
|
||||
* @param event
|
||||
*/
|
||||
public void logEvent(BlacklistEvent event, String comment) {
|
||||
|
@ -76,6 +76,8 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param dsn
|
||||
* @param user
|
||||
* @param pass
|
||||
* @param table
|
||||
* @param worldName
|
||||
*/
|
||||
public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName) {
|
||||
this.dsn = dsn;
|
||||
@ -136,7 +138,6 @@ private void logEvent(String event, LocalPlayer player, Vector pos, int item,
|
||||
/**
|
||||
* Log an event.
|
||||
*
|
||||
* @param player
|
||||
* @param event
|
||||
*/
|
||||
public void logEvent(BlacklistEvent event, String comment) {
|
||||
|
@ -71,6 +71,7 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
* Construct the object.
|
||||
*
|
||||
* @param pathPattern
|
||||
* @param worldName
|
||||
*/
|
||||
public FileLoggerHandler(String pathPattern, String worldName) {
|
||||
this.pathPattern = pathPattern;
|
||||
@ -82,6 +83,7 @@ public FileLoggerHandler(String pathPattern, String worldName) {
|
||||
*
|
||||
* @param pathPattern
|
||||
* @param cacheSize
|
||||
* @param worldName
|
||||
*/
|
||||
public FileLoggerHandler(String pathPattern, int cacheSize, String worldName) {
|
||||
if (cacheSize < 1) {
|
||||
@ -236,7 +238,6 @@ private void logEvent(BlacklistEvent event, String text, int id, Vector pos, Str
|
||||
/**
|
||||
* Log an event.
|
||||
*
|
||||
* @param player
|
||||
* @param event
|
||||
*/
|
||||
public void logEvent(BlacklistEvent event, String comment) {
|
||||
|
@ -42,6 +42,7 @@ public class FileLoggerWriter implements Comparable<FileLoggerWriter> {
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param path
|
||||
* @param writer
|
||||
*/
|
||||
public FileLoggerWriter(String path, BufferedWriter writer) {
|
||||
@ -75,8 +76,6 @@ public long getLastUse() {
|
||||
|
||||
/**
|
||||
* Update last use time.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void updateLastUse() {
|
||||
lastUse = System.currentTimeMillis();
|
||||
|
@ -30,9 +30,10 @@ public BukkitBlacklist(Boolean useAsWhitelist, WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastNotification(String msg) {
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (plugin.getWgConfiguration().hasPermission(player, "notify")) {
|
||||
if (plugin.hasPermission(player, "notify")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
@ -26,15 +26,15 @@
|
||||
|
||||
public class BukkitPlayer extends LocalPlayer {
|
||||
private Player player;
|
||||
private WorldGuardConfiguration config;
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
public BukkitPlayer(WorldGuardConfiguration config, Player player) {
|
||||
this.config = config;
|
||||
public BukkitPlayer(WorldGuardPlugin plugin, Player player) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static BukkitPlayer wrapPlayer(WorldGuardConfiguration config, Player player) {
|
||||
return new BukkitPlayer(config, player);
|
||||
public static BukkitPlayer wrapPlayer(WorldGuardPlugin plugin, Player player) {
|
||||
return new BukkitPlayer(plugin, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,7 +44,7 @@ public String getName() {
|
||||
|
||||
@Override
|
||||
public boolean hasGroup(String group) {
|
||||
return config.inGroup(player, group);
|
||||
return plugin.inGroup(player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,7 +65,7 @@ public void ban(String msg) {
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return config.getGroups(player);
|
||||
return plugin.getGroups(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
317
src/com/sk89q/worldguard/bukkit/GlobalConfiguration.java
Normal file
317
src/com/sk89q/worldguard/bukkit/GlobalConfiguration.java
Normal file
@ -0,0 +1,317 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.protection.dbs.CSVDatabase;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
/**
|
||||
* Represents the global configuration and also delegates configuration
|
||||
* for individual worlds.
|
||||
*
|
||||
* @author Michael
|
||||
* @author sk89q
|
||||
*/
|
||||
public class GlobalConfiguration {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
private Map<String, WorldConfiguration> worldConfig;
|
||||
|
||||
protected Set<String> invinciblePlayers = new HashSet<String>();
|
||||
protected Set<String> amphibiousPlayers = new HashSet<String>();
|
||||
|
||||
private iConomy iConomy;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public GlobalConfiguration(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldConfig = new HashMap<String, WorldConfiguration>();
|
||||
this.iConomy = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration for a world.
|
||||
*
|
||||
* @param worldName
|
||||
* @return
|
||||
*/
|
||||
public WorldConfiguration getWorldConfig(String worldName) {
|
||||
WorldConfiguration ret = worldConfig.get(worldName);
|
||||
if (ret == null) {
|
||||
ret = createWorldConfig(worldName);
|
||||
worldConfig.put(worldName, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the configuration for a world.
|
||||
*
|
||||
* @param worldName
|
||||
* @return
|
||||
*/
|
||||
private WorldConfiguration createWorldConfig(String worldName) {
|
||||
File baseFolder = new File(plugin.getDataFolder(), worldName);
|
||||
File configFile = new File(baseFolder, "config.yml");
|
||||
File blacklistFile = new File(baseFolder, "blacklist.txt");
|
||||
|
||||
return new WorldConfiguration(plugin, worldName, configFile, blacklistFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration files.
|
||||
*/
|
||||
public void load() {
|
||||
checkOldConfigFiles();
|
||||
checkOldCSVDB();
|
||||
|
||||
Configuration config = plugin.getConfiguration();
|
||||
|
||||
boolean suppressTickSyncWarnings = config.getBoolean(
|
||||
"suppress-tick-sync-warnings", false);
|
||||
|
||||
invinciblePlayers.clear();
|
||||
amphibiousPlayers.clear();
|
||||
|
||||
// Build initial lists of users matching the criteria
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (plugin.inGroup(player, "wg-invincible"))
|
||||
invinciblePlayers.add(player.getName());
|
||||
|
||||
if (plugin.inGroup(player, "wg-amphibious"))
|
||||
amphibiousPlayers.add(player.getName());
|
||||
}
|
||||
|
||||
if (suppressTickSyncWarnings) {
|
||||
Logger.getLogger("Minecraft").setFilter(
|
||||
new TickSyncDelayLoggerFilter());
|
||||
} else {
|
||||
Filter filter = Logger.getLogger("Minecraft").getFilter();
|
||||
if (filter != null && filter instanceof TickSyncDelayLoggerFilter) {
|
||||
Logger.getLogger("Minecraft").setFilter(null);
|
||||
}
|
||||
}
|
||||
|
||||
loadWorldConfiguration();
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configurations for the different worlds.
|
||||
*/
|
||||
private void loadWorldConfiguration() {
|
||||
worldConfig.clear();
|
||||
|
||||
for (World w : plugin.getServer().getWorlds()) {
|
||||
String worldName = w.getName();
|
||||
worldConfig.put(worldName, createWorldConfig(worldName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for old pre-4.x configuration files.
|
||||
*/
|
||||
private void checkOldConfigFiles() {
|
||||
File oldFile = new File(plugin.getDataFolder(), "blacklist.txt");
|
||||
|
||||
if (oldFile.exists()) {
|
||||
logger.warning("WorldGuard: blacklist.txt is outdated, please "
|
||||
+ "reapply your configuration in <world>/blacklist.txt");
|
||||
logger.warning("WorldGuard: blacklist.txt renamed to blacklist.txt.old");
|
||||
|
||||
oldFile.renameTo(new File(plugin.getDataFolder(),
|
||||
"blacklist.txt.old"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for old world databases from pre-4.x versions. Also convert them
|
||||
* over to the new format.
|
||||
*/
|
||||
private void checkOldCSVDB() {
|
||||
try {
|
||||
File oldDatabase = new File(plugin.getDataFolder(), "regions.txt");
|
||||
if (!oldDatabase.exists()) return;
|
||||
|
||||
logger.info("WorldGuard: The regions database has changed in 4.x. "
|
||||
+ "Your old regions database will be converted to the new format "
|
||||
+ "and set as your primarily world's database.");
|
||||
logger.info("WorldGuard: Converting...");
|
||||
|
||||
// We're assuming that the regions
|
||||
World w = plugin.getServer().getWorlds().get(0);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager()
|
||||
.getRegionManager(w.getName());
|
||||
|
||||
// First load up the old database using the CSV loader
|
||||
CSVDatabase db = new CSVDatabase(oldDatabase);
|
||||
db.load();
|
||||
|
||||
// Then save the new database
|
||||
mgr.setRegions(db.getRegions());
|
||||
mgr.save();
|
||||
|
||||
logger.info("WorldGuard: regions.txt has been renamed to regions.txt.old.");
|
||||
|
||||
oldDatabase.renameTo(new File(plugin.getDataFolder(), "regions.txt.old"));
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (IOException e) {
|
||||
logger.warning("WorldGuard: Failed to load regions: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permission to build at a location.
|
||||
*
|
||||
* @param player
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(Player player, Vector pt) {
|
||||
if (getWorldConfig(player.getWorld().getName()).useRegions) {
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||
|
||||
if (!plugin.hasPermission(player, "region.bypass")) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager()
|
||||
.getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permission to build at a location.
|
||||
*
|
||||
* @param player
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(Player player, int x, int y, int z) {
|
||||
return canBuild(player, new Vector(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player can breathe underwater.
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
public boolean isAmphibiousPlayer(String playerName) {
|
||||
if (amphibiousPlayers.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player is invincible.
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
public boolean isInvinciblePlayer(String playerName) {
|
||||
if (invinciblePlayers.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addAmphibiousPlayer(String playerName) {
|
||||
amphibiousPlayers.add(playerName);
|
||||
}
|
||||
|
||||
public void addInvinciblePlayer(String playerName) {
|
||||
invinciblePlayers.add(playerName);
|
||||
}
|
||||
|
||||
public void removeAmphibiousPlayer(String playerName) {
|
||||
amphibiousPlayers.remove(playerName);
|
||||
}
|
||||
|
||||
public void removeInvinciblePlayer(String playerName) {
|
||||
invinciblePlayers.remove(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget all players.
|
||||
* @param player
|
||||
*/
|
||||
public void forgetPlayer(LocalPlayer player) {
|
||||
|
||||
for (Map.Entry<String, WorldConfiguration> entry : worldConfig
|
||||
.entrySet()) {
|
||||
Blacklist bl = entry.getValue().getBlacklist();
|
||||
if (bl != null) {
|
||||
bl.forgetPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public WorldGuardPlugin getWorldGuardPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public iConomy getiConomy() {
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public void setiConomy(iConomy newVal) {
|
||||
this.iConomy = newVal;
|
||||
}
|
||||
}
|
@ -47,18 +47,21 @@ public LoggerToChatHandler(Player player) {
|
||||
/**
|
||||
* Close the handler.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the output.
|
||||
*/
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a log record.
|
||||
*/
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
player.sendMessage(ChatColor.GRAY + record.getLevel().getName() + ": "
|
||||
+ ChatColor.WHITE + record.getMessage());
|
||||
|
@ -15,8 +15,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
@ -28,24 +27,24 @@
|
||||
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class WorldGuardWorldConfiguration {
|
||||
public class WorldConfiguration {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
private static final Logger logger = Logger
|
||||
.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
private WorldGuardPlugin wp;
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
private String worldName;
|
||||
private File configFile;
|
||||
@ -53,7 +52,6 @@ public class WorldGuardWorldConfiguration {
|
||||
|
||||
private Blacklist blacklist;
|
||||
|
||||
|
||||
/* Configuration data start */
|
||||
public boolean fireSpreadDisableToggle;
|
||||
public boolean enforceOneSession;
|
||||
@ -88,74 +86,29 @@ public class WorldGuardWorldConfiguration {
|
||||
public boolean teleportOnSuffocation;
|
||||
public boolean useRegions;
|
||||
public int regionWand = 287;
|
||||
public String blockCreatureSpawn;
|
||||
public Set<CreatureType> blockCreatureSpawn;
|
||||
public boolean useiConomy;
|
||||
public boolean buyOnClaim;
|
||||
public double buyOnClaimPrice;
|
||||
public int maxClaimVolume;
|
||||
public boolean claimOnlyInsideExistingRegions;
|
||||
public int maxRegionCountPerPlayer;
|
||||
|
||||
/* Configuration data end */
|
||||
|
||||
|
||||
public WorldGuardWorldConfiguration(WorldGuardPlugin wp, String worldName, File configFile, File blacklistFile)
|
||||
{
|
||||
this.wp = wp;
|
||||
public WorldConfiguration(WorldGuardPlugin wp, String worldName,
|
||||
File configFile, File blacklistFile) {
|
||||
this.plugin = wp;
|
||||
this.worldName = worldName;
|
||||
this.configFile = configFile;
|
||||
this.blacklistFile = blacklistFile;
|
||||
|
||||
createDefaultConfiguration(configFile, "config.yml");
|
||||
createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||
WorldGuardPlugin.createDefaultConfiguration(configFile, "config.yml");
|
||||
WorldGuardPlugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||
|
||||
loadConfiguration();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public static void createDefaultConfiguration(File actual, String defaultName) {
|
||||
|
||||
if (!actual.exists()) {
|
||||
|
||||
InputStream input =
|
||||
WorldGuardPlugin.class.getResourceAsStream("/defaults/" + defaultName);
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
|
||||
try {
|
||||
output = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
logger.info("WorldGuard: Default configuration file written: " + defaultName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
*/
|
||||
@ -211,9 +164,15 @@ private void loadConfiguration() {
|
||||
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);
|
||||
buyOnClaimPrice = config.getDouble("iconomy.buy-on-claim-price", 1.0);
|
||||
|
||||
blockCreatureSpawn = "";
|
||||
for (String creature : config.getStringList("mobs.block-creature-spawn", null)) {
|
||||
blockCreatureSpawn += creature.toLowerCase() + " ";
|
||||
blockCreatureSpawn = new HashSet<CreatureType>();
|
||||
for (String creatureName : config.getStringList("mobs.block-creature-spawn", null)) {
|
||||
CreatureType creature = CreatureType.fromName(creatureName);
|
||||
|
||||
if (creature == null) {
|
||||
logger.warning("WorldGuard: Unknown mob type '" + creatureName + "'");
|
||||
} else {
|
||||
blockCreatureSpawn.add(creature);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalFlags globalFlags = new GlobalFlags();
|
||||
@ -227,8 +186,7 @@ private void loadConfiguration() {
|
||||
globalFlags.canLeverandbutton = config.getBoolean("regions.default.leverandbutton", true);
|
||||
globalFlags.canPlaceVehicle = config.getBoolean("regions.default.placevehicle", true);
|
||||
globalFlags.allowWaterflow = config.getBoolean("regions.default.waterflow", true);
|
||||
wp.getGlobalRegionManager().setGlobalFlags(worldName, globalFlags);
|
||||
|
||||
plugin.getGlobalRegionManager().setGlobalFlags(worldName, globalFlags);
|
||||
|
||||
boolean useBlacklistAsWhitelist = config.getBoolean("blacklist.use-as-whitelist", false);
|
||||
|
||||
@ -255,7 +213,7 @@ private void loadConfiguration() {
|
||||
}
|
||||
|
||||
// First load the blacklist data from worldguard-blacklist.txt
|
||||
Blacklist blist = new BukkitBlacklist(useBlacklistAsWhitelist, wp);
|
||||
Blacklist blist = new BukkitBlacklist(useBlacklistAsWhitelist, plugin);
|
||||
blist.load(blacklistFile);
|
||||
|
||||
// If the blacklist is empty, then set the field to null
|
||||
@ -291,35 +249,39 @@ private void loadConfiguration() {
|
||||
|
||||
// Print an overview of settings
|
||||
if (config.getBoolean("summary-on-start", true)) {
|
||||
logger.log(Level.INFO, "=== WorldGuard configuration for world " + worldName + " ===");
|
||||
logger.log(Level.INFO, enforceOneSession ? "WorldGuard: Single session is enforced."
|
||||
: "WorldGuard: Single session is NOT ENFORCED.");
|
||||
logger.log(Level.INFO, blockTNT ? "WorldGuard: TNT ignition is blocked."
|
||||
: "WorldGuard: TNT ignition is PERMITTED.");
|
||||
logger.log(Level.INFO, blockLighter ? "WorldGuard: Lighters are blocked."
|
||||
: "WorldGuard: Lighters are PERMITTED.");
|
||||
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
||||
: "WorldGuard: Lava fire is PERMITTED.");
|
||||
logger.log(Level.INFO, enforceOneSession
|
||||
? "WorldGuard: (" + worldName + ") Single session is enforced."
|
||||
: "WorldGuard: (" + worldName + ") Single session is NOT ENFORCED.");
|
||||
logger.log(Level.INFO, blockTNT
|
||||
? "WorldGuard: (" + worldName + ") TNT ignition is blocked."
|
||||
: "WorldGuard: (" + worldName + ") TNT ignition is PERMITTED.");
|
||||
logger.log(Level.INFO, blockLighter
|
||||
? "WorldGuard: (" + worldName + ") Lighters are blocked."
|
||||
: "WorldGuard: (" + worldName + ") Lighters are PERMITTED.");
|
||||
logger.log(Level.INFO, preventLavaFire
|
||||
? "WorldGuard: (" + worldName + ") Lava fire is blocked."
|
||||
: "WorldGuard: (" + worldName + ") Lava fire is PERMITTED.");
|
||||
|
||||
if (disableFireSpread) {
|
||||
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
||||
logger.log(Level.INFO, "WorldGuard: (" + worldName + ") All fire spread is disabled.");
|
||||
} else {
|
||||
if (disableFireSpreadBlocks.size() > 0) {
|
||||
logger.log(Level.INFO, "WorldGuard: Fire spread is limited to "
|
||||
logger.log(Level.INFO, "WorldGuard: (" + worldName
|
||||
+ ") Fire spread is limited to "
|
||||
+ disableFireSpreadBlocks.size() + " block types.");
|
||||
} else {
|
||||
logger.log(Level.INFO, "WorldGuard: Fire spread is UNRESTRICTED.");
|
||||
logger.log(Level.INFO, "WorldGuard: (" + worldName
|
||||
+ ") Fire spread is UNRESTRICTED.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Blacklist getBlacklist()
|
||||
{
|
||||
public Blacklist getBlacklist() {
|
||||
return this.blacklist;
|
||||
}
|
||||
|
||||
public String getWorldName()
|
||||
{
|
||||
public String getWorldName() {
|
||||
return this.worldName;
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ public void onBlockDamage(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block blockDamaged = event.getBlock();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (wcfg.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
||||
Vector pt = toVector(blockDamaged);
|
||||
@ -123,8 +123,8 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (!wcfg.itemDurability) {
|
||||
ItemStack held = player.getItemInHand();
|
||||
@ -146,7 +146,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||
new BlockBreakBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player),
|
||||
toVector(event.getBlock()),
|
||||
event.getBlock().getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
@ -154,7 +154,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.getBlacklist().check(
|
||||
new DestroyWithBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||
new DestroyWithBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player),
|
||||
toVector(event.getBlock()),
|
||||
player.getItemInHand().getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
@ -182,8 +182,8 @@ public void onBlockFlow(BlockFromToEvent event) {
|
||||
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
||||
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
|
||||
if (wcfg.simulateSponge && isWater) {
|
||||
int ox = blockTo.getX();
|
||||
@ -271,8 +271,8 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
|
||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||
|
||||
@ -283,8 +283,8 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (player != null && !cfg.hasPermission(player, "region.bypass")) {
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
if (player != null && !plugin.hasPermission(player, "region.bypass")) {
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
@ -359,8 +359,8 @@ public void onBlockBurn(BlockBurnEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
|
||||
if (wcfg.disableFireSpread) {
|
||||
event.setCancelled(true);
|
||||
@ -394,8 +394,8 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
|
||||
int id = event.getChangedTypeId();
|
||||
|
||||
@ -431,8 +431,8 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
Material type = block.getType();
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||
|
||||
if (entity instanceof Player
|
||||
&& (block.getType() == Material.CHEST
|
||||
@ -443,10 +443,10 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
Player player = (Player) entity;
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!cfg.hasPermission(player, "region.bypass")) {
|
||||
if (!plugin.hasPermission(player, "region.bypass")) {
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (!set.isStateFlagAllowed(Flags.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
@ -461,7 +461,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
Vector pt = toVector(block);
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(((Player)entity).getWorld().getName());
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, (Player)entity);
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, (Player)entity);
|
||||
|
||||
if (!applicableRegions.isStateFlagAllowed(Flags.LEVER_AND_BUTTON, localPlayer)) {
|
||||
((Player)entity).sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
@ -474,7 +474,7 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new BlockInteractBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player), toVector(block),
|
||||
new BlockInteractBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player), toVector(block),
|
||||
block.getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -498,8 +498,8 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
World world = blockPlaced.getWorld();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(blockPlaced);
|
||||
@ -513,7 +513,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new BlockPlaceBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player), toVector(blockPlaced),
|
||||
new BlockPlaceBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player), toVector(blockPlaced),
|
||||
blockPlaced.getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -544,8 +544,8 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block blockClicked = event.getBlock();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(blockClicked.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(blockClicked.getWorld().getName());
|
||||
|
||||
if (wcfg.useRegions && event.getItemInHand().getTypeId() == wcfg.regionWand) {
|
||||
Vector pt = toVector(blockClicked);
|
||||
@ -556,7 +556,7 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
|
||||
if (regions.size() > 0) {
|
||||
player.sendMessage(ChatColor.YELLOW + "Can you build? "
|
||||
+ (app.canBuild(BukkitPlayer.wrapPlayer(cfg, player)) ? "Yes" : "No"));
|
||||
+ (app.canBuild(BukkitPlayer.wrapPlayer(plugin, player)) ? "Yes" : "No"));
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (Iterator<String> it = regions.iterator(); it.hasNext();) {
|
||||
@ -598,7 +598,7 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
if (((Sign)block).getLine(0).equalsIgnoreCase("[WorldGuard]")
|
||||
&& ((Sign)block).getLine(1).equalsIgnoreCase("For sale")) {
|
||||
String regionId = ((Sign)block).getLine(2);
|
||||
String regionComment = ((Sign)block).getLine(3);
|
||||
//String regionComment = ((Sign)block).getLine(3);
|
||||
|
||||
if (regionId != null && regionId != "") {
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
@ -654,8 +654,8 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||
Block blockTo = event.getBlock();
|
||||
World world = blockTo.getWorld();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
|
||||
if (wcfg.simulateSponge && wcfg.redstoneSponges) {
|
||||
int ox = blockTo.getX();
|
||||
@ -691,8 +691,8 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||
*/
|
||||
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
|
||||
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||
@ -715,8 +715,8 @@ private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
*/
|
||||
private void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||
|
||||
// The negative x edge
|
||||
int cx = ox - wcfg.spongeRadius - 1;
|
||||
@ -783,8 +783,6 @@ private void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
* Sets the given block to fluid water.
|
||||
* Used by addSpongeWater()
|
||||
*
|
||||
* @see addSpongeWater()
|
||||
*
|
||||
* @param world
|
||||
* @param ox
|
||||
* @param oy
|
||||
|
@ -1,426 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.InsufficientPermissionsException;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.dbs.CSVDatabase;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael
|
||||
*/
|
||||
public class WorldGuardConfiguration {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
private PermissionsResolverServerListener permsListener;
|
||||
private PermissionsResolverManager perms;
|
||||
private WorldGuardPlugin wg;
|
||||
private Map<String, WorldGuardWorldConfiguration> worldConfig;
|
||||
private Set<String> invinciblePlayers = new HashSet<String>();
|
||||
private Set<String> amphibiousPlayers = new HashSet<String>();
|
||||
private boolean suppressTickSyncWarnings;
|
||||
|
||||
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
|
||||
private iConomy iConomy;
|
||||
|
||||
public WorldGuardConfiguration(WorldGuardPlugin wg) {
|
||||
this.wg = wg;
|
||||
this.worldConfig = new HashMap<String, WorldGuardWorldConfiguration>();
|
||||
this.iConomy = null;
|
||||
}
|
||||
|
||||
public WorldGuardWorldConfiguration getWorldConfig(String worldName) {
|
||||
WorldGuardWorldConfiguration ret = worldConfig.get(worldName);
|
||||
if (ret == null) {
|
||||
ret = createWorldConfig(worldName);
|
||||
worldConfig.put(worldName, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private WorldGuardWorldConfiguration createWorldConfig(String worldName) {
|
||||
File configFile = new File(wg.getDataFolder(), worldName + ".yml");
|
||||
File blacklistFile = new File(wg.getDataFolder(), worldName + "_blacklist.txt");
|
||||
|
||||
return new WorldGuardWorldConfiguration(wg, worldName, configFile, blacklistFile);
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
wg.getDataFolder().mkdirs();
|
||||
|
||||
checkOldConfigFiles();
|
||||
checkOldCSVDB();
|
||||
|
||||
perms = new PermissionsResolverManager(wg.getConfiguration(), wg.getServer(), "WorldGuard", logger);
|
||||
permsListener = new PermissionsResolverServerListener(perms);
|
||||
|
||||
invinciblePlayers.clear();
|
||||
amphibiousPlayers.clear();
|
||||
|
||||
try {
|
||||
for (Player player : wg.getServer().getOnlinePlayers()) {
|
||||
if (inGroup(player, "wg-invincible")) {
|
||||
invinciblePlayers.add(player.getName());
|
||||
}
|
||||
|
||||
if (inGroup(player, "wg-amphibious")) {
|
||||
amphibiousPlayers.add(player.getName());
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) { // Thrown if loaded too early
|
||||
}
|
||||
|
||||
|
||||
File configFile = new File(wg.getDataFolder(), "global.yml");
|
||||
WorldGuardWorldConfiguration.createDefaultConfiguration(configFile, "global.yml");
|
||||
Configuration config = new Configuration(configFile);
|
||||
config.load();
|
||||
|
||||
suppressTickSyncWarnings = config.getBoolean("suppress-tick-sync-warnings", false);
|
||||
|
||||
if (suppressTickSyncWarnings) {
|
||||
Logger.getLogger("Minecraft").setFilter(new TickSyncDelayLoggerFilter());
|
||||
} else {
|
||||
Filter filter = Logger.getLogger("Minecraft").getFilter();
|
||||
if (filter != null && filter instanceof TickSyncDelayLoggerFilter) {
|
||||
Logger.getLogger("Minecraft").setFilter(null);
|
||||
}
|
||||
}
|
||||
|
||||
worldConfig.clear();
|
||||
;
|
||||
for (World w : wg.getServer().getWorlds()) {
|
||||
String worldName = w.getName();
|
||||
worldConfig.put(worldName, createWorldConfig(worldName));
|
||||
}
|
||||
|
||||
permsListener.register(wg);
|
||||
perms.load();
|
||||
}
|
||||
|
||||
private void checkOldConfigFiles() {
|
||||
try {
|
||||
|
||||
File oldFile = new File(wg.getDataFolder(), "config.yml");
|
||||
if (oldFile.exists()) {
|
||||
logger.info("WorldGuard: WARNING: config.yml is outdated, please reapply your configuration in <world>.yml and global.yml");
|
||||
logger.info("WorldGuard: WARNING: config.yml renamed to config.yml.old");
|
||||
oldFile.renameTo(new File(wg.getDataFolder(), "config.yml.old"));
|
||||
}
|
||||
oldFile = new File(wg.getDataFolder(), "blacklist.txt");
|
||||
if (oldFile.exists()) {
|
||||
logger.info("WorldGuard: WARNING: blacklist.txt is outdated, please reapply your configuration in <world>_blacklist.txt");
|
||||
logger.info("WorldGuard: WARNING: blacklist.txt renamed to blacklist.txt.old");
|
||||
oldFile.renameTo(new File(wg.getDataFolder(), "blacklist.txt.old"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkOldCSVDB() {
|
||||
try {
|
||||
File CSVfile = new File(wg.getDataFolder(), "regions.txt");
|
||||
if (CSVfile.exists()) {
|
||||
|
||||
logger.info("WorldGuard: Converting old regions.txt to new format....");
|
||||
|
||||
World w = wg.getServer().getWorlds().get(0);
|
||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(w.getName());
|
||||
|
||||
CSVDatabase db = new CSVDatabase(CSVfile);
|
||||
db.load();
|
||||
|
||||
for (Map.Entry<String, ProtectedRegion> entry : db.getRegions().entrySet()) {
|
||||
mgr.addRegion(entry.getValue());
|
||||
}
|
||||
|
||||
mgr.save();
|
||||
CSVfile.renameTo(new File(wg.getDataFolder(), "regions.txt.old"));
|
||||
|
||||
logger.info("WorldGuard: Done.");
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (IOException e) {
|
||||
logger.warning("WorldGuard: Failed to load regions: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
public boolean canBuild(Player player, int x, int y, int z) {
|
||||
|
||||
if (getWorldConfig(player.getWorld().getName()).useRegions) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(this, player);
|
||||
|
||||
if (!hasPermission(player, "region.bypass")) {
|
||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBuild(Player player, Vector pt) {
|
||||
|
||||
if (getWorldConfig(player.getWorld().getName()).useRegions) {
|
||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(this, player);
|
||||
|
||||
if (!hasPermission(player, "region.bypass")) {
|
||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inGroup(Player player, String group) {
|
||||
try {
|
||||
return perms.inGroup(player.getName(), group);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getGroups(Player player) {
|
||||
try {
|
||||
return perms.getGroups(player.getName());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermission(Player player, String perm) {
|
||||
try {
|
||||
return player.isOp() || perms.hasPermission(player.getName(), "worldguard." + perm);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see if there are sufficient permissions, otherwise an exception
|
||||
* is raised in that case.
|
||||
*
|
||||
* @param player
|
||||
* @param permission
|
||||
* @throws InsufficientPermissionsException
|
||||
*/
|
||||
public void checkRegionPermission(CommandSender sender, String permission)
|
||||
throws InsufficientPermissionsException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if (!hasPermission(player, permission)) {
|
||||
throw new InsufficientPermissionsException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if there are sufficient permissions, otherwise an exception
|
||||
* is raised in that case.
|
||||
*
|
||||
* @param sender
|
||||
* @param permission
|
||||
* @throws InsufficientPermissionsException
|
||||
*/
|
||||
public void checkPermission(CommandSender sender, String permission)
|
||||
throws InsufficientPermissionsException {
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!hasPermission((Player)sender, permission)) {
|
||||
throw new InsufficientPermissionsException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param domain
|
||||
* @param split
|
||||
* @param startIndex
|
||||
*/
|
||||
public static void addToDomain(DefaultDomain domain,
|
||||
String[] split, int startIndex) {
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
domain.addPlayer(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param domain
|
||||
* @param split
|
||||
* @param startIndex
|
||||
*/
|
||||
public static void removeFromDomain(DefaultDomain domain,
|
||||
String[] split, int startIndex) {
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.removeGroup(m.group(1));
|
||||
} else {
|
||||
domain.removePlayer(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param split
|
||||
* @param startIndex
|
||||
* @return
|
||||
*/
|
||||
public static DefaultDomain parseDomainString(String[] split, int startIndex) {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
domain.addPlayer(s);
|
||||
}
|
||||
}
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAmphibiousPlayer(String playerName) {
|
||||
|
||||
if (amphibiousPlayers.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInvinciblePlayer(String playerName) {
|
||||
|
||||
if (invinciblePlayers.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addAmphibiousPlayer(String playerName) {
|
||||
amphibiousPlayers.add(playerName);
|
||||
}
|
||||
|
||||
public void addInvinciblePlayer(String playerName) {
|
||||
invinciblePlayers.add(playerName);
|
||||
}
|
||||
|
||||
public void removeAmphibiousPlayer(String playerName) {
|
||||
amphibiousPlayers.remove(playerName);
|
||||
}
|
||||
|
||||
public void removeInvinciblePlayer(String playerName) {
|
||||
invinciblePlayers.remove(playerName);
|
||||
}
|
||||
|
||||
public void forgetPlayerAllBlacklists(LocalPlayer player) {
|
||||
|
||||
for (Map.Entry<String, WorldGuardWorldConfiguration> entry : worldConfig.entrySet()) {
|
||||
Blacklist bl = entry.getValue().getBlacklist();
|
||||
if (bl != null) {
|
||||
bl.forgetPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public WorldGuardPlugin getWorldGuardPlugin()
|
||||
{
|
||||
return this.wg;
|
||||
}
|
||||
|
||||
|
||||
public iConomy getiConomy()
|
||||
{
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public void setiConomy(iConomy newVal)
|
||||
{
|
||||
this.iConomy = newVal;
|
||||
}
|
||||
}
|
@ -74,8 +74,8 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
@ -102,8 +102,8 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
@ -158,8 +158,8 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
@ -217,8 +217,8 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
@ -267,9 +267,9 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
Location l = event.getLocation();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(l.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(l.getWorld().getName());
|
||||
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
|
||||
@ -317,94 +317,27 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
|
||||
|
||||
<<<<<<< HEAD
|
||||
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
||||
CreatureType creaType = event.getCreatureType();
|
||||
String creaName = "";
|
||||
=======
|
||||
CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
||||
>>>>>>> ebdb727... Some initial code reorganization. Todo: Have CSVDatabase handle flags so they can be ported over, and do the commands system a cleaner way.
|
||||
Boolean cancelEvent = false;
|
||||
|
||||
switch (creaType) {
|
||||
case SPIDER:
|
||||
if (wcfg.blockCreatureSpawn.contains("spider")) {
|
||||
if (wcfg.blockCreatureSpawn.contains(creaType)) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "spider";
|
||||
break;
|
||||
case ZOMBIE:
|
||||
if (wcfg.blockCreatureSpawn.contains("zombie")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "zombie";
|
||||
break;
|
||||
case CREEPER:
|
||||
if (wcfg.blockCreatureSpawn.contains("creeper")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "creeper";
|
||||
break;
|
||||
case SKELETON:
|
||||
if (wcfg.blockCreatureSpawn.contains("skeleton")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "skeleton";
|
||||
break;
|
||||
case SQUID:
|
||||
if (wcfg.blockCreatureSpawn.contains("squid")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "squid";
|
||||
break;
|
||||
case PIG_ZOMBIE:
|
||||
if (wcfg.blockCreatureSpawn.contains("pigzombie")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "pigzombie";
|
||||
break;
|
||||
case GHAST:
|
||||
if (wcfg.blockCreatureSpawn.contains("ghast")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "ghast";
|
||||
break;
|
||||
case SLIME:
|
||||
if (wcfg.blockCreatureSpawn.contains("slime")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "slime";
|
||||
break;
|
||||
case PIG:
|
||||
if (wcfg.blockCreatureSpawn.contains("pig")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "pig";
|
||||
break;
|
||||
case COW:
|
||||
if (wcfg.blockCreatureSpawn.contains("cow")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "cow";
|
||||
break;
|
||||
case SHEEP:
|
||||
if (wcfg.blockCreatureSpawn.contains("sheep")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "sheep";
|
||||
break;
|
||||
case CHICKEN:
|
||||
if (wcfg.blockCreatureSpawn.contains("chicken")) {
|
||||
cancelEvent = true;
|
||||
}
|
||||
creaName = "chicken";
|
||||
break;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !creaName.equals("")) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(event.getEntity().getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
||||
|
||||
Boolean flagValue = mgr.getApplicableRegions(pt).getStringFlag(Flags.DENY_SPAWN, true).getValue("").contains(creaName);
|
||||
Boolean flagValue = mgr.getApplicableRegions(pt).getStringFlag(Flags.DENY_SPAWN, true).getValue("").contains(creaType.getName());
|
||||
if (flagValue != null) {
|
||||
if (flagValue) {
|
||||
cancelEvent = true;
|
||||
|
@ -18,26 +18,27 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.RegionGroup;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent;
|
||||
import org.bukkit.entity.Item;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent;
|
||||
import org.bukkit.*;
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.regions.flags.RegionFlag.RegionGroup;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
@ -61,7 +62,6 @@ public WorldGuardPlayerListener(WorldGuardPlugin plugin) {
|
||||
|
||||
|
||||
public void registerEvents() {
|
||||
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_ITEM, this, Priority.High, plugin);
|
||||
@ -83,19 +83,19 @@ public void registerEvents() {
|
||||
public void onPlayerJoin(PlayerEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
+ "Fire spread is currently globally disabled.");
|
||||
}
|
||||
|
||||
if (cfg.inGroup(player, "wg-invincible")) {
|
||||
if (plugin.inGroup(player, "wg-invincible")) {
|
||||
cfg.addInvinciblePlayer(player.getName());
|
||||
}
|
||||
|
||||
if (cfg.inGroup(player, "wg-amphibious")) {
|
||||
if (plugin.inGroup(player, "wg-amphibious")) {
|
||||
cfg.addAmphibiousPlayer(player.getName());
|
||||
}
|
||||
}
|
||||
@ -109,13 +109,12 @@ public void onPlayerJoin(PlayerEvent event) {
|
||||
public void onPlayerQuit(PlayerEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
|
||||
cfg.removeInvinciblePlayer(player.getName());
|
||||
cfg.removeAmphibiousPlayer(player.getName());
|
||||
|
||||
cfg.forgetPlayerAllBlacklists(BukkitPlayer.wrapPlayer(cfg, player));
|
||||
cfg.forgetPlayer(BukkitPlayer.wrapPlayer(plugin, player));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,8 +134,8 @@ public void onPlayerItem(PlayerItemEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
int itemId = item.getTypeId();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (wcfg.useRegions
|
||||
&& (itemId == 322 || itemId == 320 || itemId == 319 || itemId == 297 || itemId == 260
|
||||
@ -168,7 +167,7 @@ public void onPlayerItem(PlayerItemEvent event) {
|
||||
|
||||
if (wcfg.getBlacklist() != null && item != null && block != null) {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player),
|
||||
toVector(block.getRelative(event.getBlockFace())),
|
||||
item.getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
@ -196,8 +195,8 @@ public void onPlayerItem(PlayerItemEvent event) {
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||
|
||||
if (wcfg.enforceOneSession) {
|
||||
String name = player.getName();
|
||||
@ -212,7 +211,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if (!checkediConomy) {
|
||||
iConomy iconomy = (iConomy) plugin.getServer().getPluginManager().getPlugin("iConomy");
|
||||
if (iconomy != null) {
|
||||
plugin.getWgConfiguration().setiConomy(iconomy);
|
||||
plugin.getGlobalConfiguration().setiConomy(iconomy);
|
||||
}
|
||||
|
||||
checkediConomy = true;
|
||||
@ -231,14 +230,14 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
Item ci = event.getItemDrop();
|
||||
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemDropBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) {
|
||||
new ItemDropBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -258,14 +257,14 @@ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
Item ci = event.getItem();
|
||||
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) {
|
||||
new ItemAcquireBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -277,8 +276,6 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = player.getLocation();
|
||||
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
|
||||
ApplicableRegionSet regions = plugin.getGlobalRegionManager().getRegionManager(
|
||||
player.getWorld().getName()).getApplicableRegions(
|
||||
BukkitUtil.toVector(location));
|
||||
@ -288,7 +285,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if (spawn != null) {
|
||||
RegionGroup spawnconfig = regions.getRegionGroupFlag(Flags.SPAWN_PERM, true).getValue();
|
||||
if (spawnconfig != null) {
|
||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||
if (spawnconfig == RegionGroup.OWNER) {
|
||||
if (regions.isOwner(localPlayer)) {
|
||||
event.setRespawnLocation(spawn);
|
||||
|
@ -18,56 +18,59 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.InsufficientPermissionsException;
|
||||
import com.sk89q.worldguard.protection.TimedFlagsTimer;
|
||||
import com.sk89q.worldguard.protection.regionmanager.GlobalRegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Plugin for Bukkit.
|
||||
*
|
||||
* @author sk89qs
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
private final WorldGuardPlayerListener playerListener =
|
||||
new WorldGuardPlayerListener(this);
|
||||
private final WorldGuardBlockListener blockListener =
|
||||
new WorldGuardBlockListener(this);
|
||||
private final WorldGuardEntityListener entityListener =
|
||||
new WorldGuardEntityListener(this);
|
||||
private final WorldGuardVehicleListener vehicleListener =
|
||||
new WorldGuardVehicleListener(this);
|
||||
|
||||
private final CommandHandler commandHandler = new CommandHandler(this);
|
||||
private final GlobalRegionManager globalRegionManager = new GlobalRegionManager(this);
|
||||
private final WorldGuardConfiguration configuration = new WorldGuardConfiguration(this);
|
||||
protected static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
protected final CommandHandler commandHandler = new CommandHandler(this);
|
||||
protected final GlobalRegionManager globalRegionManager = new GlobalRegionManager(this);
|
||||
protected final GlobalConfiguration configuration = new GlobalConfiguration(this);
|
||||
protected PermissionsResolverManager perms;
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
public void onEnable() {
|
||||
|
||||
Flags.Init();
|
||||
|
||||
getDataFolder().mkdirs();
|
||||
globalRegionManager.onEnable();
|
||||
|
||||
playerListener.registerEvents();
|
||||
blockListener.registerEvents();
|
||||
entityListener.registerEvents();
|
||||
vehicleListener.registerEvents();
|
||||
// Register events
|
||||
(new WorldGuardPlayerListener(this)).registerEvents();
|
||||
(new WorldGuardBlockListener(this)).registerEvents();
|
||||
(new WorldGuardEntityListener(this)).registerEvents();
|
||||
(new WorldGuardVehicleListener(this)).registerEvents();
|
||||
|
||||
// 25 equals about 1s real time
|
||||
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimedFlagsTimer(this), 25 * 5, 25 * 5);
|
||||
this.getServer().getScheduler().scheduleSyncRepeatingTask(
|
||||
this, new TimedFlagsTimer(this), 25 * 5, 25 * 5);
|
||||
|
||||
commandHandler.registerCommands();
|
||||
|
||||
// Set up permissions
|
||||
perms = new PermissionsResolverManager(
|
||||
getConfiguration(), getServer(), "WorldGuard", logger);
|
||||
(new PermissionsResolverServerListener(perms)).register(this);
|
||||
|
||||
logger.info("WorldGuard " + this.getDescription().getVersion() + " enabled.");
|
||||
}
|
||||
|
||||
@ -75,10 +78,9 @@ public void onEnable() {
|
||||
* Called on plugin disable.
|
||||
*/
|
||||
public void onDisable() {
|
||||
|
||||
globalRegionManager.onDisable();
|
||||
|
||||
logger.info("WorldGuard " + this.getDescription().getVersion() + " disabled.");
|
||||
logger.info("WorldGuard " + getDescription().getVersion() + " disabled.");
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +98,123 @@ public GlobalRegionManager getGlobalRegionManager() {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WorldGuardConfiguration getWgConfiguration() {
|
||||
public GlobalConfiguration getGlobalConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player is in a group.
|
||||
*
|
||||
* @param player
|
||||
* @param group
|
||||
* @return
|
||||
*/
|
||||
public boolean inGroup(Player player, String group) {
|
||||
try {
|
||||
return perms.inGroup(player.getName(), group);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the groups of a player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public String[] getGroups(Player player) {
|
||||
try {
|
||||
return perms.getGroups(player.getName());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a player has a permission.
|
||||
*
|
||||
* @param player
|
||||
* @param perm
|
||||
* @return
|
||||
*/
|
||||
public boolean hasPermission(Player player, String perm) {
|
||||
try {
|
||||
return player.isOp()
|
||||
|| perms.hasPermission(player.getName(),
|
||||
"worldguard." + perm);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if there are sufficient permissions, otherwise an exception
|
||||
* is raised in that case.
|
||||
*
|
||||
* @param sender
|
||||
* @param permission
|
||||
* @throws InsufficientPermissionsException
|
||||
*/
|
||||
public void checkPermission(CommandSender sender, String permission)
|
||||
throws InsufficientPermissionsException {
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!hasPermission((Player)sender, permission)) {
|
||||
throw new InsufficientPermissionsException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param actual
|
||||
* @param defaultName
|
||||
*/
|
||||
public static void createDefaultConfiguration(File actual,
|
||||
String defaultName) {
|
||||
|
||||
if (actual.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream input = WorldGuardPlugin.class
|
||||
.getResourceAsStream("/defaults/" + defaultName);
|
||||
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
|
||||
try {
|
||||
output = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
logger.info("WorldGuard: Default configuration file written: "
|
||||
+ defaultName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public void onVehicleCreate(VehicleCreateEvent event) {
|
||||
Vector pt = new Vector(vhclLoc.getBlockX(), vhclLoc.getBlockY(), vhclLoc.getBlockZ());
|
||||
|
||||
if (vhcl instanceof Minecart || vhcl instanceof Boat) {
|
||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(vhcl.getWorld().getName());
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
|
||||
|
@ -20,8 +20,9 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
@ -34,9 +35,11 @@
|
||||
*/
|
||||
public class CommandAllowFire extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
|
||||
cfg.checkPermission(sender, "allowfire");
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
plugin.checkPermission(sender, "worldguard.fire-toggle.allow");
|
||||
|
||||
String worldName;
|
||||
|
||||
@ -55,7 +58,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
return true;
|
||||
}
|
||||
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
server.broadcastMessage(ChatColor.YELLOW
|
||||
|
@ -24,7 +24,8 @@
|
||||
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.*;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
@ -38,7 +39,11 @@
|
||||
*/
|
||||
public class CommandBuyRegion extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
@ -53,7 +58,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
|
||||
CommandHandler.checkArgs(args, 1, 2);
|
||||
|
||||
cfg.checkRegionPermission(player, "buyregion");
|
||||
plugin.checkPermission(player, "worldguard.regions.buy");
|
||||
|
||||
String id = args[0];
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -32,13 +33,16 @@
|
||||
*/
|
||||
public class CommandGod extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 0, 1);
|
||||
|
||||
// Allow setting other people invincible
|
||||
if (args.length > 0) {
|
||||
cfg.checkPermission(sender, "god.other");
|
||||
plugin.checkPermission(sender, "worldguard.god.other");
|
||||
|
||||
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||
if (other == null) {
|
||||
@ -56,7 +60,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
// Invincibility for one's self
|
||||
} else if(sender instanceof Player) {
|
||||
cfg.checkPermission(sender, "god.self");
|
||||
plugin.checkPermission(sender, "worldguard.god");
|
||||
Player player = (Player)sender;
|
||||
if (!cfg.isInvinciblePlayer(player.getName())) {
|
||||
cfg.addInvinciblePlayer(player.getName());
|
||||
|
@ -94,7 +94,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
|
||||
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getName() : "Console";
|
||||
|
||||
wgcmd.handle(sender, senderName, cmdName, args, wg.getWgConfiguration());
|
||||
wgcmd.handle(sender, senderName, cmdName, args, wg.getGlobalConfiguration(), wg);
|
||||
return true;
|
||||
|
||||
} catch (InsufficientArgumentsException e) {
|
||||
|
@ -19,7 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -32,13 +33,16 @@
|
||||
*/
|
||||
public class CommandHeal extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 0, 1);
|
||||
|
||||
// Allow healing other people
|
||||
if (args.length > 0) {
|
||||
cfg.checkPermission(sender, "heal.other");
|
||||
plugin.checkPermission(sender, "worldguard.heal.other");
|
||||
|
||||
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||
if (other == null) {
|
||||
@ -49,7 +53,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
other.sendMessage(ChatColor.YELLOW + senderName + " has healed you!");
|
||||
}
|
||||
} else if (sender instanceof Player){
|
||||
cfg.checkPermission(sender, "heal.self");
|
||||
plugin.checkPermission(sender, "worldguard.heal");
|
||||
Player player = (Player)sender;
|
||||
player.setHealth(20);
|
||||
player.sendMessage(ChatColor.YELLOW + "You have been healed!");
|
||||
|
@ -20,7 +20,8 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -33,7 +34,10 @@
|
||||
*/
|
||||
public class CommandLocate extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
@ -41,7 +45,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
cfg.checkPermission(player, "locate");
|
||||
plugin.checkPermission(sender, "worldguard.locate");
|
||||
CommandHandler.checkArgs(args, 0, 3);
|
||||
|
||||
if (args.length == 1) {
|
||||
|
@ -19,11 +19,13 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.RegionUtil;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -35,7 +37,11 @@
|
||||
*/
|
||||
public class CommandRegionAddMember extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
|
||||
boolean cmdIsOwner = command.equalsIgnoreCase("addowner");
|
||||
@ -45,12 +51,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
|
||||
if (cmdIsOwner) {
|
||||
CommandHandler.checkArgs(args, 2, -1, "/region addowner <id> [player1 [group1 [players/groups...]]]");
|
||||
permOwn = "region.addowner.own";
|
||||
permAll = "region.addowner.all";
|
||||
permOwn = "worldguard.region.addowner.own";
|
||||
permAll = "worldguard.region.addowner";
|
||||
} else {
|
||||
CommandHandler.checkArgs(args, 2, -1, "/region addmember <id> [player1 [group1 [players/groups...]]]");
|
||||
permOwn = "region.addmember.own";
|
||||
permAll = "region.addmember.all";
|
||||
permOwn = "worldguard.region.addmember.own";
|
||||
permAll = "worldguard.region.addmember";
|
||||
}
|
||||
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||
@ -67,22 +73,22 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, permOwn);
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, permOwn);
|
||||
}
|
||||
else {
|
||||
cfg.checkRegionPermission(sender, permAll);
|
||||
plugin.checkPermission(sender, permAll);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.checkRegionPermission(sender, permAll);
|
||||
plugin.checkPermission(sender, permAll);
|
||||
}
|
||||
|
||||
if (cmdIsOwner) {
|
||||
WorldGuardConfiguration.addToDomain(existing.getOwners(), args, 1);
|
||||
RegionUtil.addToDomain(existing.getOwners(), args, 1);
|
||||
} else {
|
||||
WorldGuardConfiguration.addToDomain(existing.getMembers(), args, 1);
|
||||
RegionUtil.addToDomain(existing.getMembers(), args, 1);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -26,8 +26,9 @@
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@ -50,7 +51,11 @@
|
||||
*/
|
||||
public class CommandRegionClaim extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
@ -64,14 +69,14 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
return true;
|
||||
}
|
||||
|
||||
cfg.checkRegionPermission(player, "region.claim");
|
||||
plugin.checkPermission(player, "worldguard.region.claim");
|
||||
CommandHandler.checkArgs(args, 1, 1, "/region claim <id>");
|
||||
|
||||
try {
|
||||
String id = args[0].toLowerCase();
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
|
||||
LocalPlayer lPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
LocalPlayer lPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||
|
||||
if (mgr.getRegionCountOfPlayer(lPlayer) >= wcfg.maxRegionCountPerPlayer) {
|
||||
player.sendMessage(ChatColor.RED + "You own too much regions, delete one first to claim a new one.");
|
||||
|
@ -26,13 +26,15 @@
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.RegionUtil;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
@ -46,7 +48,11 @@
|
||||
*/
|
||||
public class CommandRegionDefine extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
@ -59,7 +65,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
sender.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled!");
|
||||
return true;
|
||||
}
|
||||
cfg.checkRegionPermission(sender, "region.define");
|
||||
plugin.checkPermission(sender, "worldguard.region.define");
|
||||
CommandHandler.checkArgs(args, 1, -1, "/region define <id> [owner1 [owner2 [owners...]]]");
|
||||
|
||||
try {
|
||||
@ -85,7 +91,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
region.setOwners(WorldGuardConfiguration.parseDomainString(args, 1));
|
||||
region.setOwners(RegionUtil.parseDomainString(args, 1));
|
||||
}
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(w.getName());
|
||||
mgr.addRegion(region);
|
||||
|
@ -19,8 +19,9 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
@ -34,8 +35,11 @@
|
||||
* @author Michael
|
||||
*/
|
||||
public class CommandRegionDelete extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 0, 1, "/region delete <id>");
|
||||
|
||||
@ -54,13 +58,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.delete.own");
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.delete.own");
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.delete.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.delete");
|
||||
}
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.delete.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.delete");
|
||||
}
|
||||
|
||||
mgr.removeRegion(id);
|
||||
|
@ -20,8 +20,9 @@
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
@ -40,8 +41,11 @@
|
||||
* @author Michael
|
||||
*/
|
||||
public class CommandRegionFlag extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 2, -1, "/region flag <regionid> <name> (<value>) [no value to unset flag]");
|
||||
|
||||
@ -71,15 +75,15 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.flag.ownregions");
|
||||
} else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.flag.memberregions");
|
||||
if (region.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.own");
|
||||
} else if (region.isMember(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.flag.member");
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.flag.foreignregions");
|
||||
plugin.checkPermission(sender, "worldguard.region.flag");
|
||||
}
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.flag.foreignregions");
|
||||
plugin.checkPermission(sender, "worldguard.region.flag");
|
||||
}
|
||||
|
||||
RegionFlagInfo nfo = FlagDatabase.getFlagInfoFromName(nameStr);
|
||||
|
@ -19,8 +19,9 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
@ -38,7 +39,11 @@
|
||||
*/
|
||||
public class CommandRegionInfo extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 1, 1, "/region info <id>");
|
||||
|
||||
@ -55,15 +60,15 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.info.ownregions");
|
||||
} else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.info.memberregions");
|
||||
if (region.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.info.own");
|
||||
} else if (region.isMember(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.info.member");
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.info.foreignregions");
|
||||
plugin.checkPermission(sender, "worldguard.region.info");
|
||||
}
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.info.foreignregions");
|
||||
plugin.checkPermission(sender, "worldguard.region.info");
|
||||
}
|
||||
|
||||
RegionFlagContainer flags = region.getFlags();
|
||||
|
@ -19,8 +19,9 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
@ -35,9 +36,13 @@
|
||||
*/
|
||||
public class CommandRegionList extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
cfg.checkRegionPermission(sender, "region.list");
|
||||
plugin.checkPermission(sender, "worldguard.region.list");
|
||||
CommandHandler.checkArgs(args, 0, 1, "/region list [page]");
|
||||
|
||||
int page = 0;
|
||||
|
@ -19,8 +19,9 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import java.io.IOException;
|
||||
@ -32,9 +33,14 @@
|
||||
*/
|
||||
public class CommandRegionLoad extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
|
||||
cfg.checkRegionPermission(sender, "region.load");
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
plugin.checkPermission(sender, "worldguard.region.load");
|
||||
CommandHandler.checkArgs(args, 0, 0, "/region load");
|
||||
|
||||
try {
|
||||
|
@ -19,8 +19,9 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
@ -35,7 +36,12 @@
|
||||
*/
|
||||
public class CommandRegionPriority extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 1, 2, "/region priority <id> (<value>)");
|
||||
|
||||
@ -54,13 +60,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.priority.own");
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.priority.own");
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.priority.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.priority");
|
||||
}
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.priority.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.priority");
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
|
@ -20,11 +20,13 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.RegionUtil;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -36,7 +38,12 @@
|
||||
*/
|
||||
public class CommandRegionRemoveMember extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
boolean cmdIsOwner = command.equalsIgnoreCase("removeowner");
|
||||
String permOwn;
|
||||
@ -44,12 +51,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
|
||||
if (cmdIsOwner) {
|
||||
CommandHandler.checkArgs(args, 2, -1, "/region removeowner <id> [player1 [group1 [players/groups...]]]");
|
||||
permOwn = "region.removeowner.own";
|
||||
permAll = "region.removeowner.all";
|
||||
permOwn = "worldguard.region.removeowner.own";
|
||||
permAll = "worldguard.region.removeowner";
|
||||
} else {
|
||||
CommandHandler.checkArgs(args, 2, -1, "/region removemember <id> [player1 [group1 [players/groups...]]]");
|
||||
permOwn = "region.removemember.own";
|
||||
permAll = "region.removemember.all";
|
||||
permOwn = "worldguard.region.removemember.own";
|
||||
permAll = "worldguard.region.removemember";
|
||||
}
|
||||
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||
@ -66,23 +73,23 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, permOwn);
|
||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, permOwn);
|
||||
}
|
||||
else {
|
||||
cfg.checkRegionPermission(sender, permAll);
|
||||
plugin.checkPermission(sender, permAll);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.checkRegionPermission(sender, permAll);
|
||||
plugin.checkPermission(sender, permAll);
|
||||
}
|
||||
|
||||
|
||||
if (cmdIsOwner) {
|
||||
WorldGuardConfiguration.removeFromDomain(existing.getOwners(), args, 1);
|
||||
RegionUtil.removeFromDomain(existing.getOwners(), args, 1);
|
||||
} else {
|
||||
WorldGuardConfiguration.removeFromDomain(existing.getMembers(), args, 1);
|
||||
RegionUtil.removeFromDomain(existing.getMembers(), args, 1);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -19,8 +19,9 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import java.io.IOException;
|
||||
@ -33,9 +34,14 @@
|
||||
*/
|
||||
public class CommandRegionSave extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
|
||||
cfg.checkRegionPermission(sender, "region.save");
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
plugin.checkPermission(sender, "worldguard.region.save");
|
||||
CommandHandler.checkArgs(args, 0, 0, "/region save");
|
||||
|
||||
try {
|
||||
|
@ -19,8 +19,9 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
@ -36,7 +37,12 @@
|
||||
*/
|
||||
public class CommandRegionSetParent extends WgRegionCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 1, 2, "/region setparent <id> <parent-id>");
|
||||
|
||||
@ -54,13 +60,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.setparent.own");
|
||||
if (region.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.own");
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||
}
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||
}
|
||||
|
||||
ProtectedRegion parent = null;
|
||||
@ -77,13 +83,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (parent.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||
cfg.checkRegionPermission(sender, "region.setparent.own");
|
||||
if (parent.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent.own");
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||
}
|
||||
} else {
|
||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.LoggerToChatHandler;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -32,9 +33,12 @@
|
||||
*/
|
||||
public class CommandReloadWG extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
cfg.checkPermission(sender, "reloadwg");
|
||||
plugin.checkPermission(sender, "worldguard.reload");
|
||||
CommandHandler.checkArgs(args, 0, 0);
|
||||
|
||||
LoggerToChatHandler handler = null;
|
||||
@ -48,8 +52,8 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
|
||||
try {
|
||||
cfg.onDisable();
|
||||
cfg.onEnable();
|
||||
cfg.unload();
|
||||
cfg.load();
|
||||
|
||||
sender.sendMessage("WorldGuard configuration reloaded.");
|
||||
} catch (Throwable t) {
|
||||
|
@ -20,7 +20,8 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -32,13 +33,16 @@
|
||||
*/
|
||||
public class CommandSlay extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
CommandHandler.checkArgs(args, 0, 1);
|
||||
|
||||
// Allow killing other people
|
||||
if (args.length > 0) {
|
||||
cfg.checkPermission(sender, "slay.others");
|
||||
plugin.checkPermission(sender, "worldguard.slay.other");
|
||||
|
||||
Player other = BukkitUtil.matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||
if (other == null) {
|
||||
@ -49,7 +53,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
other.sendMessage(ChatColor.YELLOW + senderName + " has killed you!");
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
cfg.checkPermission(sender, "slay.self");
|
||||
plugin.checkPermission(sender, "worldguard.slay");
|
||||
|
||||
Player player = (Player)sender;
|
||||
player.setHealth(0);
|
||||
|
@ -20,7 +20,8 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -33,14 +34,17 @@
|
||||
*/
|
||||
public class CommandStack extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
cfg.checkPermission(player, "stack");
|
||||
plugin.checkPermission(sender, "worldguard.stack");
|
||||
CommandHandler.checkArgs(args, 0, 0);
|
||||
|
||||
ItemStack[] items = player.getInventory().getContents();
|
||||
|
@ -19,8 +19,9 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
@ -33,9 +34,12 @@
|
||||
*/
|
||||
public class CommandStopFire extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
cfg.checkPermission(sender, "stopfire");
|
||||
plugin.checkPermission(sender, "worldguard.fire-toggle.stop");
|
||||
CommandHandler.checkArgs(args, 0, 0);
|
||||
|
||||
String worldName;
|
||||
@ -55,7 +59,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
return true;
|
||||
}
|
||||
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||
|
||||
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -23,21 +24,25 @@
|
||||
*/
|
||||
public class CommandTpRegion extends WgCommand {
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
cfg.checkPermission(sender, "tpregion");
|
||||
plugin.checkPermission(sender, "worldguard.region.teleport");
|
||||
|
||||
CommandHandler.checkArgs(args, 1, 2, "/tpregion <region name> {spawn}");
|
||||
|
||||
String id = args[0];
|
||||
Boolean spawn = false;
|
||||
if (args.length == 2 && args[1].equals("spawn")) {
|
||||
cfg.checkPermission(player, "tpregion.spawn");
|
||||
plugin.checkPermission(sender, "worldguard.region.teleport.spawn");
|
||||
spawn = true;
|
||||
}
|
||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||
@ -51,14 +56,14 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
flagright = region.getFlags().getRegionGroupFlag(Flags.TELE_PERM).getValue(RegionGroup.ALL);
|
||||
}
|
||||
|
||||
LocalPlayer lPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
LocalPlayer lPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||
if (flagright == RegionGroup.OWNER) {
|
||||
if (!region.isOwner(lPlayer)) {
|
||||
cfg.checkPermission(player, "tpregion.override");
|
||||
plugin.checkPermission(sender, "worldguard.region.teleport.override");
|
||||
}
|
||||
} else if (flagright == RegionGroup.MEMBER) {
|
||||
if (!region.isMember(lPlayer)) {
|
||||
cfg.checkPermission(player, "tpregion.override");
|
||||
plugin.checkPermission(sender, "worldguard.region.teleport.override");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,9 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -70,8 +71,10 @@ public RegionCommandHandler() {
|
||||
this.aliasMap.put("rlist", "list");
|
||||
this.aliasMap.put("rp", "priority");
|
||||
}
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException {
|
||||
|
||||
String worldName;
|
||||
String subCommand;
|
||||
@ -110,7 +113,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
return true;
|
||||
}
|
||||
|
||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||
WorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||
|
||||
if (!wcfg.useRegions) {
|
||||
sender.sendMessage(ChatColor.RED + "Regions are disabled in this world.");
|
||||
@ -131,7 +134,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
|
||||
cfg.getWorldGuardPlugin().getGlobalRegionManager().reloadDataWhereRequired();
|
||||
wgcmd.handle(sender, senderName, subCommand, subArgs, cfg, wcfg);
|
||||
wgcmd.handle(sender, senderName, subCommand, subArgs, cfg, wcfg, plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -30,6 +31,8 @@
|
||||
*/
|
||||
public abstract class WgCommand {
|
||||
|
||||
public abstract boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException;
|
||||
public abstract boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException;
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,9 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -31,6 +32,9 @@
|
||||
*/
|
||||
public abstract class WgRegionCommand {
|
||||
|
||||
public abstract boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException;
|
||||
public abstract boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, GlobalConfiguration cfg,
|
||||
WorldConfiguration wcfg, WorldGuardPlugin plugin)
|
||||
throws CommandHandlingException;
|
||||
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ public class ApplicableRegionSet {
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param pt
|
||||
* @param regions
|
||||
* @param applicable
|
||||
* @param global
|
||||
*/
|
||||
public ApplicableRegionSet(List<ProtectedRegion> applicable, GlobalFlags global) {
|
||||
@ -105,7 +104,7 @@ public boolean isStateFlagAllowed(StateRegionFlagInfo info, boolean def, LocalPl
|
||||
return getStateFlag(info, true).getValue(defState) == State.ALLOW || this.isMember(player);
|
||||
}
|
||||
|
||||
private RegionFlag getFlag(RegionFlagInfo info, Boolean inherit) {
|
||||
private RegionFlag getFlag(RegionFlagInfo<?> info, Boolean inherit) {
|
||||
|
||||
ProtectedRegion region = affectedRegion;
|
||||
|
||||
|
@ -139,7 +139,7 @@ public void run() {
|
||||
}
|
||||
|
||||
//check passthrough flag
|
||||
LocalPlayer lplayer = BukkitPlayer.wrapPlayer(wg.getWgConfiguration(), player);
|
||||
LocalPlayer lplayer = BukkitPlayer.wrapPlayer(wg, player);
|
||||
if(!regions.isStateFlagAllowed(Flags.PASSTHROUGH, lplayer))
|
||||
{
|
||||
Location newLoc = player.getLocation().clone();
|
||||
@ -153,7 +153,7 @@ public void run() {
|
||||
|
||||
public void broadcastNotification(String msg) {
|
||||
for (Player player : wg.getServer().getOnlinePlayers()) {
|
||||
if (wg.getWgConfiguration().hasPermission(player, "notify_onenter")) {
|
||||
if (wg.hasPermission(player, "notify_onenter")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ public Map<String, ProtectedRegion> getRegions() {
|
||||
ret.putAll(this.pRegions);
|
||||
|
||||
for (Map.Entry<String, ProtectedRegion> entry : ret.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
ProtectedRegion region = entry.getValue();
|
||||
|
||||
String parentId = region.getParentId();
|
||||
|
@ -36,7 +36,7 @@
|
||||
* @author Redecouverte
|
||||
*/
|
||||
public class JSONDatabase implements ProtectionDatabase {
|
||||
private static Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
protected static Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
/**
|
||||
* References the json db folder.
|
||||
@ -111,6 +111,8 @@ public void save() throws IOException {
|
||||
/**
|
||||
* Writes a String to a file.
|
||||
*
|
||||
* @param string
|
||||
* @param file
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void writeStringToFile(String string, File file) throws IOException {
|
||||
@ -160,8 +162,6 @@ public Map<String,ProtectedRegion> getRegions() {
|
||||
|
||||
/**
|
||||
* Get a list of protected regions.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void setRegions(Map<String,ProtectedRegion> regions) {
|
||||
this.regions = regions;
|
||||
|
@ -46,12 +46,14 @@ public interface ProtectionDatabase {
|
||||
/**
|
||||
* Load the list of regions into a region manager.
|
||||
*
|
||||
* @param manager
|
||||
* @throws IOException
|
||||
*/
|
||||
public void load(RegionManager manager) throws IOException;
|
||||
/**
|
||||
* Save the list of regions from a region manager.
|
||||
*
|
||||
* @param manager
|
||||
* @throws IOException
|
||||
*/
|
||||
public void save(RegionManager manager) throws IOException;
|
||||
|
100
src/com/sk89q/worldguard/protection/dbs/RegionDBUtil.java
Normal file
100
src/com/sk89q/worldguard/protection/dbs/RegionDBUtil.java
Normal file
@ -0,0 +1,100 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection.dbs;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
|
||||
/**
|
||||
* Various utility functions for parsing region databases.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class RegionDBUtil {
|
||||
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
|
||||
|
||||
private RegionDBUtil() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param domain
|
||||
* @param split
|
||||
* @param startIndex
|
||||
*/
|
||||
public static void addToDomain(DefaultDomain domain, String[] split,
|
||||
int startIndex) {
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
domain.addPlayer(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param domain
|
||||
* @param split
|
||||
* @param startIndex
|
||||
*/
|
||||
public static void removeFromDomain(DefaultDomain domain, String[] split,
|
||||
int startIndex) {
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.removeGroup(m.group(1));
|
||||
} else {
|
||||
domain.removePlayer(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param split
|
||||
* @param startIndex
|
||||
* @return
|
||||
*/
|
||||
public static DefaultDomain parseDomainString(String[] split, int startIndex) {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
domain.addPlayer(s);
|
||||
}
|
||||
}
|
||||
|
||||
return domain;
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -48,6 +47,10 @@ public class FlatRegionManager extends RegionManager {
|
||||
|
||||
/**
|
||||
* Construct the manager.
|
||||
*
|
||||
* @param global
|
||||
* @param regionloader
|
||||
* @throws IOException
|
||||
*/
|
||||
public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
||||
|
||||
@ -61,15 +64,15 @@ public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) th
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, ProtectedRegion> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a list of protected regions.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void setRegions(Map<String, ProtectedRegion> regions) {
|
||||
this.regions = new TreeMap<String, ProtectedRegion>(regions);
|
||||
}
|
||||
@ -77,9 +80,9 @@ public void setRegions(Map<String, ProtectedRegion> regions) {
|
||||
/**
|
||||
* Adds a region.
|
||||
*
|
||||
* @param id
|
||||
* @param region
|
||||
*/
|
||||
@Override
|
||||
public void addRegion(ProtectedRegion region) {
|
||||
regions.put(region.getId(), region);
|
||||
}
|
||||
@ -89,6 +92,7 @@ public void addRegion(ProtectedRegion region) {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void removeRegion(String id) {
|
||||
ProtectedRegion region = regions.get(id);
|
||||
|
||||
@ -117,6 +121,7 @@ public void removeRegion(String id) {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRegion(String id) {
|
||||
return regions.containsKey(id);
|
||||
}
|
||||
@ -126,6 +131,7 @@ public boolean hasRegion(String id) {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public ProtectedRegion getRegion(String id) {
|
||||
return regions.get(id);
|
||||
}
|
||||
@ -136,6 +142,7 @@ public ProtectedRegion getRegion(String id) {
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
@ -152,9 +159,9 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
/**
|
||||
* Get an object for a region for rules to be applied with.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
@ -176,6 +183,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
List<String> applicable = new ArrayList<String>();
|
||||
|
||||
@ -192,10 +200,10 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
* Returns true if the provided region overlaps with any other region that
|
||||
* is not owned by the player.
|
||||
*
|
||||
* @param region
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
@ -223,6 +231,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return regions.size();
|
||||
}
|
||||
@ -232,6 +241,7 @@ public int size() {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void save() throws IOException {
|
||||
if (this.regionloader == null) {
|
||||
return;
|
||||
@ -240,6 +250,7 @@ public void save() throws IOException {
|
||||
regionloader.save(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionCountOfPlayer(LocalPlayer player) {
|
||||
int count = 0;
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.World;
|
||||
|
||||
@ -57,11 +55,11 @@ public void onEnable() {
|
||||
loadWorld(w.getName());
|
||||
}
|
||||
|
||||
wg.getWgConfiguration().onEnable();
|
||||
wg.getGlobalConfiguration().load();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
wg.getWgConfiguration().onDisable();
|
||||
wg.getGlobalConfiguration().unload();
|
||||
}
|
||||
|
||||
private void loadWorld(String name) {
|
||||
|
@ -30,7 +30,6 @@
|
||||
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegionMBRConverter;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
@ -53,6 +52,10 @@ public class PRTreeRegionManager extends RegionManager {
|
||||
|
||||
/**
|
||||
* Construct the manager.
|
||||
*
|
||||
* @param global
|
||||
* @param regionloader
|
||||
* @throws IOException
|
||||
*/
|
||||
public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
||||
super(global, regionloader);
|
||||
@ -66,15 +69,15 @@ public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, ProtectedRegion> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a list of protected regions.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void setRegions(Map<String, ProtectedRegion> regions) {
|
||||
this.regions = new TreeMap<String, ProtectedRegion>(regions);
|
||||
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
||||
@ -84,9 +87,9 @@ public void setRegions(Map<String, ProtectedRegion> regions) {
|
||||
/**
|
||||
* Adds a region.
|
||||
*
|
||||
* @param id
|
||||
* @param region
|
||||
*/
|
||||
@Override
|
||||
public void addRegion(ProtectedRegion region) {
|
||||
regions.put(region.getId(), region);
|
||||
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
||||
@ -99,6 +102,7 @@ public void addRegion(ProtectedRegion region) {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRegion(String id) {
|
||||
return regions.containsKey(id);
|
||||
}
|
||||
@ -108,6 +112,7 @@ public boolean hasRegion(String id) {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public ProtectedRegion getRegion(String id) {
|
||||
return regions.get(id);
|
||||
}
|
||||
@ -117,6 +122,7 @@ public ProtectedRegion getRegion(String id) {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void removeRegion(String id) {
|
||||
ProtectedRegion region = regions.get(id);
|
||||
|
||||
@ -148,6 +154,7 @@ public void removeRegion(String id) {
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
@ -164,6 +171,7 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
return new ApplicableRegionSet(appRegions, global);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
appRegions.addAll(regions.values());
|
||||
@ -184,6 +192,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
List<String> applicable = new ArrayList<String>();
|
||||
|
||||
@ -203,10 +212,10 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
* Returns true if the provided region overlaps with any other region that
|
||||
* is not owned by the player.
|
||||
*
|
||||
* @param region
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
@ -233,6 +242,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return regions.size();
|
||||
}
|
||||
@ -242,10 +252,12 @@ public int size() {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void save() throws IOException {
|
||||
regionloader.save(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegionCountOfPlayer(LocalPlayer player) {
|
||||
int count = 0;
|
||||
|
||||
|
@ -101,14 +101,13 @@ public void load() throws IOException
|
||||
/**
|
||||
* Set a list of protected regions.
|
||||
*
|
||||
* @return
|
||||
* @param regions
|
||||
*/
|
||||
public abstract void setRegions(Map<String,ProtectedRegion> regions);
|
||||
|
||||
/**
|
||||
* Adds a region.
|
||||
*
|
||||
* @param id
|
||||
* @param region
|
||||
*/
|
||||
public abstract void addRegion(ProtectedRegion region);
|
||||
@ -125,6 +124,7 @@ public void load() throws IOException
|
||||
* Get a region by its ID.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public abstract ProtectedRegion getRegion(String id);
|
||||
|
||||
@ -147,7 +147,7 @@ public void load() throws IOException
|
||||
/**
|
||||
* Get an object for a point for rules to be applied with.
|
||||
*
|
||||
* @param pt
|
||||
* @param region
|
||||
* @return
|
||||
*/
|
||||
public abstract ApplicableRegionSet getApplicableRegions(ProtectedRegion region);
|
||||
@ -181,10 +181,9 @@ public void load() throws IOException
|
||||
/**
|
||||
* Sets the global flags.
|
||||
*
|
||||
* @return
|
||||
* @param globalflags
|
||||
*/
|
||||
public void setGlobalFlags(GlobalFlags globalflags)
|
||||
{
|
||||
public void setGlobalFlags(GlobalFlags globalflags) {
|
||||
global = globalflags;
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,8 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
* Construct a new instance of this cuboid region.
|
||||
*
|
||||
* @param id
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
* @param priority
|
||||
* @param min
|
||||
* @param max
|
||||
*/
|
||||
public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) {
|
||||
super(id);
|
||||
@ -59,6 +58,7 @@ public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) {
|
||||
*
|
||||
* @return min point
|
||||
*/
|
||||
@Override
|
||||
public BlockVector getMinimumPoint() {
|
||||
return min;
|
||||
}
|
||||
@ -77,6 +77,7 @@ public void setMinimumPoint(BlockVector pt) {
|
||||
*
|
||||
* @return max point
|
||||
*/
|
||||
@Override
|
||||
public BlockVector getMaximumPoint() {
|
||||
return max;
|
||||
}
|
||||
@ -129,6 +130,7 @@ public boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersec
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
int numRegions = regions.size();
|
||||
List<ProtectedRegion> intersectingRegions = new ArrayList<ProtectedRegion>();
|
||||
@ -257,6 +259,7 @@ public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> region
|
||||
*
|
||||
* @return type of region
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "cuboid";
|
||||
}
|
||||
@ -266,6 +269,7 @@ public String getTypeName() {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int countBlocks() {
|
||||
int xLength = max.getBlockX() - min.getBlockX() + 1;
|
||||
int yLength = max.getBlockY() - min.getBlockY() + 1;
|
||||
|
@ -136,8 +136,7 @@ public boolean contains(Vector pt) {
|
||||
return inside;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
int numRegions = regions.size();
|
||||
int numPoints = points.size();
|
||||
@ -269,6 +268,7 @@ public String getTypeName() {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int countBlocks() {
|
||||
int volume = 0;
|
||||
int numPoints = points.size();
|
||||
|
@ -143,7 +143,7 @@ public ProtectedRegion getParent() {
|
||||
* Set the curParent. This checks to make sure that it will not result
|
||||
* in circular inheritance.
|
||||
*
|
||||
* @param curParent the curParent to setFlag
|
||||
* @param parent the curParent to setFlag
|
||||
* @throws CircularInheritanceException
|
||||
*/
|
||||
public void setParent(ProtectedRegion parent) throws CircularInheritanceException {
|
||||
@ -192,7 +192,7 @@ public DefaultDomain getMembers() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param owners the owners to setFlag
|
||||
* @param members the members to setFlag
|
||||
*/
|
||||
public void setMembers(DefaultDomain members) {
|
||||
this.members = members;
|
||||
|
@ -75,15 +75,4 @@ public enum FlagType {
|
||||
public static RegionGroupRegionFlagInfo TELE_PERM = new RegionGroupRegionFlagInfo("teleperm", FlagType.TELE_PERM);
|
||||
public static RegionGroupRegionFlagInfo SPAWN_PERM = new RegionGroupRegionFlagInfo("spawnperm", FlagType.SPAWN_PERM);
|
||||
|
||||
|
||||
private static Integer initCount = 0;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
// this will init all static fields
|
||||
|
||||
// change some field's value to make sure this function
|
||||
// is not erased for optimization
|
||||
initCount++;
|
||||
}
|
||||
}
|
||||
|
100
src/com/sk89q/worldguard/util/RegionUtil.java
Normal file
100
src/com/sk89q/worldguard/util/RegionUtil.java
Normal file
@ -0,0 +1,100 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
|
||||
/**
|
||||
* Various utility functions for regions.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class RegionUtil {
|
||||
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
|
||||
|
||||
private RegionUtil() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param domain
|
||||
* @param split
|
||||
* @param startIndex
|
||||
*/
|
||||
public static void addToDomain(DefaultDomain domain, String[] split,
|
||||
int startIndex) {
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
domain.addPlayer(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param domain
|
||||
* @param split
|
||||
* @param startIndex
|
||||
*/
|
||||
public static void removeFromDomain(DefaultDomain domain, String[] split,
|
||||
int startIndex) {
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.removeGroup(m.group(1));
|
||||
} else {
|
||||
domain.removePlayer(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a group/player DefaultDomain specification for areas.
|
||||
*
|
||||
* @param split
|
||||
* @param startIndex
|
||||
* @return
|
||||
*/
|
||||
public static DefaultDomain parseDomainString(String[] split, int startIndex) {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
|
||||
for (int i = startIndex; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
Matcher m = groupPattern.matcher(s);
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
domain.addPlayer(s);
|
||||
}
|
||||
}
|
||||
|
||||
return domain;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user