package me.otisdiver.otisarena.task;

import org.bukkit.GameMode;
import org.bukkit.entity.Player;

import me.otisdiver.otisarena.OtisArena;
import me.otisdiver.otisarena.game.Game;
import me.otisdiver.otisarena.game.InventoryBuilder;
import me.otisdiver.otisarena.utils.ConfigUtils;

public class Respawn extends Task {
    
    private final Player player;
    private final Game game;
    
    public Respawn(OtisArena main, Player player) {
        super(main);
        this.game = main.getGame();
        this.player = player;
    }

    @Override
    public void run() {
        
        player.setGameMode(GameMode.SURVIVAL);
        player.teleport(ConfigUtils.getRandomSpawn(game.getActiveWorld()));
        player.setHealth(20.0);
        player.setFoodLevel(20);
        new InventoryBuilder(main, player);
        
    }
    
}

@@ -175,16 +175,62 @@
 e.Game;%0A
+import me.otisdiver.otisarena.game.GameState;%0A
 import m
@@ -274,16 +274,16 @@
 uilder;%0A
-
 import m
@@ -421,16 +421,18 @@
 al Game 
+  
 game;%0A  
@@ -579,17 +579,21 @@
 ;%0A    %7D%0A
+    
 %0A
-
     @Ove
@@ -598,16 +598,16 @@
 verride%0A
-
     publ
@@ -618,24 +618,137 @@
 oid run() %7B%0A
+        // if a game's not underway, stop%0A        if (!GameState.getCurrent().equals(GameState.PLAYING)) return;%0A
         %0A   

fix respawns after game ends