mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-05 02:41:24 +01:00
Documented extension loading and factories
This commit is contained in:
parent
4f15cf82e0
commit
56ac45820d
@ -6,6 +6,7 @@ import com.willfp.eco.util.extensions.MalformedExtensionException;
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -19,15 +20,26 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Concrete implementation of {@link ExtensionLoader}
|
||||
* Concrete implementation of {@link ExtensionLoader}.
|
||||
*/
|
||||
public class EcoExtensionLoader extends PluginDependent implements ExtensionLoader {
|
||||
/**
|
||||
* All currently loaded extensions.
|
||||
*/
|
||||
private final Set<Extension> extensions = new HashSet<>();
|
||||
|
||||
public EcoExtensionLoader(AbstractEcoPlugin plugin) {
|
||||
/**
|
||||
* Create a new extension loader and link it to a specific {@link AbstractEcoPlugin}.
|
||||
*
|
||||
* @param plugin The plugin to manage
|
||||
*/
|
||||
public EcoExtensionLoader(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all present extensions.
|
||||
*/
|
||||
@Override
|
||||
public void loadExtensions() {
|
||||
File dir = new File(this.getPlugin().getDataFolder(), "/extensions");
|
||||
@ -99,18 +111,29 @@ public class EcoExtensionLoader extends PluginDependent implements ExtensionLoad
|
||||
extensions.add(extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload all existing extensions.
|
||||
*/
|
||||
@Override
|
||||
public void unloadExtensions() {
|
||||
extensions.forEach(Extension::disable);
|
||||
extensions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads, then loads all extensions.
|
||||
*/
|
||||
@Override
|
||||
public void reloadExtensions() {
|
||||
unloadExtensions();
|
||||
loadExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all loaded extensions.
|
||||
*
|
||||
* @return A {@link Set} of all loaded extensions.
|
||||
*/
|
||||
@Override
|
||||
public Set<Extension> getLoadedExtensions() {
|
||||
return extensions;
|
||||
|
@ -5,30 +5,30 @@ import com.willfp.eco.util.extensions.Extension;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Interface for extension loader
|
||||
* Some external plugins may modify extension loading for internal server purposes
|
||||
* Interface for extension loader.
|
||||
* Some external plugins may modify extension loading for internal server purposes.
|
||||
*/
|
||||
public interface ExtensionLoader {
|
||||
|
||||
/**
|
||||
* Load all extensions
|
||||
* Load all extensions.
|
||||
*/
|
||||
void loadExtensions();
|
||||
|
||||
/**
|
||||
* Unload all loaded extensions
|
||||
* Unload all loaded extensions.
|
||||
*/
|
||||
void unloadExtensions();
|
||||
|
||||
/**
|
||||
* Reload all extensions
|
||||
* Reload all extensions.
|
||||
*/
|
||||
void reloadExtensions();
|
||||
|
||||
/**
|
||||
* Retrieve a set of all loaded extensions
|
||||
* Retrieve a set of all loaded extensions.
|
||||
*
|
||||
* @return An {@link Set<Extension>} of all loaded extensions
|
||||
* @return An {@link Set<Extension>} of all loaded extensions.
|
||||
*/
|
||||
Set<Extension> getLoadedExtensions();
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
package com.willfp.eco.util.factory;
|
||||
|
||||
public interface AbstractFactory {
|
||||
}
|
@ -2,9 +2,12 @@ package com.willfp.eco.util.factory;
|
||||
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class PluginDependentFactory extends PluginDependent implements AbstractFactory {
|
||||
protected PluginDependentFactory(AbstractEcoPlugin plugin) {
|
||||
@ApiStatus.Internal
|
||||
public abstract class PluginDependentFactory extends PluginDependent {
|
||||
protected PluginDependentFactory(@NotNull final AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user