Fix "Fixes #1015" not resetting the home location.

Resetting involves clearing the current value i.e. so it respects
whatever is set in the config, if that value is changed.
This commit is contained in:
Jesse Boyd 2016-03-29 17:06:58 +11:00
parent 32ba55baf5
commit 30dc20b3b3
2 changed files with 7 additions and 14 deletions

View File

@ -21,7 +21,6 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
@ -46,19 +45,9 @@ public class SetHome extends SetCommand {
case "none": { case "none": {
Plot base = plot.getBasePlot(false); Plot base = plot.getBasePlot(false);
Location bot = base.getBottomAbs(); Location bot = base.getBottomAbs();
Location defaultHome = base.getDefaultHome(); base.setHome(null);
BlockLoc bLoc = new BlockLoc(defaultHome.getX() - bot.getX(), defaultHome.getY(), defaultHome.getZ() - bot.getZ(), defaultHome.getYaw(), defaultHome.getPitch());
base.setHome(bLoc);
return MainUtil.sendMessage(plr, C.POSITION_UNSET); return MainUtil.sendMessage(plr, C.POSITION_UNSET);
} }
case "": {
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: { default: {
MainUtil.sendMessage(plr, C.HOME_ARGUMENT); MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
return false; return false;

View File

@ -1133,11 +1133,15 @@ public class Plot {
*/ */
public void setHome(BlockLoc location) { public void setHome(BlockLoc location) {
Plot plot = this.getBasePlot(false); Plot plot = this.getBasePlot(false);
if (new BlockLoc(0, 0, 0).equals(location)) { if (location != null && new BlockLoc(0, 0, 0).equals(location)) {
return; return;
} }
plot.getSettings().setPosition(location); plot.getSettings().setPosition(location);
if (location != null) {
DBFunc.setPosition(plot, plot.getSettings().getPosition().toString()); DBFunc.setPosition(plot, plot.getSettings().getPosition().toString());
return;
}
DBFunc.setPosition(plot, null);
} }
/** /**