mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-21 12:32:29 +00:00
- Added documentation to some classes
- Created script provider system - Did some refactoring to improve the API
This commit is contained in:
1 parent
38b78ce305
commit
97c7f42400
50 files changed
+1311
-318
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.runtime.providers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.runtime.IScriptIterator;
|
||||
import minetweaker.runtime.IScriptProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class ScriptProviderDirectory implements IScriptProvider {
|
||||
private final File directory;
|
||||
|
||||
public ScriptProviderDirectory(File directory) {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IScriptIterator> getScripts() {
|
||||
List<IScriptIterator> scripts = new ArrayList<IScriptIterator>();
|
||||
for (File file : directory.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
scripts.add(new ScriptIteratorDirectory(file));
|
||||
} else if (file.getName().endsWith(".zs")) {
|
||||
scripts.add(new ScriptIteratorSingle(file));
|
||||
} else if (file.getName().endsWith(".zip")) {
|
||||
try {
|
||||
scripts.add(new ScriptIteratorZip(file));
|
||||
} catch (IOException ex) {
|
||||
MineTweakerAPI.logger.logError("Could not load " + file.getName() + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts.iterator();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user