package me.otisdiver.otisarena.task.kit;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

public class Rollup extends Ability {
    
    private static final Long waitMillis = 10000L;
    private static final String statusMessage = "" + ChatColor.GRAY + ChatColor.BOLD + "Shield activated!";

    @Override
    public void run() {
        if (playerOnCooldown(player)) return;
        startCooldown(player, waitMillis);
        
        // toggle invincibility once, and then again in 3 seconds (20 * 3 = 60 ticks)
        Bukkit.getScheduler().runTask(main, toggleInvincibility());
        Bukkit.getScheduler().runTaskLater(main, toggleInvincibility(), 60);
    }
    
    private Runnable toggleInvincibility() {
        return new Runnable() {
            @Override
            public void run() {
                player.sendMessage(statusMessage);
                player.setInvulnerable(!player.isInvulnerable());
            }
        };
    }

}

@@ -217,22 +217,129 @@
  String 
-status
+enableMessage = %22%22 + ChatColor.GOLD + ChatColor.BOLD + %22Shield enabled!%22;%0A    private static final String disable
 Message 
@@ -391,15 +391,14 @@
 eld 
-activat
+disabl
 ed!%22
@@ -929,33 +929,118 @@
     
-player.sendMessage(status
+boolean toggle = !player.isInvulnerable();%0A                player.sendMessage(toggle ? enableMessage : disable
 Mess
@@ -1088,32 +1088,14 @@
 ble(
-!player.isInvulnerable()
+toggle
 );%0A 

update - different message for shield enable/disable