package in.twizmwaz.cardinal.module.modules.mapNotification;

import com.sk89q.minecraft.util.commands.ChatColor;
import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.event.CycleCompleteEvent;
import in.twizmwaz.cardinal.module.TaskedModule;
import in.twizmwaz.cardinal.module.modules.mapInfo.contributor.Contributor;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;

import java.util.List;

public class MapNotification implements TaskedModule {

    private long startTime;

    protected MapNotification() {
    }

    @Override
    public void unload() {
        HandlerList.unregisterAll(this);
    }

    @EventHandler
    public void onCycleComplete(CycleCompleteEvent event) {
        this.startTime = System.currentTimeMillis();
    }

    /**
     * @return The current time stored in the module.
     */

    public double getTimeInSeconds() {
        return ((double) System.currentTimeMillis() - startTime) / 1000.0;
    }

    @Override
    public void run() {
        if (getTimeInSeconds() % 600 == 0 && getTimeInSeconds() != 0) {
            String result = "";
            List<Contributor> authors = GameHandler.getGameHandler().getMatch().getMapInfo().getAuthors();
            for (Contributor author : authors) {
                if (authors.indexOf(author) < authors.size() - 2) {
                    result = result + org.bukkit.ChatColor.RED + author.getName() + org.bukkit.ChatColor.DARK_PURPLE + ", ";
                } else if (authors.indexOf(author) == authors.size() - 2) {
                    result = result + org.bukkit.ChatColor.RED + author.getName() + org.bukkit.ChatColor.DARK_PURPLE + " and ";
                } else if (authors.indexOf(author) == authors.size() - 1) {
                    result = result + org.bukkit.ChatColor.RED + author.getName();
                }
            }
            Bukkit.broadcastMessage(ChatColor.DARK_PURPLE + "Currently playing " + ChatColor.GOLD + GameHandler.getGameHandler().getMatch().getMapInfo().getName() + ChatColor.DARK_PURPLE + " by " + result);
        }
    }
}

@@ -536,16 +536,45 @@
 artTime;
+%0A    private int nextMessage;
 %0A%0A    pr
@@ -824,24 +824,56 @@
 meMillis();%0A
+        this.nextMessage = 600;%0A
     %7D%0A%0A    /
@@ -1132,45 +1132,27 @@
 s() 
-%25 600 == 0 && getTimeInSeconds() != 0
+%3E= this.nextMessage
 ) %7B%0A
@@ -2134,16 +2134,48 @@
 esult);%0A
+            nextMessage += 600;%0A
         

Fix map notifications not actually showing