Plot merging now removes road

This commit is contained in:
boy0001 2014-09-26 15:18:13 +10:00
parent ccb2e32c58
commit 49f93cfb25
3 changed files with 83 additions and 7 deletions

View File

@ -10,6 +10,7 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.sk89q.worldedit.blocks.ClothColor.ID;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@ -39,8 +40,32 @@ public class PlotHelper {
return (blocks / blocks_per_second); return (blocks / blocks_per_second);
} }
/**
* direction 0 = north, 1 = south, etc:
* @param plot
* @param direction
* @return
*/
public static PlotId getPlotIdRelative(PlotId id, int direction) {
switch (direction) {
case 0:
return new PlotId(id.x,id.y-1);
case 1:
return new PlotId(id.x+1,id.y);
case 2:
return new PlotId(id.x,id.y+1);
case 3:
return new PlotId(id.x-1,id.y);
}
return id;
}
/** /**
* Merges 2 plots * Merges 2 plots
* Removes the road inbetween
* <br> - Assumes the first plot parameter is lower * <br> - Assumes the first plot parameter is lower
* <br> - Assumes neither are a Mega-plot * <br> - Assumes neither are a Mega-plot
* <br> - Assumes plots are directly next to each other * <br> - Assumes plots are directly next to each other
@ -51,15 +76,60 @@ public class PlotHelper {
* @param greaterPlot * @param greaterPlot
*/ */
public static void mergePlot(World world, Plot lesserPlot, Plot greaterPlot) { public static void mergePlot(World world, Plot lesserPlot, Plot greaterPlot) {
if (lesserPlot.id.x == greaterPlot.id.x) { Location pos1 = getPlotTopLoc(world, lesserPlot.id);
lesserPlot.settings.setMerged(2, true); Location pos2 = getPlotTopLoc(world, lesserPlot.id);
greaterPlot.settings.setMerged(0, true); int startx = Math.min(pos1.getBlockX(),pos2.getBlockX());
int endx = Math.max(pos1.getBlockX(),pos2.getBlockX());
int startz = Math.min(pos1.getBlockZ(),pos2.getBlockZ());
int endz = Math.max(pos1.getBlockZ(),pos2.getBlockZ());
PlotWorld plotworld = PlotMain.getWorldSettings(world);
final short[] plotfloors = new short[plotworld.TOP_BLOCK.length];
final short[] plotfloors_data = new short[plotworld.TOP_BLOCK.length];
final short[] filling = new short[plotworld.MAIN_BLOCK.length];
final short[] filling_data = new short[plotworld.MAIN_BLOCK.length];
for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) {
Short[] result = getBlock(plotworld.TOP_BLOCK[i]);
plotfloors[i] = result[0];
plotfloors_data[i] = result[1];
} }
else { for (int i = 0; i < plotworld.MAIN_BLOCK.length; i++) {
lesserPlot.settings.setMerged(1, true); Short[] result = getBlock(plotworld.MAIN_BLOCK[i]);
greaterPlot.settings.setMerged(3, true); filling[i] = result[0];
filling_data[i] = result[1];
} }
if (lesserPlot.id.x == greaterPlot.id.x) {
// if (lesserPlot.id.y < greaterPlot.id.y) {
lesserPlot.settings.setMerged(2, true);
greaterPlot.settings.setMerged(0, true);
startz++;
endz--;
// }
// else {
// lesserPlot.settings.setMerged(0, true);
// greaterPlot.settings.setMerged(2, true);
// }
}
else {
// if (lesserPlot.id.x < greaterPlot.id.x) {
lesserPlot.settings.setMerged(1, true);
greaterPlot.settings.setMerged(3, true);
startx++;
endx--;
// }
// else {
// lesserPlot.settings.setMerged(3, true);
// greaterPlot.settings.setMerged(1, true);
// }
}
setSimpleCuboid(world, new Location(world, startx, 0, startz), new Location(world, endx, 1, endz), (short) 7);
setSimpleCuboid(world, new Location(world, startx, plotworld.PLOT_HEIGHT + 1, startz), new Location(world, endx, world.getMaxHeight(), endz), (short) 0);
setCuboid(world, new Location(world, startx, 1, startz), new Location(world, endx, plotworld.PLOT_HEIGHT, endz), filling, filling_data);
setCuboid(world, new Location(world, startx, plotworld.PLOT_HEIGHT, startz), new Location(world, endx, plotworld.PLOT_HEIGHT + 1, endz), plotfloors, plotfloors_data);
} }
public static final long nextLong() { public static final long nextLong() {

View File

@ -39,7 +39,7 @@ import com.intellectualcrafters.plot.commands.SubCommand;
@SuppressWarnings({ "unused", "javadoc" }) @SuppressWarnings({ "unused", "javadoc" })
public class PlotAPI { public class PlotAPI {
// To access plotMain stuffz. // To access plotMain stuff.
private PlotMain plotMain; private PlotMain plotMain;
// Reference // Reference
public static final String ADMIN_PERMISSION = "plots.admin"; public static final String ADMIN_PERMISSION = "plots.admin";

View File

@ -22,6 +22,7 @@ import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper; import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
/** /**
@ -115,6 +116,11 @@ public class Merge extends SubCommand {
DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged()); DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged());
} }
PlotWorld plotworld = PlotMain.getWorldSettings(world);
int pathsize = plotworld.ROAD_WIDTH;
int plotheight = 64;
//TODO replace road sections //TODO replace road sections
return true; return true;