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

View File

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