diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java index d515a3b33..68d97e380 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -107,37 +107,35 @@ public class Clear extends Command { } BackupManager.backup(player, plot, () -> { final long start = System.currentTimeMillis(); - boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> { - TaskManager.runTask(() -> { - plot.removeRunning(); - // If the state changes, then mark it as no longer done - if (DoneFlag.isDone(plot)) { - PlotFlag plotFlag = - plot.getFlagContainer().getFlag(DoneFlag.class); - PlotFlagRemoveEvent event = this.eventDispatcher - .callFlagRemove(plotFlag, plot); - if (event.getEventResult() != Result.DENY) { - plot.removeFlag(event.getFlag()); - } + boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> TaskManager.runTask(() -> { + plot.removeRunning(); + // If the state changes, then mark it as no longer done + if (DoneFlag.isDone(plot)) { + PlotFlag plotFlag = + plot.getFlagContainer().getFlag(DoneFlag.class); + PlotFlagRemoveEvent event = this.eventDispatcher + .callFlagRemove(plotFlag, plot); + if (event.getEventResult() != Result.DENY) { + plot.removeFlag(event.getFlag()); } - if (!plot.getFlag(AnalysisFlag.class).isEmpty()) { - PlotFlag plotFlag = - plot.getFlagContainer().getFlag(AnalysisFlag.class); - PlotFlagRemoveEvent event = this.eventDispatcher - .callFlagRemove(plotFlag, plot); - if (event.getEventResult() != Result.DENY) { - plot.removeFlag(event.getFlag()); - } + } + if (!plot.getFlag(AnalysisFlag.class).isEmpty()) { + PlotFlag plotFlag = + plot.getFlagContainer().getFlag(AnalysisFlag.class); + PlotFlagRemoveEvent event = this.eventDispatcher + .callFlagRemove(plotFlag, plot); + if (event.getEventResult() != Result.DENY) { + plot.removeFlag(event.getFlag()); } - player.sendMessage( - TranslatableCaption.of("working.clearing_done"), - TagResolver.builder() - .tag("amount", Tag.inserting(Component.text(System.currentTimeMillis() - start))) - .tag("plot", Tag.inserting(Component.text(plot.getId().toString()))) - .build() - ); - }); - }); + } + player.sendMessage( + TranslatableCaption.of("working.clearing_done"), + TagResolver.builder() + .tag("amount", Tag.inserting(Component.text(System.currentTimeMillis() - start))) + .tag("plot", Tag.inserting(Component.text(plot.getId().toString()))) + .build() + ); + })); if (!result) { player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); } else { diff --git a/Core/src/main/java/com/plotsquared/core/command/Cluster.java b/Core/src/main/java/com/plotsquared/core/command/Cluster.java index 41510561a..f52a56616 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -46,6 +46,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeoutException; @@ -813,11 +814,7 @@ public class Cluster extends SubCommand { player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); } else { final String owner; - if (username == null) { - owner = "unknown"; - } else { - owner = username; - } + owner = Objects.requireNonNullElse(username, "unknown"); String name = cluster.getName(); String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + ( cluster.getP2().getY() - cluster.getP1().getY() + 1); diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java index 0af406950..b69e24835 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -220,9 +220,8 @@ public class Purge extends SubCommand { try { ids.add(plot.temp); if (finalClear) { - plot.getPlotModificationManager().clear(false, true, player, () -> { - LOGGER.info("Plot {} cleared by purge", plot.getId()); - }); + plot.getPlotModificationManager().clear(false, true, player, + () -> LOGGER.info("Plot {} cleared by purge", plot.getId())); } else { plot.getPlotModificationManager().removeSign(); } diff --git a/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java b/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java index 5e355d8cf..3f5e3ab24 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java +++ b/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java @@ -36,6 +36,7 @@ import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import org.checkerframework.checker.nullness.qual.NonNull; import javax.annotation.Nullable; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -92,11 +93,7 @@ public class DefaultProgressSubscriber implements ProgressSubscriber { this.actor = actor; this.interval = TaskTime.ms(interval); this.wait = TaskTime.ms(wait); - if (caption == null) { - this.caption = TranslatableCaption.of("working.progress"); - } else { - this.caption = caption; - } + this.caption = Objects.requireNonNullElseGet(caption, () -> TranslatableCaption.of("working.progress")); } @Override