mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-25 06:14:25 +00:00
format all the things!
This commit is contained in:
1 parent
54ec75fd3d
commit
b36c6dade6
377 files changed
+6833
-6772
No files matched your search
+26
-15
@@ -18,30 +18,30 @@ import minetweaker.runtime.IScriptProvider;
|
||||
*/
|
||||
public class ScriptProviderCascade implements IScriptProvider {
|
||||
private final IScriptProvider[] providers;
|
||||
|
||||
|
||||
public ScriptProviderCascade(IScriptProvider... providers) {
|
||||
this.providers = providers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<IScriptIterator> getScripts() {
|
||||
return new MyScripterator();
|
||||
}
|
||||
|
||||
|
||||
private class MyScripterator implements Iterator<IScriptIterator> {
|
||||
private final Set<String> executed = new HashSet<String>();
|
||||
|
||||
|
||||
private int currentIndex = providers.length - 1;
|
||||
private Iterator<IScriptIterator> current;
|
||||
private IScriptIterator currentValue;
|
||||
|
||||
|
||||
public MyScripterator() {
|
||||
currentIndex = providers.length - 1;
|
||||
current = providers[currentIndex].getScripts();
|
||||
|
||||
|
||||
advance();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return currentIndex >= 0;
|
||||
@@ -51,29 +51,40 @@ public class ScriptProviderCascade implements IScriptProvider {
|
||||
public IScriptIterator next() {
|
||||
IScriptIterator result = currentValue;
|
||||
executed.add(result.getGroupName());
|
||||
|
||||
|
||||
advance();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private void advance() {
|
||||
do {
|
||||
while (!current.hasNext()) {
|
||||
currentIndex--;
|
||||
if (currentIndex < 0) return;
|
||||
|
||||
if (currentIndex < 0)
|
||||
return;
|
||||
|
||||
current = providers[currentIndex].getScripts();
|
||||
}
|
||||
if (currentIndex < 0) break;
|
||||
|
||||
if (currentIndex < 0)
|
||||
break;
|
||||
|
||||
currentValue = current.next();
|
||||
} while (executed.contains(currentValue.getGroupName()) && hasNext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
throw new UnsupportedOperationException("Not supported yet."); // To
|
||||
// change
|
||||
// body
|
||||
// of
|
||||
// generated
|
||||
// methods,
|
||||
// choose
|
||||
// Tools
|
||||
// |
|
||||
// Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user