Browse Source

Added methods to ChatAPI for retrieving the current chat mode of a
player. Fixes #641

GJ 12 years ago
parent
commit
2d9dc92f83
2 changed files with 43 additions and 0 deletions
  1. 1 0
      Changelog.txt
  2. 42 0
      src/main/java/com/gmail/nossr50/api/ChatAPI.java

+ 1 - 0
Changelog.txt

@@ -24,6 +24,7 @@ Version 1.4.00-dev
  + Added party XP sharing, when more party members are near the share bonus increases.
  + Added party XP sharing, when more party members are near the share bonus increases.
  + Added vanilla XP boost for Fishing - includes permissions, config options, etc
  + Added vanilla XP boost for Fishing - includes permissions, config options, etc
  + Added particle effect for bleeding
  + Added particle effect for bleeding
+ + Added methods to check if a player is in party or admin chat to the ChatAPI
  = Fixed multiple commands not working properly on offline players
  = Fixed multiple commands not working properly on offline players
  = Fixed /mmoedit not giving feedback when modifying another players stats
  = Fixed /mmoedit not giving feedback when modifying another players stats
  = Fixed the guide usage string showing up every time /skillname was called
  = Fixed the guide usage string showing up every time /skillname was called

+ 42 - 0
src/main/java/com/gmail/nossr50/api/ChatAPI.java

@@ -1,9 +1,11 @@
 package com.gmail.nossr50.api;
 package com.gmail.nossr50.api;
 
 
+import org.bukkit.entity.Player;
 import org.bukkit.plugin.Plugin;
 import org.bukkit.plugin.Plugin;
 
 
 import com.gmail.nossr50.chat.ChatManager;
 import com.gmail.nossr50.chat.ChatManager;
 import com.gmail.nossr50.party.PartyManager;
 import com.gmail.nossr50.party.PartyManager;
+import com.gmail.nossr50.util.Users;
 
 
 public final class ChatAPI {
 public final class ChatAPI {
     private ChatAPI() {}
     private ChatAPI() {}
@@ -94,4 +96,44 @@ public final class ChatAPI {
     public static void sendAdminChat(String sender, String message) {
     public static void sendAdminChat(String sender, String message) {
         sendAdminChat(null, sender, sender, message);
         sendAdminChat(null, sender, sender, message);
     }
     }
+
+    /**
+     * Check if a player is currently talking in party chat.
+     *
+     * @param player The player to check
+     * @return true if the player is using party chat, false otherwise
+     */
+    public static boolean isUsingPartyChat(Player player) {
+        return Users.getPlayer(player).getPartyChatMode();
+    }
+
+    /**
+     * Check if a player is currently talking in party chat.
+     *
+     * @param playerName The name of the player to check
+     * @return true if the player is using party chat, false otherwise
+     */
+    public static boolean isUsingPartyChat(String playerName) {
+        return Users.getPlayer(playerName).getPartyChatMode();
+    }
+
+    /**
+     * Check if a player is currently talking in admin chat.
+     *
+     * @param player The player to check
+     * @return true if the player is using admin chat, false otherwise
+     */
+    public static boolean isUsingAdminChat(Player player) {
+        return Users.getPlayer(player).getAdminChatMode();
+    }
+
+    /**
+     * Check if a player is currently talking in admin chat.
+     *
+     * @param playerName The name of the player to check
+     * @return true if the player is using admin chat, false otherwise
+     */
+    public static boolean isUsingAdminChat(String playerName) {
+        return Users.getPlayer(playerName).getAdminChatMode();
+    }
 }
 }