mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-21 03:33:23 +00:00
Registry fixes
This commit is contained in:
parent
2bb1f27e07
commit
3c4599423d
@ -62,4 +62,20 @@ public class PluginRegistry<T> {
|
||||
{
|
||||
registry.remove(s);
|
||||
}
|
||||
|
||||
public T resolve(String id) {
|
||||
if(registry.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Supplier<T> m = registry.get(id);
|
||||
|
||||
if(m == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return m.get();
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,29 @@
|
||||
|
||||
package com.volmit.iris.util.plugin;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class PluginRegistryGroup<T> {
|
||||
private final KMap<String, PluginRegistry<T>> registries = new KMap<>();
|
||||
|
||||
public T resolve(String namespace, String id)
|
||||
{
|
||||
if(registries.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
PluginRegistry<T> r = registries.get(namespace);
|
||||
if(r == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return r.resolve(id);
|
||||
}
|
||||
|
||||
public void clearRegistries()
|
||||
{
|
||||
registries.clear();
|
||||
@ -37,4 +55,12 @@ public class PluginRegistryGroup<T> {
|
||||
{
|
||||
return registries.computeIfAbsent(namespace, PluginRegistry::new);
|
||||
}
|
||||
|
||||
public KList<String> compile() {
|
||||
KList<String> l = new KList<>();
|
||||
registries.values().forEach((i)
|
||||
-> i.getRegistries().forEach((j)
|
||||
-> l.add(i.getNamespace() + ":" + j)));
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user