Search in sources :

Example 1 with MinigamesBroadcastEvent

use of au.com.mineauz.minigames.events.MinigamesBroadcastEvent in project Minigames by AddstarMC.

the class MinigameUtils method broadcast.

/**
	 * Broadcasts a server message without a permission.
	 * @param message - The message to be broadcasted (Can be manipulated with MinigamesBroadcastEvent)
	 * @param minigame - The Minigame this broadcast is related to.
	 * @param prefixColor - The color to be used in the prefix.
	 */
public static void broadcast(String message, Minigame minigame, ChatColor prefixColor) {
    MinigamesBroadcastEvent ev = new MinigamesBroadcastEvent(prefixColor + "[Minigames]" + ChatColor.WHITE, message, minigame);
    Bukkit.getPluginManager().callEvent(ev);
    Bukkit.getServer().broadcastMessage(ev.getMessageWithPrefix());
}
Also used : MinigamesBroadcastEvent(au.com.mineauz.minigames.events.MinigamesBroadcastEvent)

Example 2 with MinigamesBroadcastEvent

use of au.com.mineauz.minigames.events.MinigamesBroadcastEvent in project Minigames by AddstarMC.

the class MessageManager method broadcast.

/**
 * Broadcasts a message with a defined permission.
 *
 * @param message    - The message to be broadcast (Can be manipulated with MinigamesBroadcastEvent)
 * @param minigame   - The Minigame this broadcast is related to.
 * @param permission - The permission required to see this broadcast message.
 */
public static void broadcast(String message, Minigame minigame, String permission) {
    MinigamesBroadcastEvent ev = new MinigamesBroadcastEvent(org.bukkit.ChatColor.AQUA + "[Minigames]" + org.bukkit.ChatColor.WHITE, message, minigame);
    Bukkit.getPluginManager().callEvent(ev);
    // Only send broadcast if event was not cancelled and is not empty
    if (!ev.isCancelled() && !ev.getMessage().isEmpty())
        Bukkit.getServer().broadcast(ev.getMessageWithPrefix(), permission);
}
Also used : MinigamesBroadcastEvent(au.com.mineauz.minigames.events.MinigamesBroadcastEvent)

Example 3 with MinigamesBroadcastEvent

use of au.com.mineauz.minigames.events.MinigamesBroadcastEvent in project Minigames by AddstarMC.

the class MinigameUtils method broadcast.

/**
	 * Broadcasts a message with a defined permission.
	 * @param message - The message to be broadcasted (Can be manipulated with MinigamesBroadcastEvent)
	 * @param minigame - The Minigame this broadcast is related to.
	 * @param permission - The permission required to see this broadcast message.
	 */
public static void broadcast(String message, Minigame minigame, String permission) {
    MinigamesBroadcastEvent ev = new MinigamesBroadcastEvent(ChatColor.AQUA + "[Minigames]" + ChatColor.WHITE, message, minigame);
    Bukkit.getPluginManager().callEvent(ev);
    Bukkit.getServer().broadcast(ev.getMessageWithPrefix(), permission);
}
Also used : MinigamesBroadcastEvent(au.com.mineauz.minigames.events.MinigamesBroadcastEvent)

Example 4 with MinigamesBroadcastEvent

use of au.com.mineauz.minigames.events.MinigamesBroadcastEvent in project Minigames by AddstarMC.

the class MessageManager method broadcast.

/**
 * Broadcasts a server message without a permission.
 *
 * @param message     - The message to be broadcasted (Can be manipulated with MinigamesBroadcastEvent)
 * @param minigame    - The Minigame this broadcast is related to.
 * @param prefixColor - The color to be used in the prefix.
 */
public static void broadcast(String message, Minigame minigame, org.bukkit.ChatColor prefixColor) {
    BaseComponent init = new TextComponent("[Minigames]");
    init.setColor(prefixColor.asBungee());
    TextComponent m = new TextComponent(" " + message);
    MinigamesBroadcastEvent ev = new MinigamesBroadcastEvent(prefixColor + "[Minigames]" + org.bukkit.ChatColor.WHITE, message, minigame);
    Bukkit.getPluginManager().callEvent(ev);
    // Only send broadcast if event was not cancelled and is not empty
    if (!ev.isCancelled() && !ev.getMessage().isEmpty()) {
        if (PaperLib.isPaper()) {
            Bukkit.getServer().broadcast(init, m);
        } else {
            Bukkit.getServer().spigot().broadcast(init, m);
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) MinigamesBroadcastEvent(au.com.mineauz.minigames.events.MinigamesBroadcastEvent)

Aggregations

MinigamesBroadcastEvent (au.com.mineauz.minigames.events.MinigamesBroadcastEvent)4 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1