2012-04-18 19:18:25 +02:00
|
|
|
package com.gmail.nossr50.api;
|
|
|
|
|
2013-02-05 18:30:15 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2013-01-27 00:19:13 +01:00
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
2013-02-02 06:09:47 +01:00
|
|
|
import com.gmail.nossr50.chat.ChatManager;
|
2013-06-07 00:48:25 +02:00
|
|
|
import com.gmail.nossr50.chat.ChatManagerFactory;
|
|
|
|
import com.gmail.nossr50.chat.ChatMode;
|
|
|
|
import com.gmail.nossr50.chat.PartyChatManager;
|
2013-01-26 00:21:17 +01:00
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2012-04-18 19:18:25 +02:00
|
|
|
|
2012-06-06 22:03:15 +02:00
|
|
|
public final class ChatAPI {
|
|
|
|
private ChatAPI() {}
|
|
|
|
|
2013-02-02 00:59:22 +01:00
|
|
|
/**
|
|
|
|
* Send a message to all members of a party
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param plugin The plugin sending the message
|
|
|
|
* @param sender The name of the sender
|
|
|
|
* @param displayName The display name of the sender
|
|
|
|
* @param party The name of the party to send to
|
|
|
|
* @param message The message to send
|
|
|
|
*/
|
|
|
|
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
2013-06-07 00:48:25 +02:00
|
|
|
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
2013-02-02 00:59:22 +01:00
|
|
|
}
|
|
|
|
|
2012-04-18 19:18:25 +02:00
|
|
|
/**
|
|
|
|
* Send a message to all members of a party
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
2013-01-27 00:19:13 +01:00
|
|
|
* @param plugin The plugin sending the message
|
|
|
|
* @param sender The name of the sender to display in the chat
|
|
|
|
* @param party The name of the party to send to
|
|
|
|
* @param message The message to send
|
|
|
|
*/
|
|
|
|
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
2013-06-07 00:48:25 +02:00
|
|
|
getPartyChatManager(plugin, party).handleChat(sender, message);
|
2013-01-27 00:19:13 +01:00
|
|
|
}
|
|
|
|
|
2013-02-02 00:59:22 +01:00
|
|
|
/**
|
|
|
|
* Send a message to administrators
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param plugin The plugin sending the message
|
|
|
|
* @param sender The name of the sender
|
|
|
|
* @param displayName The display name of the sender
|
|
|
|
* @param message The message to send
|
|
|
|
*/
|
|
|
|
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
2013-06-07 00:48:25 +02:00
|
|
|
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
2012-04-18 19:18:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a message to administrators
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
2013-01-27 00:19:13 +01:00
|
|
|
* @param plugin The plugin sending the message
|
|
|
|
* @param sender The name of the sender to display in the chat
|
|
|
|
* @param message The message to send
|
|
|
|
*/
|
|
|
|
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
2013-06-07 00:48:25 +02:00
|
|
|
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, message);
|
2013-01-27 00:19:13 +01:00
|
|
|
}
|
|
|
|
|
2013-02-05 18:30:15 +01:00
|
|
|
/**
|
|
|
|
* 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) {
|
2013-06-07 00:48:25 +02:00
|
|
|
return UserManager.getPlayer(player).getPartyChatMode();
|
2013-02-05 18:30:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2013-03-01 06:52:01 +01:00
|
|
|
return UserManager.getPlayer(playerName).getPartyChatMode();
|
2013-02-05 18:30:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2013-06-07 00:48:25 +02:00
|
|
|
return UserManager.getPlayer(player).getAdminChatMode();
|
2013-02-05 18:30:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2013-03-01 06:52:01 +01:00
|
|
|
return UserManager.getPlayer(playerName).getAdminChatMode();
|
2013-02-05 18:30:15 +01:00
|
|
|
}
|
2013-03-26 06:55:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the party chat mode of a player.
|
|
|
|
*
|
|
|
|
* @param player The player to toggle party chat on.
|
|
|
|
*/
|
|
|
|
public static void togglePartyChat(Player player) {
|
2013-06-07 00:48:25 +02:00
|
|
|
UserManager.getPlayer(player).togglePartyChat();
|
2013-03-26 06:55:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the party chat mode of a player.
|
|
|
|
*
|
|
|
|
* @param playerName The name of the player to toggle party chat on.
|
|
|
|
*/
|
|
|
|
public static void togglePartyChat(String playerName) {
|
2013-06-07 00:48:25 +02:00
|
|
|
UserManager.getPlayer(playerName).togglePartyChat();
|
2013-03-26 06:55:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the admin chat mode of a player.
|
|
|
|
*
|
|
|
|
* @param player The player to toggle admin chat on.
|
|
|
|
*/
|
|
|
|
public static void toggleAdminChat(Player player) {
|
2013-06-07 00:48:25 +02:00
|
|
|
UserManager.getPlayer(player).toggleAdminChat();
|
2013-03-26 06:55:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the admin chat mode of a player.
|
|
|
|
*
|
|
|
|
* @param playerName The name of the player to toggle party chat on.
|
|
|
|
*/
|
2013-05-18 22:41:42 +02:00
|
|
|
public static void toggleAdminChat(String playerName) {
|
2013-06-07 00:48:25 +02:00
|
|
|
UserManager.getPlayer(playerName).toggleAdminChat();
|
|
|
|
}
|
|
|
|
|
|
|
|
private static ChatManager getPartyChatManager(Plugin plugin, String party) {
|
|
|
|
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
|
|
|
|
((PartyChatManager) chatManager).setParty(PartyManager.getParty(party));
|
|
|
|
|
|
|
|
return chatManager;
|
2013-03-26 06:55:24 +01:00
|
|
|
}
|
2012-04-18 19:18:25 +02:00
|
|
|
}
|