This commit is contained in:
Alexander Brandes 2023-03-05 10:42:15 +01:00
parent ad522358c7
commit b8b5dd8d13
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
4 changed files with 33 additions and 42 deletions

View File

@ -107,37 +107,35 @@ public class Clear extends Command {
} }
BackupManager.backup(player, plot, () -> { BackupManager.backup(player, plot, () -> {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> { boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> TaskManager.runTask(() -> {
TaskManager.runTask(() -> { plot.removeRunning();
plot.removeRunning(); // If the state changes, then mark it as no longer done
// If the state changes, then mark it as no longer done if (DoneFlag.isDone(plot)) {
if (DoneFlag.isDone(plot)) { PlotFlag<?, ?> plotFlag =
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
plot.getFlagContainer().getFlag(DoneFlag.class); PlotFlagRemoveEvent event = this.eventDispatcher
PlotFlagRemoveEvent event = this.eventDispatcher .callFlagRemove(plotFlag, plot);
.callFlagRemove(plotFlag, plot); if (event.getEventResult() != Result.DENY) {
if (event.getEventResult() != Result.DENY) { plot.removeFlag(event.getFlag());
plot.removeFlag(event.getFlag());
}
} }
if (!plot.getFlag(AnalysisFlag.class).isEmpty()) { }
PlotFlag<?, ?> plotFlag = if (!plot.getFlag(AnalysisFlag.class).isEmpty()) {
plot.getFlagContainer().getFlag(AnalysisFlag.class); PlotFlag<?, ?> plotFlag =
PlotFlagRemoveEvent event = this.eventDispatcher plot.getFlagContainer().getFlag(AnalysisFlag.class);
.callFlagRemove(plotFlag, plot); PlotFlagRemoveEvent event = this.eventDispatcher
if (event.getEventResult() != Result.DENY) { .callFlagRemove(plotFlag, plot);
plot.removeFlag(event.getFlag()); if (event.getEventResult() != Result.DENY) {
} plot.removeFlag(event.getFlag());
} }
player.sendMessage( }
TranslatableCaption.of("working.clearing_done"), player.sendMessage(
TagResolver.builder() TranslatableCaption.of("working.clearing_done"),
.tag("amount", Tag.inserting(Component.text(System.currentTimeMillis() - start))) TagResolver.builder()
.tag("plot", Tag.inserting(Component.text(plot.getId().toString()))) .tag("amount", Tag.inserting(Component.text(System.currentTimeMillis() - start)))
.build() .tag("plot", Tag.inserting(Component.text(plot.getId().toString())))
); .build()
}); );
}); }));
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
} else { } else {

View File

@ -46,6 +46,7 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -813,11 +814,7 @@ public class Cluster extends SubCommand {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} else { } else {
final String owner; final String owner;
if (username == null) { owner = Objects.requireNonNullElse(username, "unknown");
owner = "unknown";
} else {
owner = username;
}
String name = cluster.getName(); String name = cluster.getName();
String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + ( String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + (
cluster.getP2().getY() - cluster.getP1().getY() + 1); cluster.getP2().getY() - cluster.getP1().getY() + 1);

View File

@ -220,9 +220,8 @@ public class Purge extends SubCommand {
try { try {
ids.add(plot.temp); ids.add(plot.temp);
if (finalClear) { if (finalClear) {
plot.getPlotModificationManager().clear(false, true, player, () -> { plot.getPlotModificationManager().clear(false, true, player,
LOGGER.info("Plot {} cleared by purge", plot.getId()); () -> LOGGER.info("Plot {} cleared by purge", plot.getId()));
});
} else { } else {
plot.getPlotModificationManager().removeSign(); plot.getPlotModificationManager().removeSign();
} }

View File

@ -36,6 +36,7 @@ import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
/** /**
@ -92,11 +93,7 @@ public class DefaultProgressSubscriber implements ProgressSubscriber {
this.actor = actor; this.actor = actor;
this.interval = TaskTime.ms(interval); this.interval = TaskTime.ms(interval);
this.wait = TaskTime.ms(wait); this.wait = TaskTime.ms(wait);
if (caption == null) { this.caption = Objects.requireNonNullElseGet(caption, () -> TranslatableCaption.of("working.progress"));
this.caption = TranslatableCaption.of("working.progress");
} else {
this.caption = caption;
}
} }
@Override @Override