Vanished players are treated as if they are offline for inspect command

Fixed #4444
This commit is contained in:
nossr50 2021-03-05 14:48:05 -08:00
parent 72264205d0
commit b59d1afdb4
4 changed files with 48 additions and 7 deletions

View File

@ -1,6 +1,11 @@
Version 2.1.177 Version 2.1.177
Environmentally aware will now protect Wolves from Magma blocks Environmentally aware will now protect Wolves from Magma blocks
Fixed a bug where mcMMO would fail to update a players name when it detected a name change Fixed a bug where mcMMO would fail to update a players name when it detected a name change
mcMMO will treat vanished players as if they are offline when using the inspect command on them now (see notes)
NOTES:
A few changes were made to the inspect command, it used to reject you when used on vanished players, now it will be processed as if they are offline.
Additionally if you do inspect a vanished player, it will not use their display name (consistent with offline players) as that would give them away for being online
Version 2.1.176 Version 2.1.176
Another fix for Double Smelt bringing item stack size to illegal values Another fix for Double Smelt bringing item stack size to illegal values

View File

@ -36,7 +36,9 @@ public class InspectCommand implements TabExecutor {
return true; return true;
} }
if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (Config.getInstance().getScoreboardsEnabled()
&& sender instanceof Player
&& Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) { if (!Config.getInstance().getInspectUseChat()) {
@ -63,16 +65,21 @@ public class InspectCommand implements TabExecutor {
} else { } else {
Player target = mcMMOPlayer.getPlayer(); Player target = mcMMOPlayer.getPlayer();
boolean isVanished = false;
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); isVanished = true;
return true; }
} else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
//Only distance check players who are online and not vanished
if (!isVanished && CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true; return true;
} }
if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (Config.getInstance().getScoreboardsEnabled()
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); && sender instanceof Player
&& Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer);
if (!Config.getInstance().getInspectUseChat()) { if (!Config.getInstance().getInspectUseChat()) {
return true; return true;

View File

@ -21,6 +21,7 @@ import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
@ -327,7 +328,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, Config.getInstance().getStatsScoreboardTime()); changeScoreboard(wrapper, Config.getInstance().getStatsScoreboardTime());
} }
public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) { public static void enablePlayerInspectScoreboard(@NotNull Player player, @NotNull PlayerProfile targetProfile) {
ScoreboardWrapper wrapper = getWrapper(player); ScoreboardWrapper wrapper = getWrapper(player);
if(wrapper == null) { if(wrapper == null) {
@ -343,6 +344,22 @@ public class ScoreboardManager {
} }
} }
public static void enablePlayerInspectScoreboard(@NotNull Player player, @NotNull McMMOPlayer targetMcMMOPlayer) {
ScoreboardWrapper wrapper = getWrapper(player);
if(wrapper == null) {
setupPlayer(player);
wrapper = getWrapper(player);
}
if(wrapper != null) {
wrapper.setOldScoreboard();
wrapper.setTypeInspectStats(targetMcMMOPlayer);
changeScoreboard(wrapper, Config.getInstance().getInspectScoreboardTime());
}
}
public static void enablePlayerCooldownScoreboard(Player player) { public static void enablePlayerCooldownScoreboard(Player player) {
ScoreboardWrapper wrapper = getWrapper(player); ScoreboardWrapper wrapper = getWrapper(player);

View File

@ -25,6 +25,7 @@ import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -322,6 +323,17 @@ public class ScoreboardWrapper {
loadObjective(LocaleLoader.getString("Scoreboard.Header.PlayerInspect", targetPlayer)); loadObjective(LocaleLoader.getString("Scoreboard.Header.PlayerInspect", targetPlayer));
} }
public void setTypeInspectStats(@NotNull McMMOPlayer mcMMOPlayer) {
this.sidebarType = SidebarType.STATS_BOARD;
targetPlayer = mcMMOPlayer.getPlayer().getName();
targetProfile = mcMMOPlayer.getProfile();
targetSkill = null;
leaderboardPage = -1;
loadObjective(LocaleLoader.getString("Scoreboard.Header.PlayerInspect", targetPlayer));
}
public void setTypeCooldowns() { public void setTypeCooldowns() {
this.sidebarType = SidebarType.COOLDOWNS_BOARD; this.sidebarType = SidebarType.COOLDOWNS_BOARD;