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
4 changed files with 14 additions and 27 deletions

View File

@ -181,6 +181,7 @@ public class Download extends SubCommand {
schematicHandler.upload(compoundTag, null, null, new RunnableVal<>() {
@Override
public void run(URL value) {
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("web.generation_link_success"),
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 net.kyori.adventure.text.minimessage.Template;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "near",
@ -48,9 +49,13 @@ public class Near extends Command {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(
TranslatableCaption.of("near.plot_near"),
Template.of("list", StringMan.join(plot.getPlayersInPlot(), ", "))
Template.of("list", StringMan.join(getPlayersInPlotVisible(plot, player), ", "))
);
return CompletableFuture.completedFuture(true);
}
private List<PlotPlayer<?>> getPlayersInPlotVisible(Plot plot, PlotPlayer<?> executor) {
return plot.getPlayersInPlot().stream().filter(executor::canSee).toList();
}
}

View File

@ -28,17 +28,13 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nullable;
@SuppressWarnings("WeakerAccess")
public abstract class ClassicPlotWorld extends SquarePlotWorld {
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + ClassicPlotWorld.class.getSimpleName());
public int ROAD_HEIGHT = 62;
public int PLOT_HEIGHT = 62;
@ -125,15 +121,15 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
super.loadConfiguration(config);
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
this.PLOT_HEIGHT = Math.min(getMaxGenHeight(), config.getInt("plot.height"));
this.MAIN_BLOCK = createCheckedBlockBucket(config.getString("plot.filling"), MAIN_BLOCK);
this.TOP_BLOCK = createCheckedBlockBucket(config.getString("plot.floor"), TOP_BLOCK);
this.WALL_BLOCK = createCheckedBlockBucket(config.getString("wall.block"), WALL_BLOCK);
this.MAIN_BLOCK = new BlockBucket(config.getString("plot.filling"));
this.TOP_BLOCK = new BlockBucket(config.getString("plot.floor"));
this.WALL_BLOCK = new BlockBucket(config.getString("wall.block"));
this.ROAD_HEIGHT = Math.min(getMaxGenHeight(), config.getInt("road.height"));
this.ROAD_BLOCK = createCheckedBlockBucket(config.getString("road.block"), ROAD_BLOCK);
this.WALL_FILLING = createCheckedBlockBucket(config.getString("wall.filling"), WALL_FILLING);
this.ROAD_BLOCK = new BlockBucket(config.getString("road.block"));
this.WALL_FILLING = new BlockBucket(config.getString("wall.filling"));
this.PLACE_TOP_BLOCK = config.getBoolean("wall.place_top_block");
this.WALL_HEIGHT = Math.min(getMaxGenHeight() - (PLACE_TOP_BLOCK ? 1 : 0), config.getInt("wall.height"));
this.CLAIMED_WALL_BLOCK = createCheckedBlockBucket(config.getString("wall.block_claimed"), CLAIMED_WALL_BLOCK);
this.CLAIMED_WALL_BLOCK = new BlockBucket(config.getString("wall.block_claimed"));
}
int schematicStartHeight() {
@ -144,19 +140,4 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
return Math.min(WALL_HEIGHT, plotRoadMin);
}
private static BlockBucket createCheckedBlockBucket(String input, BlockBucket def) {
final BlockBucket bucket = new BlockBucket(input);
Pattern pattern = null;
try {
pattern = bucket.toPattern();
} catch (Exception ignore) {
}
if (pattern == null) {
LOGGER.error("Failed to parse pattern '{}', check your worlds.yml", input);
LOGGER.error("Falling back to {}", def);
return def;
}
return bucket;
}
}

View File

@ -457,7 +457,7 @@ public class Plot {
* that could alter the de facto owner of the plot.
*
* @return The plot owner of this particular (sub-)plot
* as stored in the database, if one exists. Else, null.
* as stored in the database, if one exists. Else, null.
*/
public @Nullable UUID getOwnerAbs() {
return this.owner;