mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Take player visibility into account when sending notify-enter and notify-leave messages. Fixes PS-103.
This commit is contained in:
@ -160,8 +160,8 @@ public class PlotListener {
|
||||
if (plot.getFlag(NotifyEnterFlag.class)) {
|
||||
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
|
||||
for (UUID uuid : plot.getOwners()) {
|
||||
final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (owner != null && !owner.getUUID().equals(player.getUUID())) {
|
||||
final PlotPlayer<?> owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
|
||||
MainUtil.sendMessage(owner, Captions.NOTIFY_ENTER.getTranslated()
|
||||
.replace("%player", player.getName())
|
||||
.replace("%plot", plot.getId().toString()));
|
||||
@ -336,8 +336,8 @@ public class PlotListener {
|
||||
if (plot.getFlag(NotifyLeaveFlag.class)) {
|
||||
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
|
||||
for (UUID uuid : plot.getOwners()) {
|
||||
final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
|
||||
final PlotPlayer<?> owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||
if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
|
||||
MainUtil.sendMessage(owner, Captions.NOTIFY_LEAVE.getTranslated()
|
||||
.replace("%player", player.getName())
|
||||
.replace("%plot", plot.getId().toString()));
|
||||
|
@ -174,4 +174,8 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean canSee(final PlotPlayer<?> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -727,6 +727,16 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 boolean hasPersistentMeta(String key) {
|
||||
return this.metaMap.containsKey(key);
|
||||
}
|
||||
|
Reference in New Issue
Block a user