mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Allow swapping only the plot data (not blocks)
This commit is contained in:
parent
f45d1f4c0b
commit
d9124dcfb8
@ -801,6 +801,27 @@ public class MainUtil {
|
|||||||
DBFunc.dbManager.swapPlots(p2, p1);
|
DBFunc.dbManager.swapPlots(p2, p1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||||
|
Plot p1 = PlotSquared.getPlots(world).get(current);
|
||||||
|
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
|
||||||
|
if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Swap cached
|
||||||
|
PlotId temp = new PlotId(p1.id.x.intValue(), p1.id.y.intValue());
|
||||||
|
p1.id.x = p2.id.x.intValue();
|
||||||
|
p1.id.y = p2.id.y.intValue();
|
||||||
|
p2.id.x = temp.x;
|
||||||
|
p2.id.y = temp.y;
|
||||||
|
PlotSquared.getPlots(world).remove(p1.id);
|
||||||
|
PlotSquared.getPlots(world).remove(p2.id);
|
||||||
|
PlotSquared.getPlots(world).put(p1.id, p1);
|
||||||
|
PlotSquared.getPlots(world).put(p2.id, p2);
|
||||||
|
// Swap database
|
||||||
|
DBFunc.dbManager.swapPlots(p2, p1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||||
final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current);
|
final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current);
|
||||||
|
Loading…
Reference in New Issue
Block a user