mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 12:25:46 +01:00
Add an on-complete task to PlotArea#mergePlots (#3671)
* Add an on-complete task to PlotArea#mergePlots * Fix typo
This commit is contained in:
parent
b9479405e1
commit
b6c45f2df3
@ -65,7 +65,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -965,7 +964,31 @@ public abstract class PlotArea {
|
||||
return this.plots.remove(id) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a list of plots together. This is non-blocking for the world-changes that will be made. To run a task when the
|
||||
* world changes are complete, use {@link PlotArea#mergePlots(List, boolean, Runnable)};
|
||||
*
|
||||
* @param plotIds List of plot IDs to merge
|
||||
* @param removeRoads If the roads between plots should be removed
|
||||
* @return if merges were completed successfully.
|
||||
*/
|
||||
public boolean mergePlots(final @NonNull List<PlotId> plotIds, final boolean removeRoads) {
|
||||
return mergePlots(plotIds, removeRoads, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a list of plots together. This is non-blocking for the world-changes that will be made.
|
||||
*
|
||||
* @param plotIds List of plot IDs to merge
|
||||
* @param removeRoads If the roads between plots should be removed
|
||||
* @param whenDone Task to run when any merge world changes are complete. Also runs if no changes were made. Does not
|
||||
* run if there was an error or if too few plots IDs were supplied.
|
||||
* @return if merges were completed successfully.
|
||||
* @since TODO
|
||||
*/
|
||||
public boolean mergePlots(
|
||||
final @NonNull List<PlotId> plotIds, final boolean removeRoads, final @Nullable Runnable whenDone
|
||||
) {
|
||||
if (plotIds.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
@ -1028,6 +1051,9 @@ public abstract class PlotArea {
|
||||
}
|
||||
}
|
||||
manager.finishPlotMerge(plotIds, queue);
|
||||
if (whenDone != null) {
|
||||
queue.setCompleteTask(whenDone);
|
||||
}
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user