mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-15 20:04:43 +02:00
Compare commits
5 Commits
refactor/v
...
feature/v6
Author | SHA1 | Date | |
---|---|---|---|
ae340aeb2a | |||
c45bbe3ec5 | |||
49be6c0bb9 | |||
c15e1c066d | |||
35dd4899b9 |
@ -290,10 +290,13 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
if (this.econHandler != null && plotarea.useEconomy()) {
|
if (this.econHandler != null && plotarea.useEconomy()) {
|
||||||
PlotExpression costExp = plotarea.getPrices().get("claim");
|
PlotExpression costExp = plotarea.getPrices().get("claim");
|
||||||
|
PlotExpression mergeCostExp = plotarea.getPrices().get("merge");
|
||||||
|
int size = sizeX * sizeZ;
|
||||||
|
double mergeCost = size > 1 && mergeCostExp == null ? 0d : mergeCostExp.evaluate(size);
|
||||||
double cost = costExp.evaluate(Settings.Limit.GLOBAL ?
|
double cost = costExp.evaluate(Settings.Limit.GLOBAL ?
|
||||||
player.getPlotCount() :
|
player.getPlotCount() :
|
||||||
player.getPlotCount(plotarea.getWorldName()));
|
player.getPlotCount(plotarea.getWorldName()));
|
||||||
cost = (sizeX * sizeZ) * cost;
|
cost = size * cost + mergeCost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (!this.econHandler.isSupported()) {
|
if (!this.econHandler.isSupported()) {
|
||||||
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null"));
|
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null"));
|
||||||
|
@ -220,17 +220,6 @@ public final class PlotModificationManager {
|
|||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
this.removeSign();
|
this.removeSign();
|
||||||
}
|
}
|
||||||
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
|
||||||
.callUnlink(
|
|
||||||
this.plot.getArea(),
|
|
||||||
this.plot,
|
|
||||||
true,
|
|
||||||
!isDelete,
|
|
||||||
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR
|
|
||||||
);
|
|
||||||
if (event.getEventResult() != Result.DENY && this.unlinkPlot(event.isCreateRoad(), event.isCreateSign())) {
|
|
||||||
PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason());
|
|
||||||
}
|
|
||||||
final PlotManager manager = this.plot.getArea().getPlotManager();
|
final PlotManager manager = this.plot.getArea().getPlotManager();
|
||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -281,7 +270,21 @@ public final class PlotModificationManager {
|
|||||||
manager.clearPlot(current, this, actor, null);
|
manager.clearPlot(current, this, actor, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
run.run();
|
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
|
.callUnlink(
|
||||||
|
this.plot.getArea(),
|
||||||
|
this.plot,
|
||||||
|
true,
|
||||||
|
!isDelete,
|
||||||
|
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR
|
||||||
|
);
|
||||||
|
if (event.getEventResult() != Result.DENY) {
|
||||||
|
if (this.unlinkPlot(event.isCreateRoad(), event.isCreateSign(), run)) {
|
||||||
|
PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +324,23 @@ public final class PlotModificationManager {
|
|||||||
* @return success/!cancelled
|
* @return success/!cancelled
|
||||||
*/
|
*/
|
||||||
public boolean unlinkPlot(final boolean createRoad, final boolean createSign) {
|
public boolean unlinkPlot(final boolean createRoad, final boolean createSign) {
|
||||||
|
return unlinkPlot(createRoad, createSign, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlink the plot and all connected plots.
|
||||||
|
*
|
||||||
|
* @param createRoad whether to recreate road
|
||||||
|
* @param createSign whether to recreate signs
|
||||||
|
* @param whenDone Task to run when unlink is complete
|
||||||
|
* @return success/!cancelled
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public boolean unlinkPlot(final boolean createRoad, final boolean createSign, final Runnable whenDone) {
|
||||||
if (!this.plot.isMerged()) {
|
if (!this.plot.isMerged()) {
|
||||||
|
if (whenDone != null) {
|
||||||
|
whenDone.run();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Set<Plot> plots = this.plot.getConnectedPlots();
|
final Set<Plot> plots = this.plot.getConnectedPlots();
|
||||||
@ -366,14 +385,17 @@ public final class PlotModificationManager {
|
|||||||
current.getPlotModificationManager().setSign(PlayerManager.resolveName(current.getOwnerAbs()).getComponent(
|
current.getPlotModificationManager().setSign(PlayerManager.resolveName(current.getOwnerAbs()).getComponent(
|
||||||
LocaleHolder.console()));
|
LocaleHolder.console()));
|
||||||
}
|
}
|
||||||
|
if (whenDone != null) {
|
||||||
|
TaskManager.runTask(whenDone);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
} else if (whenDone != null) {
|
||||||
|
queue.setCompleteTask(whenDone);
|
||||||
}
|
}
|
||||||
if (createRoad) {
|
if (createRoad) {
|
||||||
manager.finishPlotUnlink(ids, queue);
|
manager.finishPlotUnlink(ids, queue);
|
||||||
}
|
}
|
||||||
if (queue != null) {
|
queue.enqueue();
|
||||||
queue.enqueue();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user