Compare commits

..

2 Commits

Author SHA1 Message Date
6d4cbb2df6 feat: check visibility of player in /plot near 2022-10-03 13:44:45 +02:00
d1a85982fb Fix "set block timer" error after "/plot download" with legacy-webinterface setting (#3812)
Add missing `Plot.removeRunning` call to Download
2022-10-01 11:37:24 +02:00
5 changed files with 13 additions and 9 deletions

View File

@ -176,7 +176,7 @@ public class DatabaseCommand extends SubCommand {
); );
worldFile.renameTo(newFile); worldFile.renameTo(newFile);
} }
plot.setId(newId); plot.setId(newId.copy());
plot.setArea(pa); plot.setArea(pa);
plots.add(plot); plots.add(plot);
continue; continue;

View File

@ -181,6 +181,7 @@ public class Download extends SubCommand {
schematicHandler.upload(compoundTag, null, null, new RunnableVal<>() { schematicHandler.upload(compoundTag, null, null, new RunnableVal<>() {
@Override @Override
public void run(URL value) { public void run(URL value) {
plot.removeRunning();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.generation_link_success"), TranslatableCaption.of("web.generation_link_success"),
Template.of("download", value.toString()), Template.of("download", value.toString()),

View File

@ -26,6 +26,7 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "near", @CommandDeclaration(command = "near",
@ -48,9 +49,13 @@ public class Near extends Command {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("near.plot_near"), TranslatableCaption.of("near.plot_near"),
Template.of("list", StringMan.join(plot.getPlayersInPlot(), ", ")) Template.of("list", StringMan.join(getPlayersInPlotVisible(plot, player), ", "))
); );
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
private List<PlotPlayer<?>> getPlayersInPlotVisible(Plot plot, PlotPlayer<?> executor) {
return plot.getPlayersInPlot().stream().filter(executor::canSee).toList();
}
} }

View File

@ -1836,8 +1836,8 @@ public class Plot {
} }
// Swap cached // Swap cached
final PlotId temp = PlotId.of(this.getId().getX(), this.getId().getY()); final PlotId temp = PlotId.of(this.getId().getX(), this.getId().getY());
this.id = plot.getId(); this.id = plot.getId().copy();
plot.id = temp; plot.id = temp.copy();
this.area.removePlot(this.getId()); this.area.removePlot(this.getId());
plot.area.removePlot(plot.getId()); plot.area.removePlot(plot.getId());
this.area.addPlotAbs(this); this.area.addPlotAbs(this);
@ -1863,7 +1863,7 @@ public class Plot {
return false; return false;
} }
this.area.removePlot(this.id); this.area.removePlot(this.id);
this.id = plot.getId(); this.id = plot.getId().copy();
this.area.addPlotAbs(this); this.area.addPlotAbs(this);
DBFunc.movePlot(this, plot); DBFunc.movePlot(this, plot);
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L)); TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));

View File

@ -110,11 +110,9 @@ public final class PlotId {
* Get a copy of the plot ID * Get a copy of the plot ID
* *
* @return Plot ID copy * @return Plot ID copy
* @deprecated PlotId is immutable, copy is not required.
*/ */
@Deprecated(forRemoval = true, since = "TODO")
public @NonNull PlotId copy() { public @NonNull PlotId copy() {
return this; return of(this.getX(), this.getY());
} }
/** /**