generify BootstrapBaseAddon

This commit is contained in:
dfsek
2021-11-17 08:22:06 -07:00
parent e211b27a80
commit 4f4dc45a48
10 changed files with 56 additions and 45 deletions

View File

@@ -5,12 +5,12 @@ import com.dfsek.terra.api.addon.BaseAddon;
import java.nio.file.Path;
public interface BootstrapBaseAddon extends BaseAddon {
public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
/**
* Load all the relevant addons in the specified path.
* @param addonsFolder Path containing addons.
* @param parent
* @return Loaded addons
*/
Iterable<BaseAddon> loadAddons(Path addonsFolder, ClassLoader parent);
Iterable<T> loadAddons(Path addonsFolder, ClassLoader parent);
}

View File

@@ -2,6 +2,7 @@ dependencies {
"shadedApi"(project(":common:api:util"))
"shadedApi"(project(":common:api:noise"))
"shadedApi"(project(":common:api:registry"))
"shadedApi"(project(":common:api:addons"))
"shadedApi"("com.dfsek:Paralithic:0.5.0")

View File

@@ -2,6 +2,7 @@ package com.dfsek.terra.api;
import java.io.File;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.PluginConfig;
@@ -47,7 +48,7 @@ public interface Platform extends LoaderRegistrar {
CheckedRegistry<ConfigPack> getConfigRegistry();
Registry<TerraAddon> getAddons();
Registry<BaseAddon> getAddons();
ItemHandle getItemHandle();

View File

@@ -11,7 +11,7 @@ import com.dfsek.terra.api.addon.annotations.Version;
/**
* Represents an entry point for an com.dfsek.terra.addon. Implementations must be annotated with {@link Addon}.
*/
public abstract class TerraAddon {
public abstract class TerraAddon implements BaseAddon {
/**
* Invoked immediately after an com.dfsek.terra.addon is loaded.
*/
@@ -50,4 +50,9 @@ public abstract class TerraAddon {
// .dfsek.terra.addon loader.
return addon.value();
}
@Override
public String getID() {
return getName();
}
}

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.api.event.functional;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.event.EventHandler;
import com.dfsek.terra.api.event.events.Event;
@@ -7,7 +8,7 @@ import com.dfsek.terra.api.util.reflection.TypeKey;
public interface FunctionalEventHandler extends EventHandler {
<T extends Event> EventContext<T> register(TerraAddon addon, Class<T> clazz);
<T extends Event> EventContext<T> register(BaseAddon addon, Class<T> clazz);
<T extends Event> EventContext<T> register(TerraAddon addon, TypeKey<T> clazz);
<T extends Event> EventContext<T> register(BaseAddon addon, TypeKey<T> clazz);
}