diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-01-31 13:50:12 -0600 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-02-03 03:32:21 -0500 |
commit | 5e6125e01be2c30f93bb6f8da1eb7cba76bd1ef8 (patch) | |
tree | c04e5c7c4977e5a0ee7681146ae293fdc55ef76b /src/main/java/org | |
parent | 8d2637ee0da3cf8d6d5275d7d5a0c30a922c297f (diff) | |
download | bukkit-5e6125e01be2c30f93bb6f8da1eb7cba76bd1ef8.tar bukkit-5e6125e01be2c30f93bb6f8da1eb7cba76bd1ef8.tar.gz bukkit-5e6125e01be2c30f93bb6f8da1eb7cba76bd1ef8.tar.lz bukkit-5e6125e01be2c30f93bb6f8da1eb7cba76bd1ef8.tar.xz bukkit-5e6125e01be2c30f93bb6f8da1eb7cba76bd1ef8.zip |
[Bleeding] Added Vanish API for hiding players from each other.
Adds Player.hidePlayer, Player.showPlayer, and Player.canSee for managing
what players are hidden from a player. When someone is hidden from a player
the player cannot see them in the user list or /list and they cannot /tell
them so they appear to be completely gone from the server.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/command/defaults/ListCommand.java | 4 | ||||
-rw-r--r-- | src/main/java/org/bukkit/command/defaults/TellCommand.java | 3 | ||||
-rw-r--r-- | src/main/java/org/bukkit/entity/Player.java | 22 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/ListCommand.java b/src/main/java/org/bukkit/command/defaults/ListCommand.java index b7fc3b0a..67f58fa4 100644 --- a/src/main/java/org/bukkit/command/defaults/ListCommand.java +++ b/src/main/java/org/bukkit/command/defaults/ListCommand.java @@ -19,6 +19,10 @@ public class ListCommand extends VanillaCommand { StringBuilder players = new StringBuilder(); for (Player player : Bukkit.getOnlinePlayers()) { + // If a player is hidden from the sender don't show them in the list + if (sender instanceof Player && !((Player) sender).canSee(player)) + continue; + if (players.length() > 0) { players.append(", "); } diff --git a/src/main/java/org/bukkit/command/defaults/TellCommand.java b/src/main/java/org/bukkit/command/defaults/TellCommand.java index 4fce3b1c..4cc31bc8 100644 --- a/src/main/java/org/bukkit/command/defaults/TellCommand.java +++ b/src/main/java/org/bukkit/command/defaults/TellCommand.java @@ -24,7 +24,8 @@ public class TellCommand extends VanillaCommand { Player player = Bukkit.getPlayerExact(args[0]); - if (player == null) { + // If a player is hidden from the sender pretend they are offline + if (player == null || (sender instanceof Player && !((Player) sender).canSee(player))) { sender.sendMessage("There's no player by that name online."); } else { StringBuilder message = new StringBuilder(); diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 21e8204a..1ee3722e 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -490,4 +490,26 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer, Plugi */ public void setAllowFlight(boolean flight); + /** + * Hides a player from this player + * + * @param player Player to hide + */ + public void hidePlayer(Player player); + + /** + * Allows this player to see a player that was previously hidden + * + * @param player Player to show + */ + public void showPlayer(Player player); + + /** + * Checks to see if a player has been hidden from this player + * + * @param player Player to check + * @return True if the provided player is not being hidden from this player + */ + public boolean canSee(Player player); + } |