mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Multiple bug fixes
Plot clearing also now requires an unlink if mega. Copy paste now requires an unlink if mega *We should fix this at some later point Plot merging now checks the entirety of both mega plots being merged (rather that just the two adjacent)
This commit is contained in:
parent
9087d48d9a
commit
4403edf7ca
@ -54,15 +54,36 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
||||||
ArrayList<PlotId> myplots = new ArrayList<PlotId>();
|
ArrayList<PlotId> myplots = new ArrayList<PlotId>();
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
myplots.add(new PlotId(x, y));
|
myplots.add(new PlotId(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return myplots;
|
||||||
|
}
|
||||||
|
|
||||||
return myplots;
|
public static ArrayList<PlotId> getMaxPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
||||||
}
|
|
||||||
|
Plot plot1 = PlotMain.getPlots(world).get(pos1);
|
||||||
|
Plot plot2 = PlotMain.getPlots(world).get(pos2);
|
||||||
|
|
||||||
|
if (plot1 != null) {
|
||||||
|
pos1 = getBottomPlot(world, plot1).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plot2 != null) {
|
||||||
|
pos2 = getTopPlot(world, plot2).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<PlotId> myplots = new ArrayList<PlotId>();
|
||||||
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
|
myplots.add(new PlotId(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return myplots;
|
||||||
|
}
|
||||||
|
|
||||||
public static Plot getBottomPlot(World world, Plot plot) {
|
public static Plot getBottomPlot(World world, Plot plot) {
|
||||||
if (plot.settings.getMerged(0)) {
|
if (plot.settings.getMerged(0)) {
|
||||||
|
@ -30,6 +30,10 @@ public class Clear extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
|
||||||
&& !plr.hasPermission("plots.admin")) {
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import com.intellectualcrafters.plot.*;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +33,10 @@ public class Copy extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||||
PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot);
|
PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot);
|
||||||
|
@ -102,19 +102,19 @@ public class Merge extends SubCommand {
|
|||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 0: // north = -y
|
case 0: // north = -y
|
||||||
plots =
|
plots =
|
||||||
PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
PlayerFunctions.getMaxPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||||
break;
|
break;
|
||||||
case 1: // east = +x
|
case 1: // east = +x
|
||||||
plots =
|
plots =
|
||||||
PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
PlayerFunctions.getMaxPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||||
break;
|
break;
|
||||||
case 2: // south = +y
|
case 2: // south = +y
|
||||||
plots =
|
plots =
|
||||||
PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
PlayerFunctions.getMaxPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||||
break;
|
break;
|
||||||
case 3: // west = -x
|
case 3: // west = -x
|
||||||
plots =
|
plots =
|
||||||
PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
PlayerFunctions.getMaxPlotSelectionIds(plr.getWorld(), new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import com.intellectualcrafters.plot.*;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +25,10 @@ public class Paste extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user