merged with recent commits

This commit is contained in:
Redecouverte 2011-02-25 17:28:08 +01:00
parent 9b4a7c705b
commit 0a45292587
12 changed files with 148 additions and 101 deletions

View File

@ -28,6 +28,7 @@ endorsed.classpath=
excludes= excludes=
file.reference.Bukkit.jar=lib/Bukkit.jar file.reference.Bukkit.jar=lib/Bukkit.jar
file.reference.gson-1.7-SNAPSHOT.jar=lib\\gson-1.7-SNAPSHOT.jar file.reference.gson-1.7-SNAPSHOT.jar=lib\\gson-1.7-SNAPSHOT.jar
file.reference.iConomy.jar=lib\\iConomy.jar
file.reference.prtree.jar=lib/prtree.jar file.reference.prtree.jar=lib/prtree.jar
file.reference.truezip.jar=lib/truezip.jar file.reference.truezip.jar=lib/truezip.jar
file.reference.WorldEdit.jar=lib/WorldEdit.jar file.reference.WorldEdit.jar=lib/WorldEdit.jar
@ -38,7 +39,8 @@ javac.classpath=\
${file.reference.prtree.jar}:\ ${file.reference.prtree.jar}:\
${file.reference.truezip.jar}:\ ${file.reference.truezip.jar}:\
${file.reference.WorldEdit.jar}:\ ${file.reference.WorldEdit.jar}:\
${file.reference.gson-1.7-SNAPSHOT.jar} ${file.reference.gson-1.7-SNAPSHOT.jar}:\
${file.reference.iConomy.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false

View File

@ -46,3 +46,8 @@ worldguard.region.delete.all
worldguard.region.define worldguard.region.define
worldguard.region.claim worldguard.region.claim
worldguard.tpregion
worldguard.tpregion.spawn
worldguard.buyregion

View File

@ -34,7 +34,6 @@
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.*; import com.sk89q.worldguard.blacklist.events.*;
import com.sk89q.worldguard.protection.GlobalFlags;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.AreaFlags; import com.sk89q.worldguard.protection.regions.AreaFlags;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*; import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
@ -217,7 +216,7 @@ public void onBlockFlow(BlockFromToEvent event) {
} }
} }
if (plugin.useRegions) { if (wcfg.useRegions) {
Vector pt = toVector(blockFrom.getLocation()); Vector pt = toVector(blockFrom.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(world.getName()); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(world.getName());

View File

@ -18,6 +18,7 @@
*/ */
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.nijikokun.bukkit.iConomy.iConomy;
import com.sk89q.bukkit.migration.PermissionsResolverManager; import com.sk89q.bukkit.migration.PermissionsResolverManager;
import com.sk89q.bukkit.migration.PermissionsResolverServerListener; import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
@ -61,10 +62,12 @@ public class WorldGuardConfiguration {
private boolean suppressTickSyncWarnings; private boolean suppressTickSyncWarnings;
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$"); private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
private iConomy iConomy;
public WorldGuardConfiguration(WorldGuardPlugin wg) { public WorldGuardConfiguration(WorldGuardPlugin wg) {
this.wg = wg; this.wg = wg;
this.worldConfig = new HashMap<String, WorldGuardWorldConfiguration>(); this.worldConfig = new HashMap<String, WorldGuardWorldConfiguration>();
this.iConomy = null;
} }
public WorldGuardWorldConfiguration getWorldConfig(String worldName) { public WorldGuardWorldConfiguration getWorldConfig(String worldName) {
@ -416,4 +419,14 @@ public WorldGuardPlugin getWorldGuardPlugin()
return this.wg; return this.wg;
} }
public iConomy getiConomy()
{
return this.iConomy;
}
public void setiConomy(iConomy newVal)
{
this.iConomy = newVal;
}
} }

View File

@ -18,8 +18,8 @@
*/ */
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.nijikokun.bukkit.iConomy.iConomy;
import java.util.logging.*; import java.util.logging.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Priority;
@ -52,6 +52,7 @@ public class WorldGuardPlugin extends JavaPlugin {
private final GlobalRegionManager globalRegionManager = new GlobalRegionManager(this); private final GlobalRegionManager globalRegionManager = new GlobalRegionManager(this);
private final WorldGuardConfiguration configuration = new WorldGuardConfiguration(this); private final WorldGuardConfiguration configuration = new WorldGuardConfiguration(this);
/** /**
* Called on plugin enable. * Called on plugin enable.
*/ */
@ -103,6 +104,8 @@ private void registerEvents() {
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
// 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);
} }

View File

@ -22,9 +22,8 @@
import org.bukkit.event.server.PluginEvent; import org.bukkit.event.server.PluginEvent;
import org.bukkit.event.server.ServerListener; import org.bukkit.event.server.ServerListener;
import com.nijiko.iConomy.configuration.PropertyHandler;
import com.nijikokun.bukkit.iConomy.iConomy; import com.nijikokun.bukkit.iConomy.iConomy;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
/** /**
* *
@ -48,7 +47,7 @@ public WorldGuardServerListener(WorldGuardPlugin plugin) {
@Override @Override
public void onPluginEnabled(PluginEvent event) { public void onPluginEnabled(PluginEvent event) {
if(event.getPlugin().getDescription().getName().equals("iConomy")) { if(event.getPlugin().getDescription().getName().equals("iConomy")) {
WorldGuardPlugin.iConomy = (iConomy)event.getPlugin(); plugin.getWgConfiguration().setiConomy((iConomy)event.getPlugin());
} }
} }
} }

View File

@ -89,6 +89,9 @@ public class WorldGuardWorldConfiguration {
public boolean useRegions; public boolean useRegions;
public int regionWand = 287; public int regionWand = 287;
public String blockCreatureSpawn; public String blockCreatureSpawn;
public boolean useiConomy;
public boolean buyOnClaim;
public int buyOnClaimPrice;
/* Configuration data end */ /* Configuration data end */
@ -198,6 +201,10 @@ private void loadConfiguration() {
useRegions = config.getBoolean("regions.enable", true); useRegions = config.getBoolean("regions.enable", true);
regionWand = config.getInt("regions.wand", 287); regionWand = config.getInt("regions.wand", 287);
useiConomy = config.getBoolean("iconomy.enable", false);
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);
buyOnClaimPrice = config.getInt("iconomy.buy-on-claim-price", 1);
for (String creature : config.getStringList("mobs.block-creature-spawn", null)) { for (String creature : config.getStringList("mobs.block-creature-spawn", null)) {
blockCreatureSpawn += creature.toLowerCase() + " "; blockCreatureSpawn += creature.toLowerCase() + " ";
} }

View File

@ -24,7 +24,7 @@
import com.nijikokun.bukkit.iConomy.Account; import com.nijikokun.bukkit.iConomy.Account;
import com.nijikokun.bukkit.iConomy.iConomy; import com.nijikokun.bukkit.iConomy.iConomy;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
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;
@ -37,19 +37,24 @@
*/ */
public class CommandBuyRegion extends WgCommand { public class CommandBuyRegion extends WgCommand {
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException { public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) 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;
} }
if (wg.iConomy == null) { Player player = (Player) sender;
if (cfg.getiConomy() == null) {
sender.sendMessage("iConomy is not installed on this Server."); sender.sendMessage("iConomy is not installed on this Server.");
return true; return true;
} }
cfg.checkRegionPermission(player, "buyregion");
String id = args[0]; String id = args[0];
Player player = (Player) sender;
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName()); RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
ProtectedRegion region = mgr.getRegion(id); ProtectedRegion region = mgr.getRegion(id);
if (region != null) { if (region != null) {
AreaFlags flags = region.getFlags(); AreaFlags flags = region.getFlags();

View File

@ -56,6 +56,8 @@ public CommandHandler(WorldGuardPlugin wg)
// commands that DO NOT support console as sender // commands that DO NOT support console as sender
this.commandMap.put("stack", new CommandStack()); this.commandMap.put("stack", new CommandStack());
this.commandMap.put("locate", new CommandLocate()); this.commandMap.put("locate", new CommandLocate());
this.commandMap.put("tpregrion", new CommandTpRegion());
this.commandMap.put("buyregion", new CommandBuyRegion());
} }

View File

@ -106,11 +106,11 @@ public boolean handle(CommandSender sender, String senderName, String command, S
region.getOwners().addPlayer(player.getName()); region.getOwners().addPlayer(player.getName());
if (wg.iConomy != null && wg.useiConomy && wg.buyOnClaim) { if (cfg.getiConomy() != null && wcfg.useiConomy && wcfg.buyOnClaim) {
if (iConomy.getBank().hasAccount(player.getName())) { if (iConomy.getBank().hasAccount(player.getName())) {
Account account = iConomy.getBank().getAccount(player.getName()); Account account = iConomy.getBank().getAccount(player.getName());
double balance = account.getBalance(); double balance = account.getBalance();
int regionCosts = region.countBlocks() * wg.buyOnClaimPrice; int regionCosts = region.countBlocks() * wcfg.buyOnClaimPrice;
if (balance >= regionCosts) { if (balance >= regionCosts) {
account.subtract(regionCosts); account.subtract(regionCosts);
player.sendMessage(ChatColor.YELLOW + "You have bought that region for " + player.sendMessage(ChatColor.YELLOW + "You have bought that region for " +

View File

@ -18,9 +18,8 @@
*/ */
package com.sk89q.worldguard.bukkit.commands; package com.sk89q.worldguard.bukkit.commands;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.BukkitPlayer; import com.sk89q.worldguard.bukkit.BukkitPlayer;
import com.sk89q.worldguard.bukkit.BukkitUtil;
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration; import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration; import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException; import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
@ -69,16 +68,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) { if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
cfg.checkRegionPermission(sender, "region.flag.ownregions"); cfg.checkRegionPermission(sender, "region.flag.ownregions");
} } else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
else if(region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
cfg.checkRegionPermission(sender, "region.flag.memberregions"); cfg.checkRegionPermission(sender, "region.flag.memberregions");
} } else {
else {
cfg.checkRegionPermission(sender, "region.flag.foreignregions"); cfg.checkRegionPermission(sender, "region.flag.foreignregions");
} }
} } else {
else
{
cfg.checkRegionPermission(sender, "region.flag.foreignregions"); cfg.checkRegionPermission(sender, "region.flag.foreignregions");
} }
@ -86,41 +81,65 @@ else if(region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
if (nfo == null) { if (nfo == null) {
if(!(sender instanceof Player)) if (!(sender instanceof Player)) {
{
sender.sendMessage(ChatColor.RED + "Unknown flag, or not supported in console mode."); sender.sendMessage(ChatColor.RED + "Unknown flag, or not supported in console mode.");
return true; return true;
} }
Player player = (Player)sender; Player player = (Player) sender;
if(nameStr.equals("spawn")) if (nameStr.equals("spawn")) {
{
if (valueStr.equals("set")) { if (valueStr.equals("set")) {
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn set to current location");
AreaFlags flags = region.getFlags();
Location l = player.getLocation(); Location l = player.getLocation();
if (region.contains(BukkitUtil.toVector(l))) {
AreaFlags flags = region.getFlags();
flags.setFlag("spawn", "x", l.getX()); flags.setFlag("spawn", "x", l.getX());
flags.setFlag("spawn", "y", l.getY()); flags.setFlag("spawn", "y", l.getY());
flags.setFlag("spawn", "z", l.getZ()); flags.setFlag("spawn", "z", l.getZ());
flags.setFlag("spawn", "yaw", l.getYaw()); flags.setFlag("spawn", "yaw", l.getYaw());
flags.setFlag("spawn", "pitch", l.getPitch()); flags.setFlag("spawn", "pitch", l.getPitch());
flags.setFlag("spawn", "world", l.getWorld().getName()); flags.setFlag("spawn", "world", l.getWorld().getName());
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn set to current location");
} else { } else {
player.sendMessage(ChatColor.RED + "You must set the teleport location inside the region it belongs to.");
}
} else if (valueStr.equals("delete")) {
AreaFlags flags = region.getFlags(); AreaFlags flags = region.getFlags();
flags.setFlag("spawn", "x", (String)null); flags.setFlag("spawn", "x", (String) null);
flags.setFlag("spawn", "y", (String)null); flags.setFlag("spawn", "y", (String) null);
flags.setFlag("spawn", "z", (String)null); flags.setFlag("spawn", "z", (String) null);
flags.setFlag("spawn", "yaw", (String)null); flags.setFlag("spawn", "yaw", (String) null);
flags.setFlag("spawn", "pitch", (String)null); flags.setFlag("spawn", "pitch", (String) null);
flags.setFlag("spawn", "world", (String)null); flags.setFlag("spawn", "world", (String) null);
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn removed."); sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn removed.");
}else{ } else {
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> spawn <set|delete>"); player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> spawn <set|delete>");
} }
}else if(nameStr.equals("teleport")) } else if (nameStr.equals("teleport")) {
{ if (valueStr.equals("set")) {
sender.sendMessage(ChatColor.RED + "Unknown flag specified."); Location l = player.getLocation();
if (region.contains(BukkitUtil.toVector(l))) {
AreaFlags flags = region.getFlags();
flags.setFlag("teleport", "x", l.getX());
flags.setFlag("teleport", "y", l.getY());
flags.setFlag("teleport", "z", l.getZ());
flags.setFlag("teleport", "world", l.getWorld().getName());
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport set to current location");
} else {
player.sendMessage(ChatColor.RED + "You must set the teleport location inside the region it belongs to.");
}
} else if (valueStr.equals("delete")) {
AreaFlags flags = region.getFlags();
flags.setFlag("teleport", "x", (String) null);
flags.setFlag("teleport", "y", (String) null);
flags.setFlag("teleport", "z", (String) null);
flags.setFlag("teleport", "world", (String) null);
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport removed.");
} else {
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> teleport <set|delete>");
}
} else {
player.sendMessage(ChatColor.RED + "Unknown flag specified.");
} }
return true; return true;
} }

View File

@ -3,13 +3,13 @@
*/ */
package com.sk89q.worldguard.bukkit.commands; package com.sk89q.worldguard.bukkit.commands;
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
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.AreaFlags; import com.sk89q.worldguard.protection.regions.AreaFlags;
@ -21,58 +21,51 @@
*/ */
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 {
* @see com.sk89q.worldguard.bukkit.commands.WgCommand#handle(org.bukkit.command.CommandSender, java.lang.String, java.lang.String, java.lang.String[], com.sk89q.worldguard.bukkit.commands.CommandHandler, com.sk89q.worldguard.bukkit.WorldGuardPlugin)
*/
@Override
public boolean handle(CommandSender sender, String senderName,
String command, String[] args, CommandHandler ch,
WorldGuardPlugin wg) 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;
ch.checkPermission(sender, "/tpregion"); cfg.checkPermission(sender, "tpregion");
//ch.checkArgs(args, 1, 1, "/tpregion <region name> ");
ch.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")) {
ch.checkPermission(player, "/tpregion.spawn"); cfg.checkPermission(player, "tpregion.spawn");
spawn = true; spawn = true;
} }
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName()); RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
ProtectedRegion region = mgr.getRegion(id); ProtectedRegion region = mgr.getRegion(id);
if(region !=null){ if (region != null) {
AreaFlags flags = region.getFlags(); AreaFlags flags = region.getFlags();
Double x,y,z; Double x, y, z;
World world; World world;
if(spawn){ if (spawn) {
x =flags.getDoubleFlag("spawn", "x"); x = flags.getDoubleFlag("spawn", "x");
y =flags.getDoubleFlag("spawn", "y"); y = flags.getDoubleFlag("spawn", "y");
z =flags.getDoubleFlag("spawn", "z"); z = flags.getDoubleFlag("spawn", "z");
world=wg.getServer().getWorld(flags.getFlag("teleport", "world")); world = cfg.getWorldGuardPlugin().getServer().getWorld(flags.getFlag("teleport", "world"));
}else{ } else {
x =flags.getDoubleFlag("teleport", "x"); x = flags.getDoubleFlag("teleport", "x");
y =flags.getDoubleFlag("teleport", "y"); y = flags.getDoubleFlag("teleport", "y");
z =flags.getDoubleFlag("teleport", "z"); z = flags.getDoubleFlag("teleport", "z");
world=wg.getServer().getWorld(flags.getFlag("teleport", "world")); world = cfg.getWorldGuardPlugin().getServer().getWorld(flags.getFlag("teleport", "world"));
} }
if(x != null && y !=null && z != null &&world !=null){ if (x != null && y != null && z != null && world != null) {
Location location = new Location(world, x, y, z); Location location = new Location(world, x, y, z);
player.teleportTo(location); player.teleportTo(location);
return true; return true;
}else{ } else {
player.sendMessage(ChatColor.RED + "Region: "+id+" has no teleport/spawn location assign."); player.sendMessage(ChatColor.RED + "Region: " + id + " has no teleport/spawn location assign.");
} }
}else{ } else {
player.sendMessage(ChatColor.RED + "Region: "+id+" not defined"); player.sendMessage(ChatColor.RED + "Region: " + id + " not defined");
} }
return false; return false;
} }
} }