/** * Are popops enabled * * @return if popupmanager is loaded */ public boolean popupsAreEnabled(MsgCategory category) { if (messages.getBoolean(MessageNode.SB_MSG_ENABLE)) switch (category.getSubcategory() != null ? category.getSubcategory() : category) // Some messages might inherit from another MsgCategory { case TUTORIAL: return messages.getBoolean(MessageNode.SB_MSG_TUTORIAL); case NOTIFICATION: return messages.getBoolean(MessageNode.SB_MSG_NOTIFICATION); case BROADCAST: return messages.getBoolean(MessageNode.SB_MSG_BROADCAST); default: return false; } return false; }
/** * Send a short message using SbPopupAPI * * @param player player to send the message to * @param category type defines the length color for consistency * @param message text already seperated into lines * @param stripColors if colors should be removed from the message */ public void sendPopup( Player player, MsgCategory category, List<String> message, boolean stripColors) { if (popupsAreEnabled(category)) { int length; ChatColor titleColor; ChatColor textColor; String titleText = messages.getString(MessageNode.SB_MSG_TITLE); if (stripColors) for (int i = 0; i < message.size(); i++) message.set(i, ChatColor.stripColor(message.get(i))); switch (category) { case BROADCAST: length = messages.getInt(MessageNode.SB_MSG_BROADCAST_LEN); titleColor = null; textColor = messages.getColor(MessageNode.SB_MSG_BROADCAST_TEXT_CLR); break; case ONE_TIME: case NOTIFICATION: length = messages.getInt(MessageNode.SB_MSG_NOTIFICATION_LEN); titleColor = null; textColor = messages.getColor(MessageNode.SB_MSG_NOTIFICATION_TEXT_CLR); break; case TUTORIAL: length = messages.getInt(MessageNode.SB_MSG_TUTORIAL_LEN); titleColor = null; textColor = messages.getColor(MessageNode.SB_MSG_TUTORIAL_TEXT_CLR); break; case DISABLED: default: length = 0; titleColor = null; textColor = null; } manager.showPopup( player.getName(), category.getUniqueIdentifier(), length, titleColor, textColor, titleText, message); } }