Some work on plot clusters

This commit is contained in:
boy0001
2015-08-28 12:37:01 +10:00
parent ad94637c2a
commit 22997ac089
6 changed files with 156 additions and 32 deletions

View File

@ -43,6 +43,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.util.BO3Handler;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
@ -226,6 +227,44 @@ public class Plot {
this.meta.remove(key);
}
}
/**
* Get the cluster this plot is associated with
* @return
*/
public PlotCluster getCluster() {
if (!Settings.ENABLE_CLUSTERS) {
return null;
}
if (owner == null) {
return ClusterManager.getCluster(this);
}
Flag flag = FlagManager.getPlotFlag(this, "cluster");
if (flag != null) {
PlotCluster cluster = (PlotCluster) flag.getValue();
cluster = ClusterManager.getCluster(cluster.world, cluster.getName());
if (cluster != null) {
return cluster;
}
cluster = ClusterManager.getCluster(this);
if (cluster == null) {
FlagManager.removePlotFlag(this, "cluster");
return null;
}
else {
flag = new Flag(flag.getAbstractFlag(), cluster);
FlagManager.addPlotFlag(this, flag);
return cluster;
}
}
PlotCluster cluster = ClusterManager.getCluster(this);
if (cluster != null) {
flag = new Flag(FlagManager.getFlag("cluster"), cluster);
FlagManager.addPlotFlag(this, flag);
return cluster;
}
return null;
}
/**
* Get the players currently inside this plot