/*
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *   License, v. 2.0. If a copy of the MPL was not distributed with this
 *   file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package de.myzelyam.supervanish.visibility;

import com.google.common.collect.ImmutableList;

import de.myzelyam.supervanish.SuperVanish;

import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.ArrayList;
import java.util.List;

public class ActionBarMgr {

    private final List<Player> actionBars = new ArrayList<>();

    public ActionBarMgr(SuperVanish plugin) {
        startTimerTask(plugin);
    }

    private void startTimerTask(final SuperVanish plugin) {
        new BukkitRunnable() {

            @Override
            public void run() {
                try {
                    List<Player> actionBars = ImmutableList.copyOf(ActionBarMgr.this.actionBars);
                    for (Player player : actionBars) {
                        plugin.getProtocolLibPacketUtils().sendActionBar(
                                player, plugin.convertString(plugin.getMsg("ActionBarMessage"), player));
                    }
                } catch (Exception e) {
                    plugin.printException(e);
                }
            }
        }.runTaskTimerAsynchronously(plugin, 0, 2 * 20);
    }

    public void addActionBar(Player p) {
        actionBars.add(p);
    }

    public void removeActionBar(Player p) {
        actionBars.remove(p);
    }
}

@@ -347,16 +347,108 @@
 anish;%0A%0A
+import net.md_5.bungee.api.ChatMessageType;%0Aimport net.md_5.bungee.api.chat.TextComponent;%0A%0A
 import o
@@ -1013,16 +1013,17 @@
 nBars);%0A
+%0A
         
@@ -1097,65 +1097,142 @@
     
-plugin.getProtocolLibPacketUtils().sendActionBar(%0A       
+String message = plugin.convertString(plugin.getMsg(%22ActionBarMessage%22), player);%0A                        if (plugin.isOneDotX(12)) %7B%0A
     
@@ -1256,79 +1256,267 @@
     
+   
 player
-, plugin.convertString(plugin.getMsg(%22ActionBarMessage%22), player)
+.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent%0A                                    .fromLegacyText(message));%0A                        %7D else%0A                            plugin.getProtocolLibPacketUtils().sendActionBar(player, message
 );%0A 
@@ -1618,24 +1618,54 @@
 ception(e);%0A
+                    cancel();%0A
             

Fix 1.12 action bars (with the drawback of not having any colours)