diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 768f3312c..021367a13 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,12 +9,18 @@
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
@@ -37,186 +43,111 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -238,8 +169,6 @@
-
-
@@ -249,17 +178,25 @@
-
-
+
+
+
+
+
+
+
+
+
+
@@ -300,6 +237,8 @@
+
+
@@ -311,42 +250,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -368,16 +271,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -464,14 +357,12 @@
-
+
-
-
@@ -512,143 +403,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/C.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Plot.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/XPopulator.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java
- $PROJECT_DIR$/PlotSquared/src/plugin.yml
-
-
-
-
-
-
-
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/events/PlotMergeEvent.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/events/PlotUnmergeEvent.java
-
-
-
-
-
-
-
- $PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotCollection.java
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -797,7 +551,9 @@
-
+
+
+
1411382351159
@@ -879,11 +635,23 @@
1411632266961
1411632266961
-
+
+ 1411764822840
+ 1411764822840
+
+
+ 1411892478249
+ 1411892478249
+
+
+ 1411893824125
+ 1411893824125
+
+
-
+
@@ -906,7 +674,7 @@
-
+
@@ -916,34 +684,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -988,27 +731,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1051,7 +773,6 @@
-
@@ -1066,7 +787,6 @@
-
@@ -1112,14 +832,6 @@
-
-
-
-
-
-
-
-
@@ -1181,7 +893,6 @@
-
@@ -1192,18 +903,10 @@
-
-
-
-
-
-
-
-
@@ -1211,7 +914,6 @@
-
@@ -1219,17 +921,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -1244,9 +935,6 @@
-
-
-
@@ -1254,7 +942,6 @@
-
@@ -1270,7 +957,6 @@
-
@@ -1278,7 +964,6 @@
-
@@ -1286,28 +971,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1315,15 +978,13 @@
-
-
-
-
+
+
@@ -1343,97 +1004,143 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java
index 4338a2351..a1b074e6f 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/C.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java
@@ -18,6 +18,12 @@ import org.bukkit.ChatColor;
*
*/
public enum C {
+ /**
+ * Economy Stuff
+ */
+ CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"),
+ CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"),
+ REMOVED_BALANCE("&6%s &chas been taken from your balance"),
/*
* Setup Stuff
*/
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java
index 7b98fd3aa..2790ddea5 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java
@@ -1,12 +1,10 @@
package com.intellectualcrafters.plot;
+import com.sk89q.worldedit.*;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import com.sk89q.worldedit.LocalSession;
-import com.sk89q.worldedit.LocalWorld;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.masks.RegionMask;
import com.sk89q.worldedit.regions.CuboidRegion;
@@ -18,47 +16,62 @@ import com.sk89q.worldedit.regions.CuboidRegion;
*/
public class PWE {
+ @SuppressWarnings("unused")
public static void setMask(Player p, Location l) {
- LocalSession s = PlotMain.worldEdit.getSession(p);
- Plot plot = PlayerFunctions.getCurrentPlot(p);
- if (plot != null) {
- boolean r;
- if (plot.getOwner() != null) {
- r = plot.getOwner().equals(p.getUniqueId());
+ try {
+ LocalSession s;
+ if (PlotMain.worldEdit == null) {
+ s = WorldEdit.getInstance().getSession(p.getName());
} else {
- r = false;
+ s = PlotMain.worldEdit.getSession(p);
}
- if (!r) {
- if (p.hasPermission("plots.we.member") && plot.hasRights(p)) {
- r = true;
- } else if (p.hasPermission("plots.we.bypass")) {
- s.setMask(null);
+ Plot plot = PlayerFunctions.getCurrentPlot(p);
+ if (plot != null) {
+ boolean r;
+ r = plot.getOwner() != null && plot.getOwner().equals(p.getUniqueId());
+ if (!r) {
+ if (p.hasPermission("plots.we.member") && plot.hasRights(p)) {
+ r = true;
+ } else if (p.hasPermission("plots.we.bypass")) {
+ s.setMask(null);
+ return;
+ }
+ }
+ if (r) {
+ World w = p.getWorld();
+ Location b = PlotHelper.getPlotBottomLoc(w, plot.id);
+ Location t = PlotHelper.getPlotTopLoc(w, plot.id);
+ Vector p1 = new Vector(b.getBlockX(), b.getBlockY(), b.getBlockZ());
+ Vector p2 = new Vector(t.getBlockX(), t.getBlockY(), t.getBlockZ());
+ LocalWorld world = PlotMain.worldEdit.wrapPlayer(p).getWorld();
+ CuboidRegion cr = new CuboidRegion(world, p1, p2);
+ RegionMask rm = new RegionMask(cr);
+ s.setMask(rm);
return;
}
}
- if (r) {
- World w = p.getWorld();
- Location b = PlotHelper.getPlotBottomLoc(w, plot.id);
- Location t = PlotHelper.getPlotTopLoc(w, plot.id);
- Vector p1 = new Vector(b.getBlockX(), b.getBlockY(), b.getBlockZ());
- Vector p2 = new Vector(t.getBlockX(), t.getBlockY(), t.getBlockZ());
- LocalWorld world = PlotMain.worldEdit.wrapPlayer(p).getWorld();
- CuboidRegion cr = new CuboidRegion(world, p1, p2);
- RegionMask rm = new RegionMask(cr);
- s.setMask(rm);
- return;
+ if (s.getMask() == null) {
+ BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
+ LocalWorld world = plr.getWorld();
+ Vector p1 = new Vector(0, 0, 0), p2 = new Vector(0, 0, 0);
+ s.setMask(new RegionMask(new CuboidRegion(world, p1, p2)));
}
- }
- if (s.getMask() == null) {
- BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
- LocalWorld world = plr.getWorld();
- Vector p1 = new Vector(0, 0, 0), p2 = new Vector(0, 0, 0);
- s.setMask(new RegionMask(new CuboidRegion(world, p1, p2)));
+ } catch(Exception e) {
+ throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
}
}
public static void removeMask(Player p) {
- LocalSession s = PlotMain.worldEdit.getSession(p);
- s.setMask(null);
+ try {
+ LocalSession s;
+ if(PlotMain.worldEdit == null) {
+ s = WorldEdit.getInstance().getSession(p.getName());
+ } else {
+ s = PlotMain.worldEdit.getSession(p);
+ }
+ s.setMask(null);
+ } catch(Exception e) {
+ throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
+ }
}
}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java
index fdfbf3dd7..cc114eeb2 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java
@@ -10,7 +10,6 @@
package com.intellectualcrafters.plot;
import ca.mera.CameraAPI;
-
import com.intellectualcrafters.plot.Logger.LogLevel;
import com.intellectualcrafters.plot.Settings.Web;
import com.intellectualcrafters.plot.commands.Camera;
@@ -26,15 +25,16 @@ import com.intellectualcrafters.plot.listeners.WorldEditListener;
import com.intellectualcrafters.plot.listeners.WorldGuardListener;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
-
import me.confuser.barapi.BarAPI;
-
+import net.milkbowl.vault.economy.Economy;
import org.bukkit.*;
import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.*;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Tameable;
import org.bukkit.generator.ChunkGenerator;
-import org.bukkit.permissions.PermissionAttachment;
-import org.bukkit.permissions.PermissionAttachmentInfo;
+import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@@ -95,6 +95,9 @@ public class PlotMain extends JavaPlugin {
public static WorldGuardPlugin worldGuard;
+ public static Economy economy;
+ public static boolean useEconomy;
+
/**
* !!WorldGeneration!!
*/
@@ -545,7 +548,13 @@ public class PlotMain extends JavaPlugin {
checkExpired(PlotMain.getMain(), true);
checkForExpiredPlots();
}
-
+ if(getServer().getPluginManager().getPlugin("Vault") != null) {
+ RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
+ if(economyProvider != null) {
+ economy = economyProvider.getProvider();
+ }
+ useEconomy = (economy != null);
+ }
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L);
if (Web.ENABLED) {
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java
new file mode 100644
index 000000000..d119b2e62
--- /dev/null
+++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java
@@ -0,0 +1,30 @@
+package com.intellectualcrafters.plot;
+
+/**
+ * Created by Citymonstret on 2014-09-29.
+ */
+public class PlotSquaredException extends RuntimeException {
+
+ public PlotSquaredException(PlotError error, String details) {
+ super("PlotError >> " + error.getHeader() + ": " + details);
+ PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details);
+ }
+
+ public static enum PlotError {
+ MISSING_DEPENDENCY("Missing Dependency")
+ ;
+ private String errorHeader;
+ PlotError(String errorHeader) {
+ this.errorHeader = errorHeader;
+ }
+
+ public String getHeader() {
+ return this.errorHeader;
+ }
+
+ @Override
+ public String toString() {
+ return this.getHeader();
+ }
+ }
+}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java
index 4be44e08a..f07199731 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java
@@ -210,4 +210,8 @@ public class PlotWorld {
* Default default flags
*/
public static String[] DEFAULT_FLAGS_DEFAULT = new String[] {};
+
+ public boolean USE_ECONOMY = false;
+ public double PLOT_PRICE = 100;
+ public double MERGE_PRICE = 100;
}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java
index 5b13b7d6e..06e065996 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java
@@ -91,6 +91,9 @@ public class WorldGenerator extends ChunkGenerator {
options.put("worlds." + world + ".flags.default", DEFAULT_FLAGS_DEFAULT);
options.put("worlds." + world + ".schematic.schematics", plotworld.SCHEMATICS);
options.put("worlds." + world + ".schematic.specify_on_claim", plotworld.SCHEMATIC_CLAIM_SPECIFY);
+ options.put("worlds." + world + ".economy.use", plotworld.USE_ECONOMY);
+ options.put("worlds." + world + ".economy.prices.claim", plotworld.PLOT_PRICE);
+ options.put("worlds." + world + ".economy.prices.merge", plotworld.MERGE_PRICE);
for (Entry node : options.entrySet()) {
if (!config.contains(node.getKey())) {
config.set(node.getKey(), node.getValue());
@@ -119,6 +122,9 @@ public class WorldGenerator extends ChunkGenerator {
this.plotworld.SCHEMATIC_FILE = config.getString("worlds." + world + ".schematic.file");
this.plotworld.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("worlds." + world + ".schematic.specify_on_claim");
this.plotworld.SCHEMATICS = config.getStringList("worlds." + world + ".schematic.schematics");
+ this.plotworld.USE_ECONOMY = config.getBoolean("worlds." + world + ".economy.use");
+ this.plotworld.PLOT_PRICE = config.getDouble("worlds." + world + ".economy.prices.claim");
+ this.plotworld.MERGE_PRICE = config.getDouble("worlds." + world + ".economy.prices.merge");
String[] default_flags_string = config.getStringList("worlds." + world + ".flags.default").toArray(new String[0]);
Flag[] default_flags = new Flag[default_flags_string.length];
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java
index 425a90896..2158dc166 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java
@@ -9,17 +9,12 @@
package com.intellectualcrafters.plot.commands;
+import com.intellectualcrafters.plot.*;
+import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import com.intellectualcrafters.plot.C;
-import com.intellectualcrafters.plot.PlayerFunctions;
-import com.intellectualcrafters.plot.Plot;
-import com.intellectualcrafters.plot.PlotHelper;
-import com.intellectualcrafters.plot.PlotId;
-import com.intellectualcrafters.plot.PlotMain;
-
@SuppressWarnings("deprecation")
public class Auto extends SubCommand {
@@ -68,6 +63,32 @@ public class Auto extends SubCommand {
id = new PlotId(x, z);
if (PlotHelper.getPlot(world, id).owner == null) {
Plot plot = PlotHelper.getPlot(world, id);
+ PlotWorld plotworld = PlotMain.getWorldSettings(plot.getWorld());
+ if(PlotMain.useEconomy && plotworld.USE_ECONOMY) {
+ double cost = plotworld.PLOT_PRICE;
+ if(cost > 0d) {
+ Economy economy = PlotMain.economy;
+ if(economy.getBalance(plr) < cost) {
+ sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
+ return true;
+ }
+ economy.withdrawPlayer(plr, cost);
+ sendMessage(plr, C.REMOVED_BALANCE, cost + "");
+ }
+ }
+ String schematic;
+ if(args.length > 0 && !(schematic = args[0]).equals("")) {
+ if(plotworld.SCHEMATIC_CLAIM_SPECIFY) {
+ if(!plotworld.SCHEMATICS.contains(schematic.toLowerCase())) {
+ sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
+ return true;
+ }
+ if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
+ PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
+ return true;
+ }
+ }
+ }
boolean result = Claim.claimPlot(plr, plot, true);
br = !result;
}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java
index 54d209f7a..281aa3d68 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java
@@ -9,18 +9,12 @@
package com.intellectualcrafters.plot.commands;
+import com.intellectualcrafters.plot.*;
+import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
+import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
-import com.intellectualcrafters.plot.C;
-import com.intellectualcrafters.plot.PlayerFunctions;
-import com.intellectualcrafters.plot.Plot;
-import com.intellectualcrafters.plot.PlotHelper;
-import com.intellectualcrafters.plot.PlotMain;
-import com.intellectualcrafters.plot.PlotWorld;
-import com.intellectualcrafters.plot.SchematicHandler;
-import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
-
/**
*
* @author Citymonstret
@@ -51,8 +45,20 @@ public class Claim extends SubCommand {
PlayerFunctions.sendMessage(plr, C.PLOT_IS_CLAIMED);
return false;
}
+ PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
+ if(PlotMain.useEconomy && world.USE_ECONOMY) {
+ double cost = world.PLOT_PRICE;
+ if(cost > 0d) {
+ Economy economy = PlotMain.economy;
+ if(economy.getBalance(plr) < cost) {
+ sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
+ return true;
+ }
+ economy.withdrawPlayer(plr, cost);
+ sendMessage(plr, C.REMOVED_BALANCE, cost + "");
+ }
+ }
if(!schematic.equals("")) {
- PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
if(world.SCHEMATIC_CLAIM_SPECIFY) {
if(!world.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java
index 178b3f76f..fea0aa35f 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java
@@ -9,25 +9,15 @@
package com.intellectualcrafters.plot.commands;
-import java.util.ArrayList;
-import java.util.Set;
-
+import com.intellectualcrafters.plot.*;
+import com.intellectualcrafters.plot.events.PlotMergeEvent;
+import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
-import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import com.intellectualcrafters.plot.C;
-import com.intellectualcrafters.plot.PlayerFunctions;
-import com.intellectualcrafters.plot.Plot;
-import com.intellectualcrafters.plot.PlotHelper;
-import com.intellectualcrafters.plot.PlotId;
-import com.intellectualcrafters.plot.PlotMain;
-import com.intellectualcrafters.plot.PlotWorld;
-import com.intellectualcrafters.plot.SetBlockFast;
-import com.intellectualcrafters.plot.database.DBFunc;
-import com.intellectualcrafters.plot.events.PlotMergeEvent;
+import java.util.ArrayList;
/**
*
@@ -45,13 +35,34 @@ public class Merge extends SubCommand {
public static String direction(float yaw) {
yaw = yaw / 90;
- yaw = (float)Math.round(yaw);
-
- if (yaw == -4 || yaw == 0 || yaw == 4) {return "SOUTH";}
- if (yaw == -1 || yaw == 3) {return "EAST";}
- if (yaw == -2 || yaw == 2) {return "NORTH";}
- if (yaw == -3 || yaw == 1) {return "WEST";}
- return "";
+ // yaw = (float)Math.round(yaw);
+ /*
+ * if (yaw == -4 || yaw == 0 || yaw == 4) {return "SOUTH";}
+ * if (yaw == -1 || yaw == 3) {return "EAST";}
+ * if (yaw == -2 || yaw == 2) {return "NORTH";}
+ * if (yaw == -3 || yaw == 1) {return "WEST";}
+ */
+ int i = Math.round(yaw);
+ switch(i) {
+ case -4:
+ case 0:
+ case 4:
+ return "SOUTH";
+ case -1:
+ case 3:
+ return "EAST";
+ case -2:
+ case 2:
+ return "NORTH";
+ case -3:
+ case 1:
+ return "WEST";
+ default:
+ return "";
+ }
+ /////////////////////////////////////////////////////////////////////////////////////////
+ // Had to... I'm sorry xD But it looks soo much better, and should be equally as fast. //
+ /////////////////////////////////////////////////////////////////////////////////////////
}
@Override
@@ -106,7 +117,7 @@ public class Merge extends SubCommand {
default:
return false;
}
- for (PlotId myid:plots) {
+ for (PlotId myid : plots) {
Plot myplot = PlotMain.getPlots(world).get(myid);
if (myplot==null || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
@@ -117,7 +128,21 @@ public class Merge extends SubCommand {
return false;
}
}
-
+
+ PlotWorld plotWorld = PlotMain.getWorldSettings(world);
+ if(PlotMain.useEconomy && plotWorld.USE_ECONOMY) {
+ double cost = plotWorld.MERGE_PRICE;
+ if(cost > 0d) {
+ Economy economy = PlotMain.economy;
+ if(economy.getBalance(plr) < cost) {
+ sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
+ return false;
+ }
+ economy.withdrawPlayer(plr, cost);
+ sendMessage(plr, C.REMOVED_BALANCE, cost + "");
+ }
+ }
+
PlotMergeEvent event = new PlotMergeEvent(world, plot, plots);
Bukkit.getServer().getPluginManager().callEvent(event);
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java
index b07be5f79..46e6519c9 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java
@@ -157,6 +157,7 @@ public class Setup extends SubCommand implements Listener {
sendMessage(plr, C.SETUP_INIT);
return true;
}
+ return true;
}
}
diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java
index f0df5a706..b588de63a 100644
--- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java
+++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java
@@ -1,5 +1,6 @@
package com.intellectualcrafters.plot.listeners;
+import com.intellectualcrafters.plot.*;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -8,20 +9,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.player.PlayerPortalEvent;
-import org.bukkit.event.player.PlayerTeleportEvent;
-
-import com.intellectualcrafters.plot.PWE;
-import com.intellectualcrafters.plot.PlayerFunctions;
-import com.intellectualcrafters.plot.Plot;
-import com.intellectualcrafters.plot.PlotHelper;
-import com.intellectualcrafters.plot.PlotId;
-import com.intellectualcrafters.plot.PlotMain;
-import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
+import org.bukkit.event.player.*;
/**
*