mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Improved plot swapping
This commit is contained in:
parent
18ab0c221e
commit
bbd3fd3484
@ -83,10 +83,12 @@ public class Swap extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ChunkManager.manager.swap(world, plot.id, plotid);
|
MainUtil.swap(world, plot.id, plotid, new Runnable() {
|
||||||
// FIXME Requires testing!!
|
@Override
|
||||||
DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid));
|
public void run() {
|
||||||
MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
|
// FIXME not implemented yet
|
||||||
|
}
|
||||||
|
});
|
||||||
MainUtil.update(plr.getLocation());
|
MainUtil.update(plr.getLocation());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -298,14 +298,14 @@ public class PlotMeConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
||||||
sendMessage("Conversion has finished");
|
|
||||||
PlotSquared.log("&c - Stop the server");
|
|
||||||
PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml");
|
|
||||||
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
|
||||||
PlotSquared.log("&c - Start the server");
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
sendMessage("Conversion has finished");
|
||||||
|
PlotSquared.log("&c - Stop the server");
|
||||||
|
PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml");
|
||||||
|
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||||
|
PlotSquared.log("&c - Start the server");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
@ -794,6 +794,29 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean swap(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 blocks
|
||||||
|
ChunkManager.manager.swap(world, current, newPlot);
|
||||||
|
// 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