Various changes and Merge Economy Fix

This commit is contained in:
Matt 2016-03-13 22:44:59 -04:00
parent 8739f3ef78
commit ae885eafca
6 changed files with 29 additions and 32 deletions

View File

@ -5,9 +5,17 @@ import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -17,7 +25,12 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.*; import org.bukkit.material.MaterialData;
import org.bukkit.material.Sandstone;
import org.bukkit.material.Step;
import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -282,7 +295,7 @@ public class BukkitUtil extends WorldUtil {
final World world = getWorld(loc.getWorld()); final World world = getWorld(loc.getWorld());
final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ());
if (block == null) { if (block == null) {
return new PlotBlock((short) 0, (byte) 0); return PlotBlock.EVERYTHING;
} }
return new PlotBlock((short) block.getTypeId(), block.getData()); return new PlotBlock((short) block.getTypeId(), block.getData());
} }

View File

@ -32,14 +32,8 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE,
command = "auto", description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
permission = "plots.auto",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
description = "Claim the nearest plot",
aliases = { "a" },
usage = "/plot auto [length,width]")
public class Auto extends SubCommand { public class Auto extends SubCommand {
public static PlotId getNextPlotId(final PlotId id, final int step) { public static PlotId getNextPlotId(final PlotId id, final int step) {
@ -149,7 +143,7 @@ public class Auto extends SubCommand {
sendMessage(plr, C.REMOVED_BALANCE, cost + ""); sendMessage(plr, C.REMOVED_BALANCE, cost + "");
} }
} }
if (schematic != null && !schematic.equals("")) { if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) { if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;

View File

@ -31,14 +31,8 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
command = "claim", requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim")
aliases = { "c" },
description = "Claim the current plot you're standing on",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
permission = "plots.claim",
usage = "/plot claim")
public class Claim extends SubCommand { public class Claim extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {
@ -87,7 +81,7 @@ public class Claim extends SubCommand {
} }
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
} }
if (!schematic.equals("")) { if (!schematic.isEmpty()) {
if (world.SCHEMATIC_CLAIM_SPECIFY) { if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);

View File

@ -89,8 +89,7 @@ public class Merge extends SubCommand {
} }
final PlotArea plotworld = plot.getArea(); final PlotArea plotworld = plot.getArea();
final double price = plotworld.PRICES.get("merge"); final double price = plotworld.PRICES.get("merge");
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) {
&& EconHandler.manager.getMoney(plr) < price) {
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + ""); sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
return false; return false;
} }
@ -123,7 +122,7 @@ public class Merge extends SubCommand {
terrain = "true".equalsIgnoreCase(args[1]); terrain = "true".equalsIgnoreCase(args[1]);
} }
if (plot.autoMerge(-1, maxSize, uuid, terrain)) { if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
if (EconHandler.manager != null && price > 0d) { if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
EconHandler.manager.withdrawMoney(plr, price); EconHandler.manager.withdrawMoney(plr, price);
sendMessage(plr, C.REMOVED_BALANCE, price + ""); sendMessage(plr, C.REMOVED_BALANCE, price + "");
} }

View File

@ -95,7 +95,7 @@ public class BO3Handler {
BO3 bo3 = map.get(loc); BO3 bo3 = map.get(loc);
for (int y = 1; y < height; y++) { for (int y = 1; y < height; y++) {
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z)); final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) { if (!contains(cpw.MAIN_BLOCK, block)) {
if (bo3 == null) { if (bo3 == null) {
bo3 = new BO3(alias, loc); bo3 = new BO3(alias, loc);
map.put(loc, bo3); map.put(loc, bo3);
@ -105,7 +105,7 @@ public class BO3Handler {
} }
} }
final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z)); final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z));
if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) { if (!contains(cpw.TOP_BLOCK, floor)) {
if (bo3 == null) { if (bo3 == null) {
bo3 = new BO3(alias, loc); bo3 = new BO3(alias, loc);
map.put(loc, bo3); map.put(loc, bo3);
@ -115,7 +115,7 @@ public class BO3Handler {
} }
for (int y = height + 1; y < 256; y++) { for (int y = height + 1; y < 256; y++) {
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z)); final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
if ((block != null) && (block.id != 0)) { if (block.id != 0) {
if (bo3 == null) { if (bo3 == null) {
bo3 = new BO3(alias, loc); bo3 = new BO3(alias, loc);
map.put(loc, bo3); map.put(loc, bo3);
@ -205,4 +205,4 @@ public class BO3Handler {
} }
return base; return base;
} }
} }

View File

@ -155,9 +155,6 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }