mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-22 13:10:01 +00:00
Remove: all vanilla editions
This commit is contained in:
1 parent
c2dad72690
commit
755f7647ed
136 files changed
+113
-1355
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package customskinloader.plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.loader.ProfileLoader;
|
||||
|
||||
public interface ICustomSkinLoaderPlugin {
|
||||
/**
|
||||
* @return return a non-null value if need to add a new profile loader, otherwise return null.
|
||||
*/
|
||||
ProfileLoader.IProfileLoader getProfileLoader();
|
||||
|
||||
/**
|
||||
* @return the default implementations which import by {@link ICustomSkinLoaderPlugin#getProfileLoader()}.
|
||||
*/
|
||||
List<IDefaultProfile> getDefaultProfiles();
|
||||
|
||||
interface IDefaultProfile {
|
||||
/**
|
||||
* @return the name of {@link SkinSiteProfile#name}.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return the lower the number, the first to load.
|
||||
*/
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* Complete the {@link SkinSiteProfile} from config and write to config.
|
||||
*/
|
||||
void updateSkinSiteProfile(SkinSiteProfile ssp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package customskinloader.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.loader.LegacyLoader;
|
||||
import customskinloader.loader.MojangAPILoader;
|
||||
import customskinloader.loader.jsonapi.*;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
public class PluginLoader {
|
||||
public static final ICustomSkinLoaderPlugin[] DEFAULT_PLUGINS = new ICustomSkinLoaderPlugin[]{
|
||||
new MojangAPILoader(),
|
||||
new LegacyLoader(),
|
||||
new JsonAPILoader(new CustomSkinAPI()),
|
||||
new JsonAPILoader(new CustomSkinAPIPlus()),
|
||||
new JsonAPILoader(new UniSkinAPI()),
|
||||
new JsonAPILoader(new ElyByAPI()),
|
||||
new JsonAPILoader(new GlitchlessAPI()),
|
||||
new JsonAPILoader(new MinecraftCapesAPI()),
|
||||
new JsonAPILoader(new WynntilsAPI()),
|
||||
};
|
||||
public static final ArrayList<ICustomSkinLoaderPlugin> PLUGINS = loadPlugins();
|
||||
|
||||
private static ArrayList<ICustomSkinLoaderPlugin> loadPlugins() {
|
||||
File pluginsDir = new File(CustomSkinLoader.DATA_DIR, "Plugins");
|
||||
ArrayList<URL> urls = new ArrayList<>();
|
||||
if (!pluginsDir.isDirectory()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
pluginsDir.mkdirs();
|
||||
} else {
|
||||
for (File plugin : FileUtils.listFiles(pluginsDir, new String[]{"jar", "zip"}, false)) {
|
||||
try {
|
||||
urls.add(plugin.toURI().toURL());
|
||||
CustomSkinLoader.logger.info("Found a jar or zip file: " + plugin.getName());
|
||||
} catch (MalformedURLException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<ICustomSkinLoaderPlugin> plugins = Lists.newArrayList(DEFAULT_PLUGINS);
|
||||
|
||||
ServiceLoader<ICustomSkinLoaderPlugin> sl = ServiceLoader.load(ICustomSkinLoaderPlugin.class, new URLClassLoader(urls.toArray(new URL[0]), PluginLoader.class.getClassLoader()));
|
||||
for (ICustomSkinLoaderPlugin plugin : sl) {
|
||||
plugins.add(plugin);
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user