From 2d9dc92f83833b85fd8e28840d1605b2c36d87d0 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 5 Feb 2013 12:30:15 -0500 Subject: [PATCH] Added methods to ChatAPI for retrieving the current chat mode of a player. Fixes #641 --- Changelog.txt | 1 + .../java/com/gmail/nossr50/api/ChatAPI.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 3b84b58f7..22da60add 100644 --- a/Changelog.txt +++ b/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 vanilla XP boost for Fishing - includes permissions, config options, etc + 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 /mmoedit not giving feedback when modifying another players stats = Fixed the guide usage string showing up every time /skillname was called diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java index c20835b01..357ac0008 100644 --- a/src/main/java/com/gmail/nossr50/api/ChatAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -1,9 +1,11 @@ package com.gmail.nossr50.api; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.Users; public final class ChatAPI { private ChatAPI() {} @@ -94,4 +96,44 @@ public final class ChatAPI { public static void sendAdminChat(String sender, String 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(); + } }