Fix sethome/home for mega plots
Minor tweaks
This commit is contained in:
Jesse Boyd 2015-12-16 16:38:53 +11:00
parent dd4a1faede
commit c32cfc62fa
10 changed files with 34 additions and 26 deletions

View file

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>3.2.23</version>
<version>3.2.24</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View file

@ -1841,6 +1841,7 @@ public class PS {
options.put("metrics", true);
options.put("debug", true);
options.put("update-notifications", Settings.UPDATE_NOTIFICATIONS);
options.put("merge.remove-terrain", Settings.MERGE_REMOVES_ROADS);
for (final Entry<String, Object> node : options.entrySet()) {
if (!config.contains(node.getKey())) {
@ -1966,6 +1967,7 @@ public class PS {
}
Settings.METRICS = config.getBoolean("metrics");
Settings.UPDATE_NOTIFICATIONS = config.getBoolean("update-notifications");
Settings.MERGE_REMOVES_ROADS = config.getBoolean("merge.remove-terrain");
}
/**

View file

@ -20,7 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
@ -29,12 +28,10 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringMan;
@ -46,7 +43,7 @@ command = "merge",
aliases = { "m" },
description = "Merge the plot you are standing on, with another plot",
permission = "plots.merge",
usage = "/plot merge [direction]",
usage = "/plot merge <all|n|e|s|w> [removeroads]",
category = CommandCategory.ACTIONS,
requiredType = RequiredType.NONE)
public class Merge extends SubCommand {
@ -125,7 +122,11 @@ public class Merge extends SubCommand {
// }
} else {
if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("auto")) {
if (MainUtil.autoMerge(plot, -1, maxSize - size, uuid, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
boolean terrain = Settings.MERGE_REMOVES_ROADS;
if (args.length == 2) {
terrain = args[1].equalsIgnoreCase("true");
}
if (MainUtil.autoMerge(plot, -1, maxSize - size, uuid, terrain)) {
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
@ -145,11 +146,17 @@ public class Merge extends SubCommand {
}
}
if (direction == -1) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + ">");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
return false;
}
if (MainUtil.autoMerge(plot, direction, maxSize - size, uuid, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
final boolean terrain;
if (args.length == 2) {
terrain = args[1].equalsIgnoreCase("true");
} else {
terrain = Settings.MERGE_REMOVES_ROADS;
}
if (MainUtil.autoMerge(plot, direction, maxSize - size, uuid, terrain)) {
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
@ -179,7 +186,7 @@ public class Merge extends SubCommand {
@Override
public void run() {
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
MainUtil.autoMerge(plot, dir, maxSize - size, owner, true);
MainUtil.autoMerge(plot, dir, maxSize - size, owner, terrain);
final PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
if (pp == null) {
sendMessage(accepter, C.MERGE_NOT_VALID);

View file

@ -44,17 +44,16 @@ public class SetHome extends SetCommand {
case "unset":
case "remove":
case "none": {
plot.setHome(null);
plot.getBasePlot(false).setHome(null);
MainUtil.sendMessage(plr, C.POSITION_UNSET);
return true;
}
case "": {
final String world = plr.getLocation().getWorld();
final Location base = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
base.setY(0);
final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getYaw(), relative.getPitch());
plot.setHome(blockloc);
Plot base = plot.getBasePlot(false);
Location bot = base.getBottomAbs();
Location loc = plr.getLocationFull();
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());;
base.setHome(rel);
return MainUtil.sendMessage(plr, C.POSITION_SET);
}
default: {

View file

@ -37,6 +37,7 @@ public class Settings {
public static boolean ENABLE_CLUSTERS = false;
public static boolean FAST_CLEAR = false;
public static boolean MERGE_REMOVES_ROADS = true;
/**
* Default UUID_FECTHING: false
*/

View file

@ -2375,8 +2375,7 @@ public class SQLManager implements AbstractDB {
break;
default:
try {
final String[] split = pos.split(",");
final BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
BlockLoc loc = BlockLoc.fromString(pos);
cluster.settings.setPosition(loc);
} catch (final Exception e) {}
}

View file

@ -817,16 +817,17 @@ public class Plot {
* Set the home location
* @param loc
*/
public void setHome(final BlockLoc loc) {
public void setHome(BlockLoc loc) {
final BlockLoc pos = getSettings().getPosition();
if (((pos == null || pos.equals(new BlockLoc(0, 0, 0))) && (loc == null)) || ((pos != null) && pos.equals(loc))) {
return;
}
getSettings().setPosition(loc);
if (getSettings().getPosition() == null) {
DBFunc.setPosition(this, "");
Plot plot = getBasePlot(false);
plot.getSettings().setPosition(loc);
if (plot.getSettings().getPosition() == null) {
DBFunc.setPosition(plot, "");
} else {
DBFunc.setPosition(this, getSettings().getPosition().toString());
DBFunc.setPosition(plot, getSettings().getPosition().toString());
}
}

View file

@ -1616,14 +1616,14 @@ public class MainUtil {
* @return Home Location
*/
public static Location getPlotHome(final String w, final PlotId plotid) {
final Plot plot = getPlot(w, plotid);
final Plot plot = getPlot(w, plotid).getBasePlot(false);
final BlockLoc home = plot.getPosition();
PS.get().getPlotManager(w);
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
return getDefaultHome(plot);
} else {
Location bot = plot.getBottomAbs();
final Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z);
final Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z, home.yaw, home.pitch);
if (BlockManager.manager.getBlock(loc).id != 0) {
loc.setY(Math.max(getHeighestBlock(w, loc.getX(), loc.getZ()), bot.getY()));
}

View file

@ -485,7 +485,6 @@ public abstract class SchematicHandler {
*/
public Schematic getSchematic(final File file) {
if (!file.exists()) {
PS.debug(file.toString() + " doesn't exist");
return null;
}
try {

Binary file not shown.