mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 07:38:12 +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.
|
* Get the entries for an item or list.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<BlacklistEntry> getEntries(int id) {
|
public List<BlacklistEntry> getEntries(int id) {
|
||||||
return blacklist.get(id);
|
return blacklist.get(id);
|
||||||
@ -119,7 +122,6 @@ public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent)
|
|||||||
* Load the blacklist.
|
* Load the blacklist.
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* @return
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void load(File file) throws IOException {
|
public void load(File file) throws IOException {
|
||||||
@ -242,6 +244,7 @@ public BlacklistEvent getLastEvent() {
|
|||||||
* Notify administrators.
|
* Notify administrators.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
|
* @param comment
|
||||||
*/
|
*/
|
||||||
public void notify(BlacklistEvent event, String comment) {
|
public void notify(BlacklistEvent event, String comment) {
|
||||||
lastEvent = event;
|
lastEvent = event;
|
||||||
@ -272,8 +275,6 @@ public void forgetPlayer(LocalPlayer player) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Forget all players.
|
* Forget all players.
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
*/
|
*/
|
||||||
public void forgetAllPlayers() {
|
public void forgetAllPlayers() {
|
||||||
lastAffected.clear();
|
lastAffected.clear();
|
||||||
|
@ -107,7 +107,7 @@ public String[] getDestroyWithActions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param action
|
* @param actions
|
||||||
*/
|
*/
|
||||||
public void setDestroyWithActions(String[] actions) {
|
public void setDestroyWithActions(String[] actions) {
|
||||||
this.destroyWithActions = actions;
|
this.destroyWithActions = actions;
|
||||||
@ -266,6 +266,7 @@ private String[] getActions(BlacklistEvent event) {
|
|||||||
/**
|
/**
|
||||||
* Method to handle the event.
|
* Method to handle the event.
|
||||||
*
|
*
|
||||||
|
* @param useAsWhitelist
|
||||||
* @param event
|
* @param event
|
||||||
* @param forceRepeat
|
* @param forceRepeat
|
||||||
* @param silent
|
* @param silent
|
||||||
|
@ -55,8 +55,6 @@ public void removeHandler(BlacklistLoggerHandler handler) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a handler.
|
* Add a handler.
|
||||||
*
|
|
||||||
* @param handler
|
|
||||||
*/
|
*/
|
||||||
public void clearHandlers() {
|
public void clearHandlers() {
|
||||||
handlers.clear();
|
handlers.clear();
|
||||||
@ -65,7 +63,6 @@ public void clearHandlers() {
|
|||||||
/**
|
/**
|
||||||
* Log an event.
|
* Log an event.
|
||||||
*
|
*
|
||||||
* @param player
|
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void logEvent(BlacklistEvent event, String comment) {
|
public void logEvent(BlacklistEvent event, String comment) {
|
||||||
|
@ -32,7 +32,7 @@ public class BlacklistTrackedEvent {
|
|||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param event
|
||||||
* @param time
|
* @param time
|
||||||
*/
|
*/
|
||||||
public BlacklistTrackedEvent(BlacklistEvent event, long time) {
|
public BlacklistTrackedEvent(BlacklistEvent event, long time) {
|
||||||
|
@ -32,6 +32,7 @@ public BlockBreakBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "break";
|
return "break";
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public BlockInteractBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "interact with";
|
return "interact with";
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public BlockPlaceBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "place";
|
return "place";
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public DestroyWithBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "destroy with";
|
return "destroy with";
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public ItemAcquireBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "acquire";
|
return "acquire";
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public ItemDropBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "drop";
|
return "drop";
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public ItemUseBlacklistEvent(LocalPlayer player, Vector pos, int type) {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "use";
|
return "use";
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ public ConsoleLoggerHandler(String worldName)
|
|||||||
/**
|
/**
|
||||||
* Log an event.
|
* Log an event.
|
||||||
*
|
*
|
||||||
* @param player
|
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void logEvent(BlacklistEvent event, String comment) {
|
public void logEvent(BlacklistEvent event, String comment) {
|
||||||
|
@ -76,6 +76,8 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
* @param dsn
|
* @param dsn
|
||||||
* @param user
|
* @param user
|
||||||
* @param pass
|
* @param pass
|
||||||
|
* @param table
|
||||||
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName) {
|
public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName) {
|
||||||
this.dsn = dsn;
|
this.dsn = dsn;
|
||||||
@ -136,7 +138,6 @@ private void logEvent(String event, LocalPlayer player, Vector pos, int item,
|
|||||||
/**
|
/**
|
||||||
* Log an event.
|
* Log an event.
|
||||||
*
|
*
|
||||||
* @param player
|
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void logEvent(BlacklistEvent event, String comment) {
|
public void logEvent(BlacklistEvent event, String comment) {
|
||||||
|
@ -71,6 +71,7 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param pathPattern
|
* @param pathPattern
|
||||||
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public FileLoggerHandler(String pathPattern, String worldName) {
|
public FileLoggerHandler(String pathPattern, String worldName) {
|
||||||
this.pathPattern = pathPattern;
|
this.pathPattern = pathPattern;
|
||||||
@ -82,6 +83,7 @@ public FileLoggerHandler(String pathPattern, String worldName) {
|
|||||||
*
|
*
|
||||||
* @param pathPattern
|
* @param pathPattern
|
||||||
* @param cacheSize
|
* @param cacheSize
|
||||||
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public FileLoggerHandler(String pathPattern, int cacheSize, String worldName) {
|
public FileLoggerHandler(String pathPattern, int cacheSize, String worldName) {
|
||||||
if (cacheSize < 1) {
|
if (cacheSize < 1) {
|
||||||
@ -236,7 +238,6 @@ private void logEvent(BlacklistEvent event, String text, int id, Vector pos, Str
|
|||||||
/**
|
/**
|
||||||
* Log an event.
|
* Log an event.
|
||||||
*
|
*
|
||||||
* @param player
|
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void logEvent(BlacklistEvent event, String comment) {
|
public void logEvent(BlacklistEvent event, String comment) {
|
||||||
|
@ -42,6 +42,7 @@ public class FileLoggerWriter implements Comparable<FileLoggerWriter> {
|
|||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
|
* @param path
|
||||||
* @param writer
|
* @param writer
|
||||||
*/
|
*/
|
||||||
public FileLoggerWriter(String path, BufferedWriter writer) {
|
public FileLoggerWriter(String path, BufferedWriter writer) {
|
||||||
@ -75,8 +76,6 @@ public long getLastUse() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update last use time.
|
* Update last use time.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public void updateLastUse() {
|
public void updateLastUse() {
|
||||||
lastUse = System.currentTimeMillis();
|
lastUse = System.currentTimeMillis();
|
||||||
|
@ -30,9 +30,10 @@ public BukkitBlacklist(Boolean useAsWhitelist, WorldGuardPlugin plugin) {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void broadcastNotification(String msg) {
|
public void broadcastNotification(String msg) {
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
if (plugin.getWgConfiguration().hasPermission(player, "notify")) {
|
if (plugin.hasPermission(player, "notify")) {
|
||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,15 @@
|
|||||||
|
|
||||||
public class BukkitPlayer extends LocalPlayer {
|
public class BukkitPlayer extends LocalPlayer {
|
||||||
private Player player;
|
private Player player;
|
||||||
private WorldGuardConfiguration config;
|
private WorldGuardPlugin plugin;
|
||||||
|
|
||||||
public BukkitPlayer(WorldGuardConfiguration config, Player player) {
|
public BukkitPlayer(WorldGuardPlugin plugin, Player player) {
|
||||||
this.config = config;
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BukkitPlayer wrapPlayer(WorldGuardConfiguration config, Player player) {
|
public static BukkitPlayer wrapPlayer(WorldGuardPlugin plugin, Player player) {
|
||||||
return new BukkitPlayer(config, player);
|
return new BukkitPlayer(plugin, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +44,7 @@ public String getName() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasGroup(String group) {
|
public boolean hasGroup(String group) {
|
||||||
return config.inGroup(player, group);
|
return plugin.inGroup(player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,7 +65,7 @@ public void ban(String msg) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getGroups() {
|
public String[] getGroups() {
|
||||||
return config.getGroups(player);
|
return plugin.getGroups(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.
|
* Close the handler.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush the output.
|
* Flush the output.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish a log record.
|
* Publish a log record.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void publish(LogRecord record) {
|
public void publish(LogRecord record) {
|
||||||
player.sendMessage(ChatColor.GRAY + record.getLevel().getName() + ": "
|
player.sendMessage(ChatColor.GRAY + record.getLevel().getName() + ": "
|
||||||
+ ChatColor.WHITE + record.getMessage());
|
+ ChatColor.WHITE + record.getMessage());
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit;
|
package com.sk89q.worldguard.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||||
@ -28,24 +27,24 @@
|
|||||||
import com.sk89q.worldguard.protection.GlobalFlags;
|
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Michael
|
* @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 String worldName;
|
||||||
private File configFile;
|
private File configFile;
|
||||||
@ -53,7 +52,6 @@ public class WorldGuardWorldConfiguration {
|
|||||||
|
|
||||||
private Blacklist blacklist;
|
private Blacklist blacklist;
|
||||||
|
|
||||||
|
|
||||||
/* Configuration data start */
|
/* Configuration data start */
|
||||||
public boolean fireSpreadDisableToggle;
|
public boolean fireSpreadDisableToggle;
|
||||||
public boolean enforceOneSession;
|
public boolean enforceOneSession;
|
||||||
@ -88,74 +86,29 @@ public class WorldGuardWorldConfiguration {
|
|||||||
public boolean teleportOnSuffocation;
|
public boolean teleportOnSuffocation;
|
||||||
public boolean useRegions;
|
public boolean useRegions;
|
||||||
public int regionWand = 287;
|
public int regionWand = 287;
|
||||||
public String blockCreatureSpawn;
|
public Set<CreatureType> blockCreatureSpawn;
|
||||||
public boolean useiConomy;
|
public boolean useiConomy;
|
||||||
public boolean buyOnClaim;
|
public boolean buyOnClaim;
|
||||||
public double buyOnClaimPrice;
|
public double buyOnClaimPrice;
|
||||||
public int maxClaimVolume;
|
public int maxClaimVolume;
|
||||||
public boolean claimOnlyInsideExistingRegions;
|
public boolean claimOnlyInsideExistingRegions;
|
||||||
public int maxRegionCountPerPlayer;
|
public int maxRegionCountPerPlayer;
|
||||||
|
|
||||||
/* Configuration data end */
|
/* Configuration data end */
|
||||||
|
|
||||||
|
public WorldConfiguration(WorldGuardPlugin wp, String worldName,
|
||||||
public WorldGuardWorldConfiguration(WorldGuardPlugin wp, String worldName, File configFile, File blacklistFile)
|
File configFile, File blacklistFile) {
|
||||||
{
|
this.plugin = wp;
|
||||||
this.wp = wp;
|
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
this.blacklistFile = blacklistFile;
|
this.blacklistFile = blacklistFile;
|
||||||
|
|
||||||
createDefaultConfiguration(configFile, "config.yml");
|
WorldGuardPlugin.createDefaultConfiguration(configFile, "config.yml");
|
||||||
createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
WorldGuardPlugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||||
|
|
||||||
loadConfiguration();
|
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.
|
* Load the configuration.
|
||||||
*/
|
*/
|
||||||
@ -211,9 +164,15 @@ private void loadConfiguration() {
|
|||||||
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);
|
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);
|
||||||
buyOnClaimPrice = config.getDouble("iconomy.buy-on-claim-price", 1.0);
|
buyOnClaimPrice = config.getDouble("iconomy.buy-on-claim-price", 1.0);
|
||||||
|
|
||||||
blockCreatureSpawn = "";
|
blockCreatureSpawn = new HashSet<CreatureType>();
|
||||||
for (String creature : config.getStringList("mobs.block-creature-spawn", null)) {
|
for (String creatureName : config.getStringList("mobs.block-creature-spawn", null)) {
|
||||||
blockCreatureSpawn += creature.toLowerCase() + " ";
|
CreatureType creature = CreatureType.fromName(creatureName);
|
||||||
|
|
||||||
|
if (creature == null) {
|
||||||
|
logger.warning("WorldGuard: Unknown mob type '" + creatureName + "'");
|
||||||
|
} else {
|
||||||
|
blockCreatureSpawn.add(creature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalFlags globalFlags = new GlobalFlags();
|
GlobalFlags globalFlags = new GlobalFlags();
|
||||||
@ -227,8 +186,7 @@ private void loadConfiguration() {
|
|||||||
globalFlags.canLeverandbutton = config.getBoolean("regions.default.leverandbutton", true);
|
globalFlags.canLeverandbutton = config.getBoolean("regions.default.leverandbutton", true);
|
||||||
globalFlags.canPlaceVehicle = config.getBoolean("regions.default.placevehicle", true);
|
globalFlags.canPlaceVehicle = config.getBoolean("regions.default.placevehicle", true);
|
||||||
globalFlags.allowWaterflow = config.getBoolean("regions.default.waterflow", 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);
|
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
|
// First load the blacklist data from worldguard-blacklist.txt
|
||||||
Blacklist blist = new BukkitBlacklist(useBlacklistAsWhitelist, wp);
|
Blacklist blist = new BukkitBlacklist(useBlacklistAsWhitelist, plugin);
|
||||||
blist.load(blacklistFile);
|
blist.load(blacklistFile);
|
||||||
|
|
||||||
// If the blacklist is empty, then set the field to null
|
// If the blacklist is empty, then set the field to null
|
||||||
@ -291,35 +249,39 @@ private void loadConfiguration() {
|
|||||||
|
|
||||||
// Print an overview of settings
|
// Print an overview of settings
|
||||||
if (config.getBoolean("summary-on-start", true)) {
|
if (config.getBoolean("summary-on-start", true)) {
|
||||||
logger.log(Level.INFO, "=== WorldGuard configuration for world " + worldName + " ===");
|
logger.log(Level.INFO, enforceOneSession
|
||||||
logger.log(Level.INFO, enforceOneSession ? "WorldGuard: Single session is enforced."
|
? "WorldGuard: (" + worldName + ") Single session is enforced."
|
||||||
: "WorldGuard: Single session is NOT ENFORCED.");
|
: "WorldGuard: (" + worldName + ") Single session is NOT ENFORCED.");
|
||||||
logger.log(Level.INFO, blockTNT ? "WorldGuard: TNT ignition is blocked."
|
logger.log(Level.INFO, blockTNT
|
||||||
: "WorldGuard: TNT ignition is PERMITTED.");
|
? "WorldGuard: (" + worldName + ") TNT ignition is blocked."
|
||||||
logger.log(Level.INFO, blockLighter ? "WorldGuard: Lighters are blocked."
|
: "WorldGuard: (" + worldName + ") TNT ignition is PERMITTED.");
|
||||||
: "WorldGuard: Lighters are PERMITTED.");
|
logger.log(Level.INFO, blockLighter
|
||||||
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
? "WorldGuard: (" + worldName + ") Lighters are blocked."
|
||||||
: "WorldGuard: Lava fire is PERMITTED.");
|
: "WorldGuard: (" + worldName + ") Lighters are PERMITTED.");
|
||||||
|
logger.log(Level.INFO, preventLavaFire
|
||||||
|
? "WorldGuard: (" + worldName + ") Lava fire is blocked."
|
||||||
|
: "WorldGuard: (" + worldName + ") Lava fire is PERMITTED.");
|
||||||
|
|
||||||
if (disableFireSpread) {
|
if (disableFireSpread) {
|
||||||
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
logger.log(Level.INFO, "WorldGuard: (" + worldName + ") All fire spread is disabled.");
|
||||||
} else {
|
} else {
|
||||||
if (disableFireSpreadBlocks.size() > 0) {
|
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.");
|
+ disableFireSpreadBlocks.size() + " block types.");
|
||||||
} else {
|
} 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;
|
return this.blacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWorldName()
|
public String getWorldName() {
|
||||||
{
|
|
||||||
return this.worldName;
|
return this.worldName;
|
||||||
}
|
}
|
||||||
|
|
@ -94,8 +94,8 @@ public void onBlockDamage(BlockDamageEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block blockDamaged = event.getBlock();
|
Block blockDamaged = event.getBlock();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
if (wcfg.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
||||||
Vector pt = toVector(blockDamaged);
|
Vector pt = toVector(blockDamaged);
|
||||||
@ -123,8 +123,8 @@ public void onBlockBreak(BlockBreakEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (!wcfg.itemDurability) {
|
if (!wcfg.itemDurability) {
|
||||||
ItemStack held = player.getItemInHand();
|
ItemStack held = player.getItemInHand();
|
||||||
@ -146,7 +146,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
|||||||
|
|
||||||
if (wcfg.getBlacklist() != null) {
|
if (wcfg.getBlacklist() != null) {
|
||||||
if (!wcfg.getBlacklist().check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new BlockBreakBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
new BlockBreakBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player),
|
||||||
toVector(event.getBlock()),
|
toVector(event.getBlock()),
|
||||||
event.getBlock().getTypeId()), false, false)) {
|
event.getBlock().getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -154,7 +154,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.getBlacklist().check(
|
if (wcfg.getBlacklist().check(
|
||||||
new DestroyWithBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
new DestroyWithBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player),
|
||||||
toVector(event.getBlock()),
|
toVector(event.getBlock()),
|
||||||
player.getItemInHand().getTypeId()), false, false)) {
|
player.getItemInHand().getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -182,8 +182,8 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
||||||
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.simulateSponge && isWater) {
|
if (wcfg.simulateSponge && isWater) {
|
||||||
int ox = blockTo.getX();
|
int ox = blockTo.getX();
|
||||||
@ -271,8 +271,8 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
World world = block.getWorld();
|
World world = block.getWorld();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||||
|
|
||||||
@ -283,8 +283,8 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
|
|
||||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
|
|
||||||
if (player != null && !cfg.hasPermission(player, "region.bypass")) {
|
if (player != null && !plugin.hasPermission(player, "region.bypass")) {
|
||||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||||
|
|
||||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||||
&& !set.canBuild(localPlayer)) {
|
&& !set.canBuild(localPlayer)) {
|
||||||
@ -359,8 +359,8 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.disableFireSpread) {
|
if (wcfg.disableFireSpread) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -394,8 +394,8 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
int id = event.getChangedTypeId();
|
int id = event.getChangedTypeId();
|
||||||
|
|
||||||
@ -431,8 +431,8 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
if (entity instanceof Player
|
if (entity instanceof Player
|
||||||
&& (block.getType() == Material.CHEST
|
&& (block.getType() == Material.CHEST
|
||||||
@ -443,10 +443,10 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(block);
|
Vector pt = toVector(block);
|
||||||
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
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);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
if (!set.isStateFlagAllowed(Flags.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
if (!set.isStateFlagAllowed(Flags.CHEST_ACCESS) && !set.canBuild(localPlayer)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
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);
|
Vector pt = toVector(block);
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(((Player)entity).getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(((Player)entity).getWorld().getName());
|
||||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
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)) {
|
if (!applicableRegions.isStateFlagAllowed(Flags.LEVER_AND_BUTTON, localPlayer)) {
|
||||||
((Player)entity).sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
((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;
|
Player player = (Player) entity;
|
||||||
|
|
||||||
if (!wcfg.getBlacklist().check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new BlockInteractBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player), toVector(block),
|
new BlockInteractBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player), toVector(block),
|
||||||
block.getTypeId()), false, false)) {
|
block.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -498,8 +498,8 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
World world = blockPlaced.getWorld();
|
World world = blockPlaced.getWorld();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(blockPlaced);
|
Vector pt = toVector(blockPlaced);
|
||||||
@ -513,7 +513,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
|||||||
|
|
||||||
if (wcfg.getBlacklist() != null) {
|
if (wcfg.getBlacklist() != null) {
|
||||||
if (!wcfg.getBlacklist().check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new BlockPlaceBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player), toVector(blockPlaced),
|
new BlockPlaceBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player), toVector(blockPlaced),
|
||||||
blockPlaced.getTypeId()), false, false)) {
|
blockPlaced.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -544,8 +544,8 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block blockClicked = event.getBlock();
|
Block blockClicked = event.getBlock();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(blockClicked.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(blockClicked.getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.useRegions && event.getItemInHand().getTypeId() == wcfg.regionWand) {
|
if (wcfg.useRegions && event.getItemInHand().getTypeId() == wcfg.regionWand) {
|
||||||
Vector pt = toVector(blockClicked);
|
Vector pt = toVector(blockClicked);
|
||||||
@ -556,7 +556,7 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
|
|
||||||
if (regions.size() > 0) {
|
if (regions.size() > 0) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Can you build? "
|
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();
|
StringBuilder str = new StringBuilder();
|
||||||
for (Iterator<String> it = regions.iterator(); it.hasNext();) {
|
for (Iterator<String> it = regions.iterator(); it.hasNext();) {
|
||||||
@ -598,7 +598,7 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
if (((Sign)block).getLine(0).equalsIgnoreCase("[WorldGuard]")
|
if (((Sign)block).getLine(0).equalsIgnoreCase("[WorldGuard]")
|
||||||
&& ((Sign)block).getLine(1).equalsIgnoreCase("For sale")) {
|
&& ((Sign)block).getLine(1).equalsIgnoreCase("For sale")) {
|
||||||
String regionId = ((Sign)block).getLine(2);
|
String regionId = ((Sign)block).getLine(2);
|
||||||
String regionComment = ((Sign)block).getLine(3);
|
//String regionComment = ((Sign)block).getLine(3);
|
||||||
|
|
||||||
if (regionId != null && regionId != "") {
|
if (regionId != null && regionId != "") {
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
@ -654,8 +654,8 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
|||||||
Block blockTo = event.getBlock();
|
Block blockTo = event.getBlock();
|
||||||
World world = blockTo.getWorld();
|
World world = blockTo.getWorld();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
if (wcfg.simulateSponge && wcfg.redstoneSponges) {
|
if (wcfg.simulateSponge && wcfg.redstoneSponges) {
|
||||||
int ox = blockTo.getX();
|
int ox = blockTo.getX();
|
||||||
@ -691,8 +691,8 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
|||||||
*/
|
*/
|
||||||
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||||
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
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) {
|
private void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
// The negative x edge
|
// The negative x edge
|
||||||
int cx = ox - wcfg.spongeRadius - 1;
|
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.
|
* Sets the given block to fluid water.
|
||||||
* Used by addSpongeWater()
|
* Used by addSpongeWater()
|
||||||
*
|
*
|
||||||
* @see addSpongeWater()
|
|
||||||
*
|
|
||||||
* @param world
|
* @param world
|
||||||
* @param ox
|
* @param ox
|
||||||
* @param oy
|
* @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) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player) defender;
|
Player player = (Player) defender;
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -102,8 +102,8 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player) defender;
|
Player player = (Player) defender;
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -158,8 +158,8 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player) defender;
|
Player player = (Player) defender;
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -217,8 +217,8 @@ public void onEntityDamage(EntityDamageEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player) defender;
|
Player player = (Player) defender;
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (cfg.isInvinciblePlayer(player.getName())) {
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -267,9 +267,9 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
Location l = event.getLocation();
|
Location l = event.getLocation();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(l.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(l.getWorld().getName());
|
||||||
|
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
|
|
||||||
@ -317,94 +317,27 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
||||||
CreatureType creaType = event.getCreatureType();
|
CreatureType creaType = event.getCreatureType();
|
||||||
String creaName = "";
|
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;
|
Boolean cancelEvent = false;
|
||||||
|
|
||||||
switch (creaType) {
|
if (wcfg.blockCreatureSpawn.contains(creaType)) {
|
||||||
case SPIDER:
|
|
||||||
if (wcfg.blockCreatureSpawn.contains("spider")) {
|
|
||||||
cancelEvent = true;
|
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());
|
Vector pt = toVector(event.getEntity().getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
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 != null) {
|
||||||
if (flagValue) {
|
if (flagValue) {
|
||||||
cancelEvent = true;
|
cancelEvent = true;
|
||||||
|
@ -18,26 +18,27 @@
|
|||||||
*/
|
*/
|
||||||
package com.sk89q.worldguard.bukkit;
|
package com.sk89q.worldguard.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.flags.Flags;
|
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.Material;
|
||||||
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 org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import com.nijiko.coelho.iConomy.iConomy;
|
||||||
import com.sk89q.worldedit.Vector;
|
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 com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
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
|
* Handles all events thrown in relation to a Player
|
||||||
@ -61,7 +62,6 @@ public WorldGuardPlayerListener(WorldGuardPlugin plugin) {
|
|||||||
|
|
||||||
|
|
||||||
public void registerEvents() {
|
public void registerEvents() {
|
||||||
|
|
||||||
PluginManager pm = plugin.getServer().getPluginManager();
|
PluginManager pm = plugin.getServer().getPluginManager();
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_ITEM, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_ITEM, this, Priority.High, plugin);
|
||||||
@ -83,19 +83,19 @@ public void registerEvents() {
|
|||||||
public void onPlayerJoin(PlayerEvent event) {
|
public void onPlayerJoin(PlayerEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.fireSpreadDisableToggle) {
|
if (wcfg.fireSpreadDisableToggle) {
|
||||||
player.sendMessage(ChatColor.YELLOW
|
player.sendMessage(ChatColor.YELLOW
|
||||||
+ "Fire spread is currently globally disabled.");
|
+ "Fire spread is currently globally disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.inGroup(player, "wg-invincible")) {
|
if (plugin.inGroup(player, "wg-invincible")) {
|
||||||
cfg.addInvinciblePlayer(player.getName());
|
cfg.addInvinciblePlayer(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.inGroup(player, "wg-amphibious")) {
|
if (plugin.inGroup(player, "wg-amphibious")) {
|
||||||
cfg.addAmphibiousPlayer(player.getName());
|
cfg.addAmphibiousPlayer(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,13 +109,12 @@ public void onPlayerJoin(PlayerEvent event) {
|
|||||||
public void onPlayerQuit(PlayerEvent event) {
|
public void onPlayerQuit(PlayerEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
|
||||||
|
|
||||||
cfg.removeInvinciblePlayer(player.getName());
|
cfg.removeInvinciblePlayer(player.getName());
|
||||||
cfg.removeAmphibiousPlayer(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();
|
ItemStack item = event.getItem();
|
||||||
int itemId = item.getTypeId();
|
int itemId = item.getTypeId();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.useRegions
|
if (wcfg.useRegions
|
||||||
&& (itemId == 322 || itemId == 320 || itemId == 319 || itemId == 297 || itemId == 260
|
&& (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() != null && item != null && block != null) {
|
||||||
if (!wcfg.getBlacklist().check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(plugin, player),
|
||||||
toVector(block.getRelative(event.getBlockFace())),
|
toVector(block.getRelative(event.getBlockFace())),
|
||||||
item.getTypeId()), false, false)) {
|
item.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -196,8 +195,8 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.enforceOneSession) {
|
if (wcfg.enforceOneSession) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
@ -212,7 +211,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
|
|||||||
if (!checkediConomy) {
|
if (!checkediConomy) {
|
||||||
iConomy iconomy = (iConomy) plugin.getServer().getPluginManager().getPlugin("iConomy");
|
iConomy iconomy = (iConomy) plugin.getServer().getPluginManager().getPlugin("iConomy");
|
||||||
if (iconomy != null) {
|
if (iconomy != null) {
|
||||||
plugin.getWgConfiguration().setiConomy(iconomy);
|
plugin.getGlobalConfiguration().setiConomy(iconomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkediConomy = true;
|
checkediConomy = true;
|
||||||
@ -231,14 +230,14 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.getBlacklist() != null) {
|
if (wcfg.getBlacklist() != null) {
|
||||||
Item ci = event.getItemDrop();
|
Item ci = event.getItemDrop();
|
||||||
|
|
||||||
if (!wcfg.getBlacklist().check(
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -258,14 +257,14 @@ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||||
|
|
||||||
if (wcfg.getBlacklist() != null) {
|
if (wcfg.getBlacklist() != null) {
|
||||||
Item ci = event.getItem();
|
Item ci = event.getItem();
|
||||||
|
|
||||||
if (!wcfg.getBlacklist().check(
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -277,8 +276,6 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
|
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
|
||||||
|
|
||||||
ApplicableRegionSet regions = plugin.getGlobalRegionManager().getRegionManager(
|
ApplicableRegionSet regions = plugin.getGlobalRegionManager().getRegionManager(
|
||||||
player.getWorld().getName()).getApplicableRegions(
|
player.getWorld().getName()).getApplicableRegions(
|
||||||
BukkitUtil.toVector(location));
|
BukkitUtil.toVector(location));
|
||||||
@ -288,7 +285,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|||||||
if (spawn != null) {
|
if (spawn != null) {
|
||||||
RegionGroup spawnconfig = regions.getRegionGroupFlag(Flags.SPAWN_PERM, true).getValue();
|
RegionGroup spawnconfig = regions.getRegionGroupFlag(Flags.SPAWN_PERM, true).getValue();
|
||||||
if (spawnconfig != null) {
|
if (spawnconfig != null) {
|
||||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player);
|
||||||
if (spawnconfig == RegionGroup.OWNER) {
|
if (spawnconfig == RegionGroup.OWNER) {
|
||||||
if (regions.isOwner(localPlayer)) {
|
if (regions.isOwner(localPlayer)) {
|
||||||
event.setRespawnLocation(spawn);
|
event.setRespawnLocation(spawn);
|
||||||
|
@ -18,56 +18,59 @@
|
|||||||
*/
|
*/
|
||||||
package com.sk89q.worldguard.bukkit;
|
package com.sk89q.worldguard.bukkit;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
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;
|
||||||
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.InsufficientPermissionsException;
|
||||||
import com.sk89q.worldguard.protection.TimedFlagsTimer;
|
import com.sk89q.worldguard.protection.TimedFlagsTimer;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.GlobalRegionManager;
|
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;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for Bukkit.
|
* Plugin for Bukkit.
|
||||||
*
|
*
|
||||||
* @author sk89qs
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class WorldGuardPlugin extends JavaPlugin {
|
public class WorldGuardPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
protected 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 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.
|
* Called on plugin enable.
|
||||||
*/
|
*/
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
Flags.Init();
|
|
||||||
|
|
||||||
getDataFolder().mkdirs();
|
getDataFolder().mkdirs();
|
||||||
globalRegionManager.onEnable();
|
globalRegionManager.onEnable();
|
||||||
|
|
||||||
playerListener.registerEvents();
|
// Register events
|
||||||
blockListener.registerEvents();
|
(new WorldGuardPlayerListener(this)).registerEvents();
|
||||||
entityListener.registerEvents();
|
(new WorldGuardBlockListener(this)).registerEvents();
|
||||||
vehicleListener.registerEvents();
|
(new WorldGuardEntityListener(this)).registerEvents();
|
||||||
|
(new WorldGuardVehicleListener(this)).registerEvents();
|
||||||
|
|
||||||
// 25 equals about 1s real time
|
// 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();
|
commandHandler.registerCommands();
|
||||||
|
|
||||||
|
// Set up permissions
|
||||||
|
perms = new PermissionsResolverManager(
|
||||||
|
getConfiguration(), getServer(), "WorldGuard", logger);
|
||||||
|
(new PermissionsResolverServerListener(perms)).register(this);
|
||||||
|
|
||||||
logger.info("WorldGuard " + this.getDescription().getVersion() + " enabled.");
|
logger.info("WorldGuard " + this.getDescription().getVersion() + " enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +78,9 @@ public void onEnable() {
|
|||||||
* Called on plugin disable.
|
* Called on plugin disable.
|
||||||
*/
|
*/
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
globalRegionManager.onDisable();
|
globalRegionManager.onDisable();
|
||||||
|
|
||||||
logger.info("WorldGuard " + this.getDescription().getVersion() + " disabled.");
|
logger.info("WorldGuard " + getDescription().getVersion() + " disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +98,123 @@ public GlobalRegionManager getGlobalRegionManager() {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public WorldGuardConfiguration getWgConfiguration() {
|
public GlobalConfiguration getGlobalConfiguration() {
|
||||||
return configuration;
|
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());
|
Vector pt = new Vector(vhclLoc.getBlockX(), vhclLoc.getBlockY(), vhclLoc.getBlockZ());
|
||||||
|
|
||||||
if (vhcl instanceof Minecart || vhcl instanceof Boat) {
|
if (vhcl instanceof Minecart || vhcl instanceof Boat) {
|
||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
GlobalConfiguration cfg = plugin.getGlobalConfiguration();
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(vhcl.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(vhcl.getWorld().getName());
|
||||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||||
|
|
||||||
|
@ -20,8 +20,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -34,9 +35,11 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandAllowFire extends WgCommand {
|
public class CommandAllowFire 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,
|
||||||
cfg.checkPermission(sender, "allowfire");
|
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||||
|
throws CommandHandlingException {
|
||||||
|
plugin.checkPermission(sender, "worldguard.fire-toggle.allow");
|
||||||
|
|
||||||
String worldName;
|
String worldName;
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
WorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||||
|
|
||||||
if (wcfg.fireSpreadDisableToggle) {
|
if (wcfg.fireSpreadDisableToggle) {
|
||||||
server.broadcastMessage(ChatColor.YELLOW
|
server.broadcastMessage(ChatColor.YELLOW
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
import com.nijiko.coelho.iConomy.iConomy;
|
import com.nijiko.coelho.iConomy.iConomy;
|
||||||
import com.nijiko.coelho.iConomy.system.*;
|
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.domains.DefaultDomain;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
@ -38,7 +39,11 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandBuyRegion extends WgCommand {
|
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)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
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);
|
CommandHandler.checkArgs(args, 1, 2);
|
||||||
|
|
||||||
cfg.checkRegionPermission(player, "buyregion");
|
plugin.checkPermission(player, "worldguard.regions.buy");
|
||||||
|
|
||||||
String id = args[0];
|
String id = args[0];
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -32,13 +33,16 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandGod extends WgCommand {
|
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);
|
CommandHandler.checkArgs(args, 0, 1);
|
||||||
|
|
||||||
// Allow setting other people invincible
|
// Allow setting other people invincible
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
cfg.checkPermission(sender, "god.other");
|
plugin.checkPermission(sender, "worldguard.god.other");
|
||||||
|
|
||||||
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
@ -56,7 +60,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
// Invincibility for one's self
|
// Invincibility for one's self
|
||||||
} else if(sender instanceof Player) {
|
} else if(sender instanceof Player) {
|
||||||
cfg.checkPermission(sender, "god.self");
|
plugin.checkPermission(sender, "worldguard.god");
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
if (!cfg.isInvinciblePlayer(player.getName())) {
|
if (!cfg.isInvinciblePlayer(player.getName())) {
|
||||||
cfg.addInvinciblePlayer(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";
|
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;
|
return true;
|
||||||
|
|
||||||
} catch (InsufficientArgumentsException e) {
|
} catch (InsufficientArgumentsException e) {
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -32,13 +33,16 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandHeal extends WgCommand {
|
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);
|
CommandHandler.checkArgs(args, 0, 1);
|
||||||
|
|
||||||
// Allow healing other people
|
// Allow healing other people
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
cfg.checkPermission(sender, "heal.other");
|
plugin.checkPermission(sender, "worldguard.heal.other");
|
||||||
|
|
||||||
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||||
if (other == null) {
|
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!");
|
other.sendMessage(ChatColor.YELLOW + senderName + " has healed you!");
|
||||||
}
|
}
|
||||||
} else if (sender instanceof Player){
|
} else if (sender instanceof Player){
|
||||||
cfg.checkPermission(sender, "heal.self");
|
plugin.checkPermission(sender, "worldguard.heal");
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.sendMessage(ChatColor.YELLOW + "You have been healed!");
|
player.sendMessage(ChatColor.YELLOW + "You have been healed!");
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -33,7 +34,10 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandLocate extends WgCommand {
|
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)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
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;
|
Player player = (Player) sender;
|
||||||
cfg.checkPermission(player, "locate");
|
plugin.checkPermission(sender, "worldguard.locate");
|
||||||
CommandHandler.checkArgs(args, 0, 3);
|
CommandHandler.checkArgs(args, 0, 3);
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
@ -19,11 +19,13 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.util.RegionUtil;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -35,7 +37,11 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionAddMember extends WgRegionCommand {
|
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");
|
boolean cmdIsOwner = command.equalsIgnoreCase("addowner");
|
||||||
@ -45,12 +51,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
|
|
||||||
if (cmdIsOwner) {
|
if (cmdIsOwner) {
|
||||||
CommandHandler.checkArgs(args, 2, -1, "/region addowner <id> [player1 [group1 [players/groups...]]]");
|
CommandHandler.checkArgs(args, 2, -1, "/region addowner <id> [player1 [group1 [players/groups...]]]");
|
||||||
permOwn = "region.addowner.own";
|
permOwn = "worldguard.region.addowner.own";
|
||||||
permAll = "region.addowner.all";
|
permAll = "worldguard.region.addowner";
|
||||||
} else {
|
} else {
|
||||||
CommandHandler.checkArgs(args, 2, -1, "/region addmember <id> [player1 [group1 [players/groups...]]]");
|
CommandHandler.checkArgs(args, 2, -1, "/region addmember <id> [player1 [group1 [players/groups...]]]");
|
||||||
permOwn = "region.addmember.own";
|
permOwn = "worldguard.region.addmember.own";
|
||||||
permAll = "region.addmember.all";
|
permAll = "worldguard.region.addmember";
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, permOwn);
|
plugin.checkPermission(sender, permOwn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cfg.checkRegionPermission(sender, permAll);
|
plugin.checkPermission(sender, permAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cfg.checkRegionPermission(sender, permAll);
|
plugin.checkPermission(sender, permAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdIsOwner) {
|
if (cmdIsOwner) {
|
||||||
WorldGuardConfiguration.addToDomain(existing.getOwners(), args, 1);
|
RegionUtil.addToDomain(existing.getOwners(), args, 1);
|
||||||
} else {
|
} else {
|
||||||
WorldGuardConfiguration.addToDomain(existing.getMembers(), args, 1);
|
RegionUtil.addToDomain(existing.getMembers(), args, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
@ -50,7 +51,11 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionClaim extends WgRegionCommand {
|
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)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
@ -64,14 +69,14 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.checkRegionPermission(player, "region.claim");
|
plugin.checkPermission(player, "worldguard.region.claim");
|
||||||
CommandHandler.checkArgs(args, 1, 1, "/region claim <id>");
|
CommandHandler.checkArgs(args, 1, 1, "/region claim <id>");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
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) {
|
if (mgr.getRegionCountOfPlayer(lPlayer) >= wcfg.maxRegionCountPerPlayer) {
|
||||||
player.sendMessage(ChatColor.RED + "You own too much regions, delete one first to claim a new one.");
|
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.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.util.RegionUtil;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -46,7 +48,11 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionDefine extends WgRegionCommand {
|
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)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
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!");
|
sender.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cfg.checkRegionPermission(sender, "region.define");
|
plugin.checkPermission(sender, "worldguard.region.define");
|
||||||
CommandHandler.checkArgs(args, 1, -1, "/region define <id> [owner1 [owner2 [owners...]]]");
|
CommandHandler.checkArgs(args, 1, -1, "/region define <id> [owner1 [owner2 [owners...]]]");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -85,7 +91,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
region.setOwners(WorldGuardConfiguration.parseDomainString(args, 1));
|
region.setOwners(RegionUtil.parseDomainString(args, 1));
|
||||||
}
|
}
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(w.getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(w.getName());
|
||||||
mgr.addRegion(region);
|
mgr.addRegion(region);
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -34,8 +35,11 @@
|
|||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionDelete extends WgRegionCommand {
|
public class CommandRegionDelete extends WgRegionCommand {
|
||||||
|
@Override
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
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>");
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.delete.own");
|
plugin.checkPermission(sender, "worldguard.region.delete.own");
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.delete.all");
|
plugin.checkPermission(sender, "worldguard.region.delete");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.delete.all");
|
plugin.checkPermission(sender, "worldguard.region.delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr.removeRegion(id);
|
mgr.removeRegion(id);
|
||||||
|
@ -20,8 +20,9 @@
|
|||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -40,8 +41,11 @@
|
|||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionFlag extends WgRegionCommand {
|
public class CommandRegionFlag extends WgRegionCommand {
|
||||||
|
@Override
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
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]");
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (region.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.flag.ownregions");
|
plugin.checkPermission(sender, "worldguard.region.flag.own");
|
||||||
} else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
|
} else if (region.isMember(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.flag.memberregions");
|
plugin.checkPermission(sender, "worldguard.region.flag.member");
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.flag.foreignregions");
|
plugin.checkPermission(sender, "worldguard.region.flag");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.flag.foreignregions");
|
plugin.checkPermission(sender, "worldguard.region.flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionFlagInfo nfo = FlagDatabase.getFlagInfoFromName(nameStr);
|
RegionFlagInfo nfo = FlagDatabase.getFlagInfoFromName(nameStr);
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
@ -38,7 +39,11 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionInfo extends WgRegionCommand {
|
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>");
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (region.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.info.ownregions");
|
plugin.checkPermission(sender, "worldguard.region.info.own");
|
||||||
} else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
|
} else if (region.isMember(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.info.memberregions");
|
plugin.checkPermission(sender, "worldguard.region.info.member");
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.info.foreignregions");
|
plugin.checkPermission(sender, "worldguard.region.info");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.info.foreignregions");
|
plugin.checkPermission(sender, "worldguard.region.info");
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionFlagContainer flags = region.getFlags();
|
RegionFlagContainer flags = region.getFlags();
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -35,9 +36,13 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionList extends WgRegionCommand {
|
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]");
|
CommandHandler.checkArgs(args, 0, 1, "/region list [page]");
|
||||||
|
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -32,9 +33,14 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionLoad extends WgRegionCommand {
|
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");
|
CommandHandler.checkArgs(args, 0, 0, "/region load");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -35,7 +36,12 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionPriority extends WgRegionCommand {
|
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>)");
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.priority.own");
|
plugin.checkPermission(sender, "worldguard.region.priority.own");
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.priority.all");
|
plugin.checkPermission(sender, "worldguard.region.priority");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.priority.all");
|
plugin.checkPermission(sender, "worldguard.region.priority");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.util.RegionUtil;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -36,7 +38,12 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionRemoveMember extends WgRegionCommand {
|
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");
|
boolean cmdIsOwner = command.equalsIgnoreCase("removeowner");
|
||||||
String permOwn;
|
String permOwn;
|
||||||
@ -44,12 +51,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
|
|
||||||
if (cmdIsOwner) {
|
if (cmdIsOwner) {
|
||||||
CommandHandler.checkArgs(args, 2, -1, "/region removeowner <id> [player1 [group1 [players/groups...]]]");
|
CommandHandler.checkArgs(args, 2, -1, "/region removeowner <id> [player1 [group1 [players/groups...]]]");
|
||||||
permOwn = "region.removeowner.own";
|
permOwn = "worldguard.region.removeowner.own";
|
||||||
permAll = "region.removeowner.all";
|
permAll = "worldguard.region.removeowner";
|
||||||
} else {
|
} else {
|
||||||
CommandHandler.checkArgs(args, 2, -1, "/region removemember <id> [player1 [group1 [players/groups...]]]");
|
CommandHandler.checkArgs(args, 2, -1, "/region removemember <id> [player1 [group1 [players/groups...]]]");
|
||||||
permOwn = "region.removemember.own";
|
permOwn = "worldguard.region.removemember.own";
|
||||||
permAll = "region.removemember.all";
|
permAll = "worldguard.region.removemember";
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, permOwn);
|
plugin.checkPermission(sender, permOwn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cfg.checkRegionPermission(sender, permAll);
|
plugin.checkPermission(sender, permAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cfg.checkRegionPermission(sender, permAll);
|
plugin.checkPermission(sender, permAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (cmdIsOwner) {
|
if (cmdIsOwner) {
|
||||||
WorldGuardConfiguration.removeFromDomain(existing.getOwners(), args, 1);
|
RegionUtil.removeFromDomain(existing.getOwners(), args, 1);
|
||||||
} else {
|
} else {
|
||||||
WorldGuardConfiguration.removeFromDomain(existing.getMembers(), args, 1);
|
RegionUtil.removeFromDomain(existing.getMembers(), args, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -33,9 +34,14 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionSave extends WgRegionCommand {
|
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");
|
CommandHandler.checkArgs(args, 0, 0, "/region save");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -36,7 +37,12 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandRegionSetParent extends WgRegionCommand {
|
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>");
|
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) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (region.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.setparent.own");
|
plugin.checkPermission(sender, "worldguard.region.setparent.own");
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion parent = null;
|
ProtectedRegion parent = null;
|
||||||
@ -77,13 +83,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (parent.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
if (parent.isOwner(BukkitPlayer.wrapPlayer(plugin, player))) {
|
||||||
cfg.checkRegionPermission(sender, "region.setparent.own");
|
plugin.checkPermission(sender, "worldguard.region.setparent.own");
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.checkRegionPermission(sender, "region.setparent.all");
|
plugin.checkPermission(sender, "worldguard.region.setparent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.LoggerToChatHandler;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -32,9 +33,12 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandReloadWG extends WgCommand {
|
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);
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
|
||||||
LoggerToChatHandler handler = null;
|
LoggerToChatHandler handler = null;
|
||||||
@ -48,8 +52,8 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cfg.onDisable();
|
cfg.unload();
|
||||||
cfg.onEnable();
|
cfg.load();
|
||||||
|
|
||||||
sender.sendMessage("WorldGuard configuration reloaded.");
|
sender.sendMessage("WorldGuard configuration reloaded.");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -32,13 +33,16 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandSlay extends WgCommand {
|
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);
|
CommandHandler.checkArgs(args, 0, 1);
|
||||||
|
|
||||||
// Allow killing other people
|
// Allow killing other people
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
cfg.checkPermission(sender, "slay.others");
|
plugin.checkPermission(sender, "worldguard.slay.other");
|
||||||
|
|
||||||
Player other = BukkitUtil.matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
Player other = BukkitUtil.matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||||
if (other == null) {
|
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!");
|
other.sendMessage(ChatColor.YELLOW + senderName + " has killed you!");
|
||||||
}
|
}
|
||||||
} else if (sender instanceof Player) {
|
} else if (sender instanceof Player) {
|
||||||
cfg.checkPermission(sender, "slay.self");
|
plugin.checkPermission(sender, "worldguard.slay");
|
||||||
|
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
player.setHealth(0);
|
player.setHealth(0);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -33,14 +34,17 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandStack extends WgCommand {
|
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)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
cfg.checkPermission(player, "stack");
|
plugin.checkPermission(sender, "worldguard.stack");
|
||||||
CommandHandler.checkArgs(args, 0, 0);
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
|
||||||
ItemStack[] items = player.getInventory().getContents();
|
ItemStack[] items = player.getInventory().getContents();
|
||||||
|
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -33,9 +34,12 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandStopFire extends WgCommand {
|
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);
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
|
||||||
String worldName;
|
String worldName;
|
||||||
@ -55,7 +59,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
return true;
|
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.LocalPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
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.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -23,21 +24,25 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandTpRegion extends WgCommand {
|
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)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
cfg.checkPermission(sender, "tpregion");
|
plugin.checkPermission(sender, "worldguard.region.teleport");
|
||||||
|
|
||||||
CommandHandler.checkArgs(args, 1, 2, "/tpregion <region name> {spawn}");
|
CommandHandler.checkArgs(args, 1, 2, "/tpregion <region name> {spawn}");
|
||||||
|
|
||||||
String id = args[0];
|
String id = args[0];
|
||||||
Boolean spawn = false;
|
Boolean spawn = false;
|
||||||
if (args.length == 2 && args[1].equals("spawn")) {
|
if (args.length == 2 && args[1].equals("spawn")) {
|
||||||
cfg.checkPermission(player, "tpregion.spawn");
|
plugin.checkPermission(sender, "worldguard.region.teleport.spawn");
|
||||||
spawn = true;
|
spawn = true;
|
||||||
}
|
}
|
||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
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);
|
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 (flagright == RegionGroup.OWNER) {
|
||||||
if (!region.isOwner(lPlayer)) {
|
if (!region.isOwner(lPlayer)) {
|
||||||
cfg.checkPermission(player, "tpregion.override");
|
plugin.checkPermission(sender, "worldguard.region.teleport.override");
|
||||||
}
|
}
|
||||||
} else if (flagright == RegionGroup.MEMBER) {
|
} else if (flagright == RegionGroup.MEMBER) {
|
||||||
if (!region.isMember(lPlayer)) {
|
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;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -70,8 +71,10 @@ public RegionCommandHandler() {
|
|||||||
this.aliasMap.put("rlist", "list");
|
this.aliasMap.put("rlist", "list");
|
||||||
this.aliasMap.put("rp", "priority");
|
this.aliasMap.put("rp", "priority");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName,
|
||||||
|
String command, String[] args, GlobalConfiguration cfg, WorldGuardPlugin plugin)
|
||||||
|
throws CommandHandlingException {
|
||||||
|
|
||||||
String worldName;
|
String worldName;
|
||||||
String subCommand;
|
String subCommand;
|
||||||
@ -110,7 +113,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
WorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||||
|
|
||||||
if (!wcfg.useRegions) {
|
if (!wcfg.useRegions) {
|
||||||
sender.sendMessage(ChatColor.RED + "Regions are disabled in this world.");
|
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();
|
cfg.getWorldGuardPlugin().getGlobalRegionManager().reloadDataWhereRequired();
|
||||||
wgcmd.handle(sender, senderName, subCommand, subArgs, cfg, wcfg);
|
wgcmd.handle(sender, senderName, subCommand, subArgs, cfg, wcfg, plugin);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
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 com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -30,6 +31,8 @@
|
|||||||
*/
|
*/
|
||||||
public abstract class WgCommand {
|
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;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.GlobalConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -31,6 +32,9 @@
|
|||||||
*/
|
*/
|
||||||
public abstract class WgRegionCommand {
|
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.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param pt
|
* @param applicable
|
||||||
* @param regions
|
|
||||||
* @param global
|
* @param global
|
||||||
*/
|
*/
|
||||||
public ApplicableRegionSet(List<ProtectedRegion> applicable, GlobalFlags 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);
|
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;
|
ProtectedRegion region = affectedRegion;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public void run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check passthrough flag
|
//check passthrough flag
|
||||||
LocalPlayer lplayer = BukkitPlayer.wrapPlayer(wg.getWgConfiguration(), player);
|
LocalPlayer lplayer = BukkitPlayer.wrapPlayer(wg, player);
|
||||||
if(!regions.isStateFlagAllowed(Flags.PASSTHROUGH, lplayer))
|
if(!regions.isStateFlagAllowed(Flags.PASSTHROUGH, lplayer))
|
||||||
{
|
{
|
||||||
Location newLoc = player.getLocation().clone();
|
Location newLoc = player.getLocation().clone();
|
||||||
@ -153,7 +153,7 @@ public void run() {
|
|||||||
|
|
||||||
public void broadcastNotification(String msg) {
|
public void broadcastNotification(String msg) {
|
||||||
for (Player player : wg.getServer().getOnlinePlayers()) {
|
for (Player player : wg.getServer().getOnlinePlayers()) {
|
||||||
if (wg.getWgConfiguration().hasPermission(player, "notify_onenter")) {
|
if (wg.hasPermission(player, "notify_onenter")) {
|
||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ public Map<String, ProtectedRegion> getRegions() {
|
|||||||
ret.putAll(this.pRegions);
|
ret.putAll(this.pRegions);
|
||||||
|
|
||||||
for (Map.Entry<String, ProtectedRegion> entry : ret.entrySet()) {
|
for (Map.Entry<String, ProtectedRegion> entry : ret.entrySet()) {
|
||||||
String id = entry.getKey();
|
|
||||||
ProtectedRegion region = entry.getValue();
|
ProtectedRegion region = entry.getValue();
|
||||||
|
|
||||||
String parentId = region.getParentId();
|
String parentId = region.getParentId();
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* @author Redecouverte
|
* @author Redecouverte
|
||||||
*/
|
*/
|
||||||
public class JSONDatabase implements ProtectionDatabase {
|
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.
|
* References the json db folder.
|
||||||
@ -111,6 +111,8 @@ public void save() throws IOException {
|
|||||||
/**
|
/**
|
||||||
* Writes a String to a file.
|
* Writes a String to a file.
|
||||||
*
|
*
|
||||||
|
* @param string
|
||||||
|
* @param file
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void writeStringToFile(String string, File 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.
|
* Get a list of protected regions.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public void setRegions(Map<String,ProtectedRegion> regions) {
|
public void setRegions(Map<String,ProtectedRegion> regions) {
|
||||||
this.regions = regions;
|
this.regions = regions;
|
||||||
|
@ -46,12 +46,14 @@ public interface ProtectionDatabase {
|
|||||||
/**
|
/**
|
||||||
* Load the list of regions into a region manager.
|
* Load the list of regions into a region manager.
|
||||||
*
|
*
|
||||||
|
* @param manager
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void load(RegionManager manager) throws IOException;
|
public void load(RegionManager manager) throws IOException;
|
||||||
/**
|
/**
|
||||||
* Save the list of regions from a region manager.
|
* Save the list of regions from a region manager.
|
||||||
*
|
*
|
||||||
|
* @param manager
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void save(RegionManager 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.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.GlobalFlags;
|
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
|
||||||
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
|
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@ -48,6 +47,10 @@ public class FlatRegionManager extends RegionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the manager.
|
* Construct the manager.
|
||||||
|
*
|
||||||
|
* @param global
|
||||||
|
* @param regionloader
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
||||||
|
|
||||||
@ -61,15 +64,15 @@ public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) th
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Map<String, ProtectedRegion> getRegions() {
|
public Map<String, ProtectedRegion> getRegions() {
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a list of protected regions.
|
* Set a list of protected regions.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRegions(Map<String, ProtectedRegion> regions) {
|
public void setRegions(Map<String, ProtectedRegion> regions) {
|
||||||
this.regions = new TreeMap<String, ProtectedRegion>(regions);
|
this.regions = new TreeMap<String, ProtectedRegion>(regions);
|
||||||
}
|
}
|
||||||
@ -77,9 +80,9 @@ public void setRegions(Map<String, ProtectedRegion> regions) {
|
|||||||
/**
|
/**
|
||||||
* Adds a region.
|
* Adds a region.
|
||||||
*
|
*
|
||||||
* @param id
|
|
||||||
* @param region
|
* @param region
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addRegion(ProtectedRegion region) {
|
public void addRegion(ProtectedRegion region) {
|
||||||
regions.put(region.getId(), region);
|
regions.put(region.getId(), region);
|
||||||
}
|
}
|
||||||
@ -89,6 +92,7 @@ public void addRegion(ProtectedRegion region) {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeRegion(String id) {
|
public void removeRegion(String id) {
|
||||||
ProtectedRegion region = regions.get(id);
|
ProtectedRegion region = regions.get(id);
|
||||||
|
|
||||||
@ -117,6 +121,7 @@ public void removeRegion(String id) {
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean hasRegion(String id) {
|
public boolean hasRegion(String id) {
|
||||||
return regions.containsKey(id);
|
return regions.containsKey(id);
|
||||||
}
|
}
|
||||||
@ -126,6 +131,7 @@ public boolean hasRegion(String id) {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ProtectedRegion getRegion(String id) {
|
public ProtectedRegion getRegion(String id) {
|
||||||
return regions.get(id);
|
return regions.get(id);
|
||||||
}
|
}
|
||||||
@ -136,6 +142,7 @@ public ProtectedRegion getRegion(String id) {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||||
|
|
||||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
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.
|
* Get an object for a region for rules to be applied with.
|
||||||
*
|
*
|
||||||
* @param pt
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||||
|
|
||||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||||
@ -176,6 +183,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<String> getApplicableRegionsIDs(Vector pt) {
|
public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||||
List<String> applicable = new ArrayList<String>();
|
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
|
* Returns true if the provided region overlaps with any other region that
|
||||||
* is not owned by the player.
|
* is not owned by the player.
|
||||||
*
|
*
|
||||||
* @param region
|
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||||
|
|
||||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||||
@ -223,6 +231,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return regions.size();
|
return regions.size();
|
||||||
}
|
}
|
||||||
@ -232,6 +241,7 @@ public int size() {
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void save() throws IOException {
|
public void save() throws IOException {
|
||||||
if (this.regionloader == null) {
|
if (this.regionloader == null) {
|
||||||
return;
|
return;
|
||||||
@ -240,6 +250,7 @@ public void save() throws IOException {
|
|||||||
regionloader.save(this);
|
regionloader.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getRegionCountOfPlayer(LocalPlayer player) {
|
public int getRegionCountOfPlayer(LocalPlayer player) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
@ -57,11 +55,11 @@ public void onEnable() {
|
|||||||
loadWorld(w.getName());
|
loadWorld(w.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.getWgConfiguration().onEnable();
|
wg.getGlobalConfiguration().load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
wg.getWgConfiguration().onDisable();
|
wg.getGlobalConfiguration().unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadWorld(String name) {
|
private void loadWorld(String name) {
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
import com.sk89q.worldguard.protection.GlobalFlags;
|
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegionMBRConverter;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegionMBRConverter;
|
||||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
|
||||||
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
|
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -53,6 +52,10 @@ public class PRTreeRegionManager extends RegionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the manager.
|
* Construct the manager.
|
||||||
|
*
|
||||||
|
* @param global
|
||||||
|
* @param regionloader
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
||||||
super(global, regionloader);
|
super(global, regionloader);
|
||||||
@ -66,15 +69,15 @@ public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader)
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Map<String, ProtectedRegion> getRegions() {
|
public Map<String, ProtectedRegion> getRegions() {
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a list of protected regions.
|
* Set a list of protected regions.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRegions(Map<String, ProtectedRegion> regions) {
|
public void setRegions(Map<String, ProtectedRegion> regions) {
|
||||||
this.regions = new TreeMap<String, ProtectedRegion>(regions);
|
this.regions = new TreeMap<String, ProtectedRegion>(regions);
|
||||||
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
||||||
@ -84,9 +87,9 @@ public void setRegions(Map<String, ProtectedRegion> regions) {
|
|||||||
/**
|
/**
|
||||||
* Adds a region.
|
* Adds a region.
|
||||||
*
|
*
|
||||||
* @param id
|
|
||||||
* @param region
|
* @param region
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addRegion(ProtectedRegion region) {
|
public void addRegion(ProtectedRegion region) {
|
||||||
regions.put(region.getId(), region);
|
regions.put(region.getId(), region);
|
||||||
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
||||||
@ -99,6 +102,7 @@ public void addRegion(ProtectedRegion region) {
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean hasRegion(String id) {
|
public boolean hasRegion(String id) {
|
||||||
return regions.containsKey(id);
|
return regions.containsKey(id);
|
||||||
}
|
}
|
||||||
@ -108,6 +112,7 @@ public boolean hasRegion(String id) {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ProtectedRegion getRegion(String id) {
|
public ProtectedRegion getRegion(String id) {
|
||||||
return regions.get(id);
|
return regions.get(id);
|
||||||
}
|
}
|
||||||
@ -117,6 +122,7 @@ public ProtectedRegion getRegion(String id) {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeRegion(String id) {
|
public void removeRegion(String id) {
|
||||||
ProtectedRegion region = regions.get(id);
|
ProtectedRegion region = regions.get(id);
|
||||||
|
|
||||||
@ -148,6 +154,7 @@ public void removeRegion(String id) {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||||
|
|
||||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||||
@ -164,6 +171,7 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
|||||||
return new ApplicableRegionSet(appRegions, global);
|
return new ApplicableRegionSet(appRegions, global);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||||
appRegions.addAll(regions.values());
|
appRegions.addAll(regions.values());
|
||||||
@ -184,6 +192,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<String> getApplicableRegionsIDs(Vector pt) {
|
public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||||
List<String> applicable = new ArrayList<String>();
|
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
|
* Returns true if the provided region overlaps with any other region that
|
||||||
* is not owned by the player.
|
* is not owned by the player.
|
||||||
*
|
*
|
||||||
* @param region
|
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||||
|
|
||||||
@ -233,6 +242,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return regions.size();
|
return regions.size();
|
||||||
}
|
}
|
||||||
@ -242,10 +252,12 @@ public int size() {
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void save() throws IOException {
|
public void save() throws IOException {
|
||||||
regionloader.save(this);
|
regionloader.save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getRegionCountOfPlayer(LocalPlayer player) {
|
public int getRegionCountOfPlayer(LocalPlayer player) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
@ -101,14 +101,13 @@ public void load() throws IOException
|
|||||||
/**
|
/**
|
||||||
* Set a list of protected regions.
|
* Set a list of protected regions.
|
||||||
*
|
*
|
||||||
* @return
|
* @param regions
|
||||||
*/
|
*/
|
||||||
public abstract void setRegions(Map<String,ProtectedRegion> regions);
|
public abstract void setRegions(Map<String,ProtectedRegion> regions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a region.
|
* Adds a region.
|
||||||
*
|
*
|
||||||
* @param id
|
|
||||||
* @param region
|
* @param region
|
||||||
*/
|
*/
|
||||||
public abstract void addRegion(ProtectedRegion region);
|
public abstract void addRegion(ProtectedRegion region);
|
||||||
@ -125,6 +124,7 @@ public void load() throws IOException
|
|||||||
* Get a region by its ID.
|
* Get a region by its ID.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract ProtectedRegion getRegion(String id);
|
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.
|
* Get an object for a point for rules to be applied with.
|
||||||
*
|
*
|
||||||
* @param pt
|
* @param region
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract ApplicableRegionSet getApplicableRegions(ProtectedRegion region);
|
public abstract ApplicableRegionSet getApplicableRegions(ProtectedRegion region);
|
||||||
@ -181,10 +181,9 @@ public void load() throws IOException
|
|||||||
/**
|
/**
|
||||||
* Sets the global flags.
|
* Sets the global flags.
|
||||||
*
|
*
|
||||||
* @return
|
* @param globalflags
|
||||||
*/
|
*/
|
||||||
public void setGlobalFlags(GlobalFlags globalflags)
|
public void setGlobalFlags(GlobalFlags globalflags) {
|
||||||
{
|
|
||||||
global = globalflags;
|
global = globalflags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,8 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
|||||||
* Construct a new instance of this cuboid region.
|
* Construct a new instance of this cuboid region.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param pos1
|
* @param min
|
||||||
* @param pos2
|
* @param max
|
||||||
* @param priority
|
|
||||||
*/
|
*/
|
||||||
public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) {
|
public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) {
|
||||||
super(id);
|
super(id);
|
||||||
@ -59,6 +58,7 @@ public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) {
|
|||||||
*
|
*
|
||||||
* @return min point
|
* @return min point
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public BlockVector getMinimumPoint() {
|
public BlockVector getMinimumPoint() {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
@ -77,6 +77,7 @@ public void setMinimumPoint(BlockVector pt) {
|
|||||||
*
|
*
|
||||||
* @return max point
|
* @return max point
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public BlockVector getMaximumPoint() {
|
public BlockVector getMaximumPoint() {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
@ -129,6 +130,7 @@ public boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersec
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||||
int numRegions = regions.size();
|
int numRegions = regions.size();
|
||||||
List<ProtectedRegion> intersectingRegions = new ArrayList<ProtectedRegion>();
|
List<ProtectedRegion> intersectingRegions = new ArrayList<ProtectedRegion>();
|
||||||
@ -257,6 +259,7 @@ public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> region
|
|||||||
*
|
*
|
||||||
* @return type of region
|
* @return type of region
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getTypeName() {
|
public String getTypeName() {
|
||||||
return "cuboid";
|
return "cuboid";
|
||||||
}
|
}
|
||||||
@ -266,6 +269,7 @@ public String getTypeName() {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int countBlocks() {
|
public int countBlocks() {
|
||||||
int xLength = max.getBlockX() - min.getBlockX() + 1;
|
int xLength = max.getBlockX() - min.getBlockX() + 1;
|
||||||
int yLength = max.getBlockY() - min.getBlockY() + 1;
|
int yLength = max.getBlockY() - min.getBlockY() + 1;
|
||||||
|
@ -136,8 +136,7 @@ public boolean contains(Vector pt) {
|
|||||||
return inside;
|
return inside;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||||
int numRegions = regions.size();
|
int numRegions = regions.size();
|
||||||
int numPoints = points.size();
|
int numPoints = points.size();
|
||||||
@ -269,6 +268,7 @@ public String getTypeName() {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int countBlocks() {
|
public int countBlocks() {
|
||||||
int volume = 0;
|
int volume = 0;
|
||||||
int numPoints = points.size();
|
int numPoints = points.size();
|
||||||
|
@ -143,7 +143,7 @@ public ProtectedRegion getParent() {
|
|||||||
* Set the curParent. This checks to make sure that it will not result
|
* Set the curParent. This checks to make sure that it will not result
|
||||||
* in circular inheritance.
|
* in circular inheritance.
|
||||||
*
|
*
|
||||||
* @param curParent the curParent to setFlag
|
* @param parent the curParent to setFlag
|
||||||
* @throws CircularInheritanceException
|
* @throws CircularInheritanceException
|
||||||
*/
|
*/
|
||||||
public void setParent(ProtectedRegion parent) 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) {
|
public void setMembers(DefaultDomain members) {
|
||||||
this.members = 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 TELE_PERM = new RegionGroupRegionFlagInfo("teleperm", FlagType.TELE_PERM);
|
||||||
public static RegionGroupRegionFlagInfo SPAWN_PERM = new RegionGroupRegionFlagInfo("spawnperm", FlagType.SPAWN_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