mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
feat: check visibility of player in /plot near
This commit is contained in:
parent
d1a85982fb
commit
6d4cbb2df6
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user