mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-23 16:48:16 +01:00
Auto Plot merge + some other things
This commit is contained in:
parent
c5195fc198
commit
fe035b97f5
@ -9,6 +9,7 @@
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.sk89q.worldedit.blocks.ClothColor.ID;
|
||||
|
||||
@ -27,8 +28,8 @@ import java.util.*;
|
||||
*
|
||||
*/
|
||||
public class PlotHelper {
|
||||
static boolean canSetFast = false;
|
||||
static long state;
|
||||
public static boolean canSetFast = false;
|
||||
static long state = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -36,6 +37,15 @@ public class PlotHelper {
|
||||
* @param blocks_per_second
|
||||
* @return
|
||||
*/
|
||||
public PlotHelper() {
|
||||
try {
|
||||
new SetBlockFast();
|
||||
canSetFast = true;
|
||||
} catch (Exception e) {
|
||||
canSetFast = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static double calculateNeededTime(double blocks, double blocks_per_second) {
|
||||
return (blocks / blocks_per_second);
|
||||
}
|
||||
@ -60,83 +70,26 @@ public class PlotHelper {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO auto plot merging
|
||||
* Merges a set of plots with another set.<br>
|
||||
* Completely merges a set of plots<br>
|
||||
* <b>(There are no checks to make sure you supply the correct arguments)</b><br>
|
||||
* - Misuse of this method can result in unusable plots<br>
|
||||
* - currentMegaPlots must be a single plot, or a set of already merged plots<br>
|
||||
* - toMerge must be a list of unmerged plots<br>
|
||||
* - the resultant mega plot must be rectangular<br>
|
||||
* - the plot arrays must be sorted in ascending order<br>
|
||||
* - the set of plots must belong to one owner and be rectangular<br>
|
||||
* - the plot array must be sorted in ascending order<br>
|
||||
* - Road will be removed where required<br>
|
||||
* - changes will be saved to DB<br>
|
||||
* @param world
|
||||
* @param player
|
||||
* @param currentMegaPlots
|
||||
* @param toMerge
|
||||
* @param dir1
|
||||
* @param dir2
|
||||
* @return
|
||||
* @param plotIds
|
||||
* @return boolean (success)
|
||||
*/
|
||||
public static boolean mergePlot(World world, Player player, ArrayList<PlotId> currentMegaPlots, ArrayList<PlotId> toMerge, int dir1, int dir2) {
|
||||
|
||||
Location pos1 = PlotHelper.getPlotBottomLoc(world, currentMegaPlots.get(0)).add(1,0,1);
|
||||
Location pos2 = PlotHelper.getPlotTopLoc(world, currentMegaPlots.get(currentMegaPlots.size()-1));
|
||||
|
||||
for (int i = 0;i < toMerge.size(); i++) {
|
||||
PlotId plotid = toMerge.get(i);
|
||||
Plot plot = PlotMain.getPlots(world).get(plotid);
|
||||
if (i<toMerge.size()-1) {
|
||||
PlotHelper.mergePlot(world, plot, PlotMain.getPlots(world).get(toMerge.get(i+1)));
|
||||
}
|
||||
}
|
||||
|
||||
Location pos3 = PlotHelper.getPlotBottomLoc(world, toMerge.get(0)).add(1,0,1);
|
||||
Location pos4 = PlotHelper.getPlotTopLoc(world, toMerge.get(toMerge.size()-1));
|
||||
|
||||
for (PlotId plotid:currentMegaPlots) {
|
||||
Plot plot = PlotMain.getPlots(world).get(plotid);
|
||||
plot.settings.setMerged(dir1, true);
|
||||
DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged());
|
||||
}
|
||||
|
||||
for (int i = 0;i < toMerge.size(); i++) {
|
||||
PlotId plotid = toMerge.get(i);
|
||||
Plot plot = PlotMain.getPlots(world).get(plotid);
|
||||
plot.settings.setMerged(dir2, true);
|
||||
DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged());
|
||||
}
|
||||
|
||||
try {
|
||||
SetBlockFast.update(player);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
public static boolean mergePlots(World world, ArrayList<PlotId> plotIds) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
||||
int sx,sz,ex,ez;
|
||||
|
||||
if (dir1 == 0 || dir1 == 3) {
|
||||
sx = Math.min(pos1.getBlockX(),pos2.getBlockX());
|
||||
ex = Math.max(pos3.getBlockX(),pos4.getBlockX());
|
||||
sz = Math.min(pos1.getBlockZ(),pos2.getBlockZ());
|
||||
ez = Math.max(pos3.getBlockZ(),pos4.getBlockZ());
|
||||
int pathsize = plotworld.ROAD_WIDTH;
|
||||
int plotheight = plotworld.PLOT_HEIGHT;
|
||||
|
||||
if (plotIds.size()<2) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
sx = Math.max(pos1.getBlockX(),pos2.getBlockX());
|
||||
ex = Math.min(pos3.getBlockX(),pos4.getBlockX());
|
||||
sz = Math.max(pos1.getBlockZ(),pos2.getBlockZ());
|
||||
ez = Math.min(pos3.getBlockZ(),pos4.getBlockZ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
int startx = Math.min(sx,ex);
|
||||
int startz = Math.min(sz,ez);
|
||||
int endx = Math.max(sx,ex)+1;
|
||||
int endz = Math.max(sz,ez)+1;
|
||||
|
||||
final short[] plotfloors = new short[plotworld.TOP_BLOCK.length];
|
||||
final short[] plotfloors_data = new short[plotworld.TOP_BLOCK.length];
|
||||
@ -145,38 +98,80 @@ public class PlotHelper {
|
||||
final short[] filling_data = new short[plotworld.MAIN_BLOCK.length];
|
||||
|
||||
for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) {
|
||||
short[] result = PlotHelper.getBlock(plotworld.TOP_BLOCK[i]);
|
||||
short[] result = getBlock(plotworld.TOP_BLOCK[i]);
|
||||
plotfloors[i] = result[0];
|
||||
plotfloors_data[i] = result[1];
|
||||
}
|
||||
for (int i = 0; i < plotworld.MAIN_BLOCK.length; i++) {
|
||||
short[] result = PlotHelper.getBlock(plotworld.MAIN_BLOCK[i]);
|
||||
short[] result = getBlock(plotworld.MAIN_BLOCK[i]);
|
||||
filling[i] = result[0];
|
||||
filling_data[i] = result[1];
|
||||
}
|
||||
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, startx, 0, startz), new Location(world, endx, 1, endz), (short) 7);
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, startx, plotworld.PLOT_HEIGHT + 1, startz), new Location(world, endx, world.getMaxHeight(), endz), (short) 0);
|
||||
PlotHelper.setCuboid(world, new Location(world, startx, 1, startz), new Location(world, endx, plotworld.PLOT_HEIGHT, endz), filling, filling_data);
|
||||
PlotHelper.setCuboid(world, new Location(world, startx, plotworld.PLOT_HEIGHT, startz), new Location(world, endx, plotworld.PLOT_HEIGHT + 1, endz), plotfloors, plotfloors_data);
|
||||
PlotId pos1 = plotIds.get(0);
|
||||
PlotId pos2 = plotIds.get(plotIds.size()-1);
|
||||
|
||||
pos1 = PlotHelper.getPlotBottomLoc(world, currentMegaPlots.get(0));
|
||||
pos2 = PlotHelper.getPlotTopLoc(world, currentMegaPlots.get(0)).add(1,0,1);
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
|
||||
boolean lx = x < pos2.x;
|
||||
boolean ly = y < pos2.y;
|
||||
|
||||
PlotId id = new PlotId(x,y);
|
||||
Plot plot = PlotMain.getPlots(world).get(id);
|
||||
|
||||
if (lx) {
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
||||
Location loc = getPlotTopLocAbs(world, id);
|
||||
|
||||
int sx = loc.getBlockX()+1;
|
||||
int ex = sx + pathsize - 1;
|
||||
int sz = loc.getBlockZ()+1;
|
||||
int ez = sz + pathsize - 1;
|
||||
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world,sx,plotheight+1,sz), new Location(world,ex+1,257+1,ez+1), (short) 0);
|
||||
|
||||
PlotHelper.setCuboid(world, new Location(world,sx+1,1,sz+1), new Location(world,ex,plotheight,ez), filling,filling_data);
|
||||
PlotHelper.setCuboid(world, new Location(world,sx+1,plotheight,sz+1), new Location(world,ex,plotheight+1,ez), plotfloors,plotfloors_data);
|
||||
}
|
||||
}
|
||||
if (!plot.settings.getMerged(1)) {
|
||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x+1,y));
|
||||
mergePlot(world, plot, plot2);
|
||||
plot.settings.setMerged(1, true);
|
||||
plot2.settings.setMerged(3, true);
|
||||
}
|
||||
}
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(2)) {
|
||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x,y+1));
|
||||
mergePlot(world, plot, plot2);
|
||||
plot.settings.setMerged(2, true);
|
||||
plot2.settings.setMerged(0, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Location megaPlotBot = getPlotBottomLoc(world, pos1);
|
||||
Location megaPlotTop = getPlotTopLoc(world, pos2).add(1,0,1);
|
||||
|
||||
short[] result_w = PlotHelper.getBlock(plotworld.WALL_BLOCK);
|
||||
short w_id = result_w[0];
|
||||
byte w_v = (byte) result_w[1];
|
||||
|
||||
for (int x = pos1.getBlockX(); x<=pos2.getBlockX(); x++) {
|
||||
for (int z = pos1.getBlockZ(); z<=pos2.getBlockZ(); z++) {
|
||||
if (z == pos1.getBlockZ() || z==pos2.getBlockZ() || x==pos1.getBlockX() || x==pos2.getBlockX()) {
|
||||
for (int x = megaPlotBot.getBlockX(); x<=megaPlotTop.getBlockX(); x++) {
|
||||
for (int z = megaPlotBot.getBlockZ(); z<=megaPlotTop.getBlockZ(); z++) {
|
||||
if (z == megaPlotBot.getBlockZ() || z==megaPlotTop.getBlockZ() || x==megaPlotBot.getBlockX() || x==megaPlotTop.getBlockX()) {
|
||||
world.getBlockAt(x, plotworld.WALL_HEIGHT+1, z).setTypeIdAndData(w_id, w_v, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Merges 2 plots
|
||||
@ -184,7 +179,7 @@ public class PlotHelper {
|
||||
* <br> - Assumes the first plot parameter is lower
|
||||
* <br> - Assumes neither are a Mega-plot
|
||||
* <br> - Assumes plots are directly next to each other
|
||||
* <br> - Does not save to DB
|
||||
* <br> - Saves to DB
|
||||
* @param world
|
||||
* @param lesserPlot
|
||||
* @param greaterPlot
|
||||
@ -245,14 +240,13 @@ public class PlotHelper {
|
||||
startz--;
|
||||
endz++;
|
||||
}
|
||||
|
||||
if (!noMerge) {
|
||||
|
||||
DBFunc.setMerged(world.getName(), lesserPlot, lesserPlot.settings.getMerged());
|
||||
DBFunc.setMerged(world.getName(), greaterPlot, greaterPlot.settings.getMerged());
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,6 +355,72 @@ public class PlotHelper {
|
||||
setWall(block, "" + id + ":" + data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void autoMerge(World world, Plot plot, Player player) {
|
||||
if (plot==null) {
|
||||
return;
|
||||
}
|
||||
if(plot.owner==null) {
|
||||
return;
|
||||
}
|
||||
if (!plot.owner.equals(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<PlotId> plots;
|
||||
boolean merge = true;
|
||||
while (merge) {
|
||||
PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||
PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
merge = false;
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x,bot.y-1), new PlotId(top.x,top.y));
|
||||
if (ownsPlots(world,plots,player, 0)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x,bot.y), new PlotId(top.x+1,top.y));
|
||||
if (ownsPlots(world,plots,player, 1)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x,bot.y), new PlotId(top.x,top.y+1));
|
||||
if (ownsPlots(world,plots,player, 2)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x-1,bot.y), new PlotId(top.x,top.y));
|
||||
if (ownsPlots(world,plots,player, 3)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (canSetFast) {
|
||||
SetBlockFast.update(player);
|
||||
}
|
||||
}
|
||||
private static boolean ownsPlots(World world, ArrayList<PlotId> plots, Player player, int dir) {
|
||||
PlotId id_min = plots.get(0);
|
||||
PlotId id_max = plots.get(plots.size()-1);
|
||||
for (PlotId myid:plots) {
|
||||
Plot myplot = PlotMain.getPlots(world).get(myid);
|
||||
if (myplot==null || !myplot.hasOwner() || !(myplot.getOwner().equals(player.getUniqueId()))) {
|
||||
return false;
|
||||
}
|
||||
PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
|
||||
if ((top.x > id_max.x && dir != 1) || (top.y > id_max.y && dir != 2)) {
|
||||
return false;
|
||||
}
|
||||
PlotId bot = PlayerFunctions.getBottomPlot(world, myplot).id;
|
||||
if ((bot.x < id_min.x && dir != 3) || (bot.y < id_min.y && dir != 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean createPlot(Player player, Plot plot) {
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -369,6 +429,11 @@ public class PlotHelper {
|
||||
PlotMain.updatePlot(p);
|
||||
DBFunc.createPlot(p);
|
||||
DBFunc.createPlotSettings(DBFunc.getId(w.getName(), p.id), p);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(w, p, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -715,12 +780,6 @@ public class PlotHelper {
|
||||
h = (prime * h) + pos1.getBlockZ();
|
||||
state = h;
|
||||
|
||||
try {
|
||||
new SetBlockFast();
|
||||
canSetFast = true;
|
||||
} catch (Exception e) {
|
||||
canSetFast = false;
|
||||
}
|
||||
if ((pos2.getBlockX() - pos1.getBlockX()) < 16) {
|
||||
setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), 1, pos2.getBlockZ()), (short) 7);
|
||||
setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), world.getMaxHeight(), pos2.getBlockZ()), (short) 0);
|
||||
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||
**/
|
||||
public class PlotWorld {
|
||||
|
||||
public boolean AUTO_MERGE;
|
||||
public static boolean AUTO_MERGE_DEFAULT = false;
|
||||
/**
|
||||
* Road Height
|
||||
*/
|
||||
|
@ -73,6 +73,7 @@ public class WorldGenerator extends ChunkGenerator {
|
||||
this.plotworld = new PlotWorld();
|
||||
Map<String, Object> options = new HashMap<String, Object>();
|
||||
|
||||
options.put("worlds." + world + ".plot.auto_merge", AUTO_MERGE_DEFAULT);
|
||||
options.put("worlds." + world + ".plot.height", PLOT_HEIGHT_DEFAULT);
|
||||
options.put("worlds." + world + ".plot.size", PLOT_WIDTH_DEFAULT);
|
||||
options.put("worlds." + world + ".plot.biome", PLOT_BIOME_DEFAULT);
|
||||
@ -101,6 +102,7 @@ public class WorldGenerator extends ChunkGenerator {
|
||||
} catch (IOException e) {
|
||||
PlotMain.sendConsoleSenderMessage("&c[Warning] PlotSquared failed to save the configuration&7 (settings.yml may differ from the one in memory)\n - To force a save from console use /plots save");
|
||||
}
|
||||
this.plotworld.AUTO_MERGE = config.getBoolean("worlds." + world + ".plot.auto_merge");
|
||||
this.plotworld.PLOT_HEIGHT = config.getInt("worlds." + world + ".plot.height");
|
||||
this.plotworld.PLOT_WIDTH = config.getInt("worlds." + world + ".plot.size");
|
||||
this.plotworld.PLOT_BIOME = config.getString("worlds." + world + ".plot.biome");
|
||||
@ -169,6 +171,7 @@ public class WorldGenerator extends ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
world.setSpawnFlags(false, false);
|
||||
return Arrays.asList((BlockPopulator) new XPopulator(PlotMain.getWorldSettings(world)));
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
if (args.length<1) {
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values,C.BLOCK_LIST_SEPARATER.s()));
|
||||
PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
|
||||
return false;
|
||||
}
|
||||
int direction = -1;
|
||||
@ -80,7 +81,6 @@ public class Merge extends SubCommand {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int direction2 = direction > 1 ? direction-2 : direction+2;
|
||||
if (direction==-1) {
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values,C.BLOCK_LIST_SEPARATER.s()));
|
||||
PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
|
||||
@ -92,16 +92,16 @@ public class Merge extends SubCommand {
|
||||
ArrayList<PlotId> plots;
|
||||
switch (direction) {
|
||||
case 0: // north = -y
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y-1), new PlotId(top.x,bot.y-1));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y-1), new PlotId(top.x,top.y));
|
||||
break;
|
||||
case 1: // east = +x
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(top.x+1,bot.y), new PlotId(top.x+1,top.y));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x+1,top.y));
|
||||
break;
|
||||
case 2: // south = +y
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,top.y+1), new PlotId(top.x,top.y+1));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x,top.y+1));
|
||||
break;
|
||||
case 3: // west = -x
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x-1,bot.y), new PlotId(bot.x-1,top.y));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x-1,bot.y), new PlotId(top.x,top.y));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@ -112,10 +112,6 @@ public class Merge extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||
return false;
|
||||
}
|
||||
if (!PlayerFunctions.getBottomPlot(world, myplot).equals(PlayerFunctions.getTopPlot(world, myplot))) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_MERGE_TO_MEGA);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PlotMergeEvent event = new PlotMergeEvent(world, plot, plots);
|
||||
@ -127,7 +123,10 @@ public class Merge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
|
||||
return PlotHelper.mergePlot(world, plr, PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x,top.y)), plots, direction, direction2);
|
||||
PlotHelper.mergePlots(world, plots);
|
||||
if (PlotHelper.canSetFast) {
|
||||
SetBlockFast.update(plr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,10 +40,7 @@ public class Unlink extends SubCommand {
|
||||
private byte wf_v;
|
||||
private short f1_id;
|
||||
private byte f1_v;
|
||||
private short f2_id;
|
||||
private byte f2_v;
|
||||
private int pathsize;
|
||||
private boolean stripes_enabled;
|
||||
private int wallheight;
|
||||
private int roadheight;
|
||||
public Unlink() {
|
||||
@ -81,6 +78,12 @@ public class Unlink extends SubCommand {
|
||||
|
||||
for (PlotId id:ids) {
|
||||
Plot myplot = PlotMain.getPlots(world).get(id);
|
||||
|
||||
if (plot.helpers!=null)
|
||||
myplot.helpers = plot.helpers;
|
||||
if (plot.denied!=null)
|
||||
myplot.denied = plot.denied;
|
||||
myplot.deny_entry = plot.deny_entry;
|
||||
myplot.settings.setMerged(new boolean[] {false, false, false, false} );
|
||||
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
|
||||
}
|
||||
@ -89,9 +92,7 @@ public class Unlink extends SubCommand {
|
||||
this.pathsize = plotworld.ROAD_WIDTH;
|
||||
this.roadheight = plotworld.ROAD_HEIGHT;
|
||||
this.wallheight = plotworld.WALL_HEIGHT;
|
||||
this.stripes_enabled = plotworld.ROAD_STRIPES_ENABLED;
|
||||
|
||||
// WALL
|
||||
// WALL
|
||||
short[] result_w = PlotHelper.getBlock(plotworld.WALL_BLOCK);
|
||||
this.w_id = result_w[0];
|
||||
this.w_v = (byte) result_w[1];
|
||||
@ -109,12 +110,8 @@ public class Unlink extends SubCommand {
|
||||
|
||||
// Floor 2
|
||||
short[] result_f2 = PlotHelper.getBlock(plotworld.ROAD_STRIPES);
|
||||
this.f2_id = result_f2[0];
|
||||
this.f2_v = (byte) result_f2[1];
|
||||
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
|
||||
boolean lx = x < pos2.x;
|
||||
boolean ly = y < pos2.y;
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlayerClaimPlotEvent.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 15:21
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-09.
|
||||
*/
|
||||
public class PlotUnmergeEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private Set<Plot> plots;
|
||||
|
||||
/**
|
||||
* PlotUnmergeEvent: Called when a plot is unmerged
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
public PlotUnmergeEvent(Set<Plot> plots) {
|
||||
this.plots = plots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots involved
|
||||
* @return Plot
|
||||
*/
|
||||
public Set<Plot> getPlost() {
|
||||
return this.plots;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
this.cancelled = b;
|
||||
}
|
||||
}
|
@ -37,10 +37,8 @@ public class WorldEditListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
System.out.print("PERM");
|
||||
return;
|
||||
}
|
||||
System.out.print("NO PERM");
|
||||
Location f = e.getFrom();
|
||||
Location t = e.getTo();
|
||||
boolean cm = false;
|
||||
@ -120,7 +118,6 @@ public class WorldEditListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
PWE.removeMask(e.getPlayer());
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
@ -141,7 +138,6 @@ public class WorldEditListener implements Listener {
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) {
|
||||
PWE.removeMask(p);
|
||||
return;
|
||||
}
|
||||
if (!p.hasPermission("plots.admin") && isPlotWorld(p.getLocation())) {
|
||||
|
Loading…
Reference in New Issue
Block a user