package io.github.Cnly.Crafter.Crafter.utils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class CompatUtils
{
    
    private static Method CACHED_GETONLINEPLAYERS = null;
    
    private CompatUtils()
    {
        throw new AssertionError("This is a util class");
    }
    
    @SuppressWarnings("unchecked")
    public static Collection<Player> getOnlinePlayers()
    {
        
        Method m = CACHED_GETONLINEPLAYERS;
        if (null == m)
        {
            try
            {
                m = Bukkit.class.getMethod("getOnlinePlayers");
            }
            catch (NoSuchMethodException | SecurityException e)
            {
                throw new RuntimeException(
                        "Cannot get method Bukkit.getOnlinePlayers()", e);
            }
            CACHED_GETONLINEPLAYERS = m;
        }
        
        Object obj = null;
        try
        {
            obj = m.invoke(null, (Object[])null);
        }
        catch (SecurityException | IllegalAccessException
                | IllegalArgumentException | InvocationTargetException e)
        {
            throw new RuntimeException(
                    "Cannot invoke Bukkit.getOnlinePlayers()", e);
        }
        
        if (obj instanceof Player[])
        {
            return Arrays.asList((Player[])obj);
        }
        else if (obj instanceof Collection)
        {
            return (Collection<Player>)obj;
        }
        else
        {
            throw new RuntimeException(
                    "Unknown getOnlinePlayers() return type!");
        }
        
    }
    
}

@@ -178,16 +178,39 @@
 lection;
+%0Aimport java.util.UUID;
 %0A%0Aimport
@@ -1769,10 +1769,219 @@
  %7D%0A    %0A
+    public static Player getPlayer(UUID uuid)%0A    %7B%0A        for(Player p : CompatUtils.getOnlinePlayers())%0A        %7B%0A            if(p.getUniqueId() == uuid) return p;%0A        %7D%0A        return null;%0A    %7D%0A    %0A
 %7D%0A

Add CompatUtils#getPlayer(UUID)