package net.engin33r.luaspigot.lua.lib;

import net.engin33r.luaspigot.lua.Library;
import net.engin33r.luaspigot.lua.annotation.LibFunctionDef;
import net.engin33r.luaspigot.lua.type.LuaPlayer;
import org.bukkit.Bukkit;
import org.luaj.vm2.Varargs;

/**
 * Library for interacting with players on and off the server.
 * Mostly deals with creating {@link LuaPlayer} instances.
 * @see LuaPlayer
 */
@SuppressWarnings("unused")
public class PlayerLibrary extends Library {
    @Override
    public String getName() {
        return "player";
    }

    @LibFunctionDef(name = "getByName")
    public Varargs getByName(Varargs args) {
        return new LuaPlayer(Bukkit.getOfflinePlayer(args.checkjstring(1)));
    }
}

Add WIP player library