This commit is contained in:
Jesse Boyd
2015-09-29 16:29:28 +10:00
parent c3eb44f51c
commit b9bb9f5674
10 changed files with 175 additions and 83 deletions

View File

@ -429,25 +429,21 @@ public class Plot {
* - The result is cached locally
* @return base Plot
*/
public Plot getBasePlot(boolean recalculate) {
public Plot getBasePlot(boolean recalculate) {
if ((origin != null && !recalculate)) {
if (this.equals(origin)) {
return this;
}
return origin.getBasePlot(false);
}
if (!isMerged()) {
origin = this;
return origin;
return origin;
}
origin = this;
int min = Integer.MAX_VALUE;
for (Plot plot : MainUtil.getConnectedPlots(this)) {
if (plot.temp != -1) {
if (plot.temp < min) {
min = plot.temp;
origin = plot;
}
}
else {
if (plot.hashCode() < min) {
origin = plot;
PlotId min = id;
for (Plot plot : MainUtil.getConnectedPlots(this)) {
if (plot.id.y < min.y || (plot.id.y == min.y && plot.id.x < min.x)) {
origin = plot;
min = plot.id;
}
@ -772,15 +768,17 @@ public class Plot {
/**
* Set the plot alias
* @param alias
*/
public void setAlias(String alias) {
final String name = getSettings().getAlias();
*/
public void setAlias(String alias) {
for (Plot current : getConnectedPlots()) {
final String name = getSettings().getAlias();
if (alias == null) {
alias = "";
}
if (name.equals(alias)) {
return;
}
current.getSettings().setAlias(alias);
alias = "";
}
if (name.equals(alias)) {
return;
}
DBFunc.setAlias(current, alias);
}
}
@ -1120,6 +1118,9 @@ public class Plot {
}
return settings.flags;
}
public String getAlias() {
if (settings == null) {
return "";
}
return getSettings().getAlias();
@ -1134,7 +1135,10 @@ public class Plot {
public void setMerged(boolean[] merged) {
getSettings().merged = merged;
DBFunc.setMerged(this, merged);
MainUtil.connected_cache = null;
MainUtil.connected_cache = null;
MainUtil.regions_cache = null;
if (origin != null) {
origin.origin = null;
origin = null;
}
}
@ -1145,10 +1149,25 @@ public class Plot {
* - Does not modify terrain
* @param merged
*/
public void setMerged(int direction, boolean value) {
if (getSettings().setMerged(direction, value)) {
if (value) {
Plot other = MainUtil.getPlotRelative(this, direction).getBasePlot(false);
if (!other.equals(getBasePlot(false))) {
Plot base = ((other.id.y < id.y) || ((other.id.y == id.y) && (other.id.x < id.x))) ? other : origin;
origin.origin = base;
other.origin = base;
origin = base;
MainUtil.connected_cache = null;
}
}
else {
if (origin != null) {
origin.origin = null;
origin = null;
}
MainUtil.connected_cache = null;
if (getSettings().setMerged(direction, value)) {
}
MainUtil.connected_cache = null;
DBFunc.setMerged(this, getSettings().getMerged());
MainUtil.regions_cache = null;
}

View File

@ -111,7 +111,10 @@ public class PlotSettings {
return new BlockLoc(0, 0, 0);
}
return position;
}
}
public void setPosition(BlockLoc position) {
if (position != null && position.x == 0 && position.y == 0 && position.z == 0) {
position = null;
}
this.position = position;