From 1af30dad1d60a5e71c5d366fc24c04bd9f7fd82b Mon Sep 17 00:00:00 2001 From: "main()" Date: Fri, 6 Jan 2012 18:00:34 +0100 Subject: [PATCH] Added collection-support for sendMessages in MVMessaging. --- .../MultiverseCore/utils/MVMessaging.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVMessaging.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVMessaging.java index 89e6a009..497e076e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVMessaging.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVMessaging.java @@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.utils; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -76,6 +77,20 @@ public class MVMessaging { return false; } + /** + * Sends a group of messages to the specified sender if the cooldown has passed. + * This method is needed, since sending many messages in quick succession would violate + * the cooldown. + * + * @param sender The person/console to send the message to. + * @param messages The messages to send. + * @param ignoreCooldown If true these messages will always be sent. Useful for things like menus + * @return true if the message was sent, false if not. + */ + public boolean sendMessages(CommandSender sender, Collection messages, boolean ignoreCooldown) { + return this.sendMessages(sender, messages.toArray(new String[0]), ignoreCooldown); + } + private void sendMessages(CommandSender sender, String[] messages) { for (String s : messages) { sender.sendMessage(s);