package com.yaohun.wheatwar.game;

import com.yaohun.wheatwar.WheatWar;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;

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

public class GameSite {

    // 获取已成熟小麦数量
    public static int getMatureWheatAmount(){
        Game game = WheatWar.getGame();
        World world = game.getWorld();
        List<Location> locationList = game.getWheatList();
        int i = 0;
        for (Location location : locationList){
            Block block = world.getBlockAt(location);
            if (!block.getType().equals(Material.AIR) && block.getType().equals(Material.WHEAT)) {
                BlockData blockData = block.getBlockData();
                if (blockData instanceof Ageable ageable) {
                    if (ageable.getAge() == 7) {
                        i++;
                    }
                }
            }
        }
        return i;
    }

    // 获取哪个坐标没有种小麦

}
