Compare commits

...

6 Commits

Author SHA1 Message Date
316dd92667 Release 6.10.1 2022-10-04 19:30:44 +02:00
e53d2ac449 Update the plot sign when a plot has been purchased (#3822) 2022-10-03 21:51:17 +02:00
5786e8cc7a refactor: replace guava's Iterables with Java's stream API (#3823) 2022-10-03 21:51:05 +02:00
1b717c9b10 Only show visible players in /plot near (#3819)
feat: check visibility of player in `/plot near`
2022-10-03 21:50:41 +02:00
35abae99ca Improve feedback for invalid patterns (#3818)
improve feedback for invalid patterns
2022-10-02 22:22:08 +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
7 changed files with 45 additions and 14 deletions

View File

@ -18,7 +18,6 @@
*/ */
package com.plotsquared.bukkit.listener; package com.plotsquared.bukkit.listener;
import com.google.common.collect.Iterables;
import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
@ -39,8 +38,11 @@ public class ForceFieldListener {
private static Set<PlotPlayer<?>> getNearbyPlayers(Player player, Plot plot) { private static Set<PlotPlayer<?>> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer<?>> players = new HashSet<>(); Set<PlotPlayer<?>> players = new HashSet<>();
for (Player nearPlayer : Iterables for (Player nearPlayer : player.getNearbyEntities(5d, 5d, 5d).stream()
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) { .filter(entity -> entity instanceof Player)
.map(entity -> (Player) entity)
.toList()
) {
PlotPlayer<?> plotPlayer; PlotPlayer<?> plotPlayer;
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
.equals(plotPlayer.getCurrentPlot())) { .equals(plotPlayer.getCurrentPlot())) {
@ -54,8 +56,11 @@ public class ForceFieldListener {
} }
private static PlotPlayer<?> hasNearbyPermitted(Player player, Plot plot) { private static PlotPlayer<?> hasNearbyPermitted(Player player, Plot plot) {
for (Player nearPlayer : Iterables for (Player nearPlayer : player.getNearbyEntities(5d, 5d, 5d).stream()
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) { .filter(entity -> entity instanceof Player)
.map(entity -> (Player) entity)
.toList()
) {
PlotPlayer<?> plotPlayer; PlotPlayer<?> plotPlayer;
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
.equals(plotPlayer.getCurrentPlot())) { .equals(plotPlayer.getCurrentPlot())) {

View File

@ -126,6 +126,7 @@ public class Buy extends Command {
plot.removeFlag(event.getFlag()); plot.removeFlag(event.getFlag());
} }
plot.setOwner(player.getUUID()); plot.setOwner(player.getUUID());
plot.getPlotModificationManager().setSign(player.getName());
player.sendMessage( player.sendMessage(
TranslatableCaption.of("working.claimed"), TranslatableCaption.of("working.claimed"),
Template.of("plot", plot.getId().toString()) Template.of("plot", plot.getId().toString())

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

@ -28,13 +28,17 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockTypes; 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 org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
public abstract class ClassicPlotWorld extends SquarePlotWorld { public abstract class ClassicPlotWorld extends SquarePlotWorld {
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + ClassicPlotWorld.class.getSimpleName());
public int ROAD_HEIGHT = 62; public int ROAD_HEIGHT = 62;
public int PLOT_HEIGHT = 62; public int PLOT_HEIGHT = 62;
@ -121,15 +125,15 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
super.loadConfiguration(config); super.loadConfiguration(config);
this.PLOT_BEDROCK = config.getBoolean("plot.bedrock"); this.PLOT_BEDROCK = config.getBoolean("plot.bedrock");
this.PLOT_HEIGHT = Math.min(getMaxGenHeight(), config.getInt("plot.height")); this.PLOT_HEIGHT = Math.min(getMaxGenHeight(), config.getInt("plot.height"));
this.MAIN_BLOCK = new BlockBucket(config.getString("plot.filling")); this.MAIN_BLOCK = createCheckedBlockBucket(config.getString("plot.filling"), MAIN_BLOCK);
this.TOP_BLOCK = new BlockBucket(config.getString("plot.floor")); this.TOP_BLOCK = createCheckedBlockBucket(config.getString("plot.floor"), TOP_BLOCK);
this.WALL_BLOCK = new BlockBucket(config.getString("wall.block")); this.WALL_BLOCK = createCheckedBlockBucket(config.getString("wall.block"), WALL_BLOCK);
this.ROAD_HEIGHT = Math.min(getMaxGenHeight(), config.getInt("road.height")); this.ROAD_HEIGHT = Math.min(getMaxGenHeight(), config.getInt("road.height"));
this.ROAD_BLOCK = new BlockBucket(config.getString("road.block")); this.ROAD_BLOCK = createCheckedBlockBucket(config.getString("road.block"), ROAD_BLOCK);
this.WALL_FILLING = new BlockBucket(config.getString("wall.filling")); this.WALL_FILLING = createCheckedBlockBucket(config.getString("wall.filling"), WALL_FILLING);
this.PLACE_TOP_BLOCK = config.getBoolean("wall.place_top_block"); 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.WALL_HEIGHT = Math.min(getMaxGenHeight() - (PLACE_TOP_BLOCK ? 1 : 0), config.getInt("wall.height"));
this.CLAIMED_WALL_BLOCK = new BlockBucket(config.getString("wall.block_claimed")); this.CLAIMED_WALL_BLOCK = createCheckedBlockBucket(config.getString("wall.block_claimed"), CLAIMED_WALL_BLOCK);
} }
int schematicStartHeight() { int schematicStartHeight() {
@ -140,4 +144,19 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
return Math.min(WALL_HEIGHT, plotRoadMin); 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. * that could alter the de facto owner of the plot.
* *
* @return The plot owner of this particular (sub-)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() { public @Nullable UUID getOwnerAbs() {
return this.owner; return this.owner;

View File

@ -19,7 +19,7 @@ plugins {
} }
group = "com.plotsquared" group = "com.plotsquared"
version = "6.10.1-SNAPSHOT" version = "6.10.1"
subprojects { subprojects {
group = rootProject.group group = rootProject.group