mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-27 17:28:28 +01:00
Take player visibility into account when sending notify-enter and notify-leave messages. Fixes PS-103.
This commit is contained in:
parent
5c48e4ad19
commit
0aeca40137
@ -32,6 +32,7 @@ import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotWeather;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
@ -354,6 +355,13 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
return this.player.isBanned();
|
||||
}
|
||||
|
||||
@Override public boolean canSee(final PlotPlayer<?> other) {
|
||||
if (other instanceof ConsolePlayer) {
|
||||
return true;
|
||||
} else {
|
||||
return this.player.canSee(((BukkitPlayer) other).getPlatformPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerTeleportEvent.TeleportCause getTeleportCause(@NotNull final TeleportCause cause) {
|
||||
switch (cause) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user