41 lines
1.4 KiB
Java
41 lines
1.4 KiB
Java
package eu.mikroskeem.utils.bukkit;
|
|
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.Plugin;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class MessageUtils {
|
|
/**
|
|
* Get new PluginMessage instance to be used in try-resource block
|
|
*
|
|
* @param plugin Plugin that initates plugin message sending
|
|
* @param player Player to send message over
|
|
* @param channel Channel to send message to
|
|
* @return PluginMessage instance
|
|
*/
|
|
public static PluginMessage newPluginMessage(@NotNull Plugin plugin,
|
|
@NotNull Player player,
|
|
@NotNull String channel){
|
|
return new PluginMessage(plugin, player, channel);
|
|
}
|
|
|
|
/**
|
|
* Send plugin message
|
|
*
|
|
* @param plugin Plugin that initates plugin message sending
|
|
* @param player Player to send message over
|
|
* @param channel Channel to send message to
|
|
* @param contents Message contents
|
|
*/
|
|
public static void sendPluginMessage(@NotNull Plugin plugin,
|
|
@NotNull Player player,
|
|
@NotNull String channel,
|
|
@NotNull String[] contents){
|
|
try(PluginMessage message = newPluginMessage(plugin, player, channel)){
|
|
for (String content : contents) {
|
|
message.writeUTF(content);
|
|
}
|
|
}
|
|
}
|
|
}
|