package net.engin33r.luaspigot;

import net.engin33r.luaspigot.lua.Library;

import java.util.HashMap;
import java.util.Map;

/**
 * Registry for keeping track of Lua libraries available to scripts.
 */
public class LibraryRegistry {
    private final Map<String, Library> nameRegistry = new HashMap<>();

    public void register(Library lib) {
        nameRegistry.put(lib.getName(), lib);
        System.out.println("Successfully added library " + lib.getName() +
                " to registry");
    }

    public Library get(String name) {
        return nameRegistry.get(name);
    }
}

@@ -117,16 +117,74 @@
 til.Map;
+%0Aimport java.util.Set;%0Aimport java.util.stream.Collectors;
 %0A%0A/**%0A *
@@ -640,11 +640,243 @@
 );%0A    %7D
+%0A%0A    public Set%3CLibrary%3E get(Class%3C? extends Library%3E clazz) %7B%0A        return nameRegistry.values().stream()%0A                .filter(lib -%3E clazz.isAssignableFrom(lib.getClass()))%0A                .collect(Collectors.toSet());%0A    %7D
 %0A%7D%0A

Add method for getting libraries by class