Merge branch 'v6' into features/v6/queue-features

This commit is contained in:
dordsor21
2020-09-18 12:22:32 +01:00
14 changed files with 152 additions and 14 deletions

View File

@ -28,6 +28,7 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
@ -149,6 +150,11 @@ public class Alias extends SubCommand {
player.sendMessage(TranslatableCaption.of("alias.alias_is_taken"));
return;
}
if (Settings.UUID.OFFLINE) {
plot.setAlias(alias);
player.sendMessage(TranslatableCaption.of("alias.alias_set_to"), Template.of("alias", alias));
return;
}
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(alias, ((uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));

View File

@ -118,6 +118,7 @@ public class HomeCommand extends Command {
PlotQuery query = query(player);
int page = 1; // page = index + 1
String identifier;
PlotArea plotArea;
boolean basePlotOnly = true;
switch (args.length) {
case 1:
@ -143,12 +144,18 @@ public class HomeCommand extends Command {
query.withPlot(fromId);
break;
}
// allow for plot home within a plot area
plotArea = this.plotAreaManager.getPlotAreaByString(args[0]);
if (plotArea != null) {
query.inArea(plotArea);
break;
}
// it wasn't a valid plot id, trying to find plot by alias
query.withAlias(identifier);
break;
case 2:
// we assume args[0] is a plot area and args[1] an identifier
final PlotArea plotArea = this.plotAreaManager.getPlotAreaByString(args[0]);
plotArea = this.plotAreaManager.getPlotAreaByString(args[0]);
identifier = args[1];
if (plotArea == null) {
// invalid command, therefore no plots

View File

@ -168,7 +168,7 @@ public class PlotListener {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
if (owner != null && !owner.getUUID().equals(player.getUUID())) {
if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
player.sendMessage(
TranslatableCaption.of("notification.notify_enter"),
Template.of("player", player.getName()),
@ -355,7 +355,7 @@ public class PlotListener {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
player.sendMessage(
TranslatableCaption.of("notification.notify_leave"),
Template.of("player", player.getName()),

View File

@ -218,4 +218,8 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
return PlotSquared.platform().getConsoleAudience();
}
@Override public boolean canSee(final PlotPlayer<?> other) {
return true;
}
}

View File

@ -859,6 +859,16 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
return this.metaMap.containsKey(key);
}
/**
* Check if the player is able to see the other player.
* This does not mean that the other player is in line of sight of the player,
* but rather that the player is permitted to see the other player.
*
* @param other Other player
* @return {@code true} if the player is able to see the other player, {@code false} if not
*/
public abstract boolean canSee(PlotPlayer<?> other);
public abstract void stopSpectating();
public boolean hasDebugMode() {

View File

@ -50,6 +50,7 @@ public class BlockTypeWrapper {
private static final Map<BlockType, BlockTypeWrapper> blockTypes = new HashMap<>();
private static final Map<String, BlockTypeWrapper> blockCategories = new HashMap<>();
@Nullable private final BlockType blockType;
private static final String minecraftNamespace = "minecraft";
@Nullable private final String blockCategoryId;
@Nullable private BlockCategory blockCategory;
@ -81,7 +82,14 @@ public class BlockTypeWrapper {
}
public static BlockTypeWrapper get(final String blockCategoryId) {
return blockCategories.computeIfAbsent(blockCategoryId, BlockTypeWrapper::new);
// use minecraft as default namespace
String id;
if (blockCategoryId.indexOf(':') == -1) {
id = minecraftNamespace + ":" + blockCategoryId;
} else {
id = blockCategoryId;
}
return blockCategories.computeIfAbsent(id, BlockTypeWrapper::new);
}
@Override public String toString() {