mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-06 08:39:33 +00:00
Merge pull request #173 from Parabot/task/seperated-library-loading
[TASK] Separated library loading
This commit is contained in:
@@ -12,40 +12,49 @@ import java.util.LinkedList;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Initializes the bot environment
|
||||||
*
|
*
|
||||||
* Initiliazes the bot environment
|
* @author Everel, JKetelaar
|
||||||
*
|
|
||||||
* @author Everel
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Environment {
|
public class Environment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a new environment
|
* Loads a new environment
|
||||||
*
|
*
|
||||||
* @param desc
|
* @param desc
|
||||||
*/
|
*/
|
||||||
public static void load(final ServerDescription desc) {
|
public static void load(final ServerDescription desc) {
|
||||||
|
|
||||||
LinkedList<Library> libs = new LinkedList<>();
|
LinkedList<Library> libs = new LinkedList<>();
|
||||||
libs.add(new JavaFX());
|
libs.add(new JavaFX());
|
||||||
|
|
||||||
for(Library lib : libs) {
|
for (Library lib : libs) {
|
||||||
if (lib.requiresJar()) {
|
loadLibrary(lib, true);
|
||||||
if (!lib.hasJar()) {
|
}
|
||||||
Core.verbose("Downloading " + lib.getLibraryName() + "...");
|
|
||||||
VerboseLoader.setState("Downloading " + lib.getLibraryName() + "...");
|
|
||||||
WebUtil.downloadFile(lib.getDownloadLink(), lib.getJarFile(), VerboseLoader.get());
|
|
||||||
Core.verbose("Downloaded " + lib.getLibraryName() + ".");
|
|
||||||
}
|
|
||||||
Core.verbose("Initializing " + lib.getLibraryName());
|
|
||||||
lib.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Core.verbose("Loading server: " + desc.toString() + "...");
|
Core.verbose("Loading server: " + desc.toString() + "...");
|
||||||
|
|
||||||
ServerParser.SERVER_CACHE.get(desc).run();
|
ServerParser.SERVER_CACHE.get(desc).run();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* Loads library into environment
|
||||||
|
*
|
||||||
|
* @param library
|
||||||
|
* @param verboseLoader defines if verboseLoader should be enabled
|
||||||
|
*/
|
||||||
|
public static void loadLibrary(Library library, boolean verboseLoader) {
|
||||||
|
if (library.requiresJar()) {
|
||||||
|
if (!library.hasJar()) {
|
||||||
|
Core.verbose("Downloading " + library.getLibraryName() + "...");
|
||||||
|
if (verboseLoader) {
|
||||||
|
VerboseLoader.setState("Downloading " + library.getLibraryName() + "...");
|
||||||
|
}
|
||||||
|
WebUtil.downloadFile(library.getDownloadLink(), library.getJarFile(), VerboseLoader.get());
|
||||||
|
Core.verbose("Downloaded " + library.getLibraryName() + ".");
|
||||||
|
}
|
||||||
|
Core.verbose("Initializing " + library.getLibraryName());
|
||||||
|
library.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user