mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 21:26:17 +01:00
Add ClassSource.attemptLoadFrom method
This method is an alternative to chaining retry calls
This commit is contained in:
parent
324e6de284
commit
e0449b2db6
@ -58,6 +58,19 @@ public abstract class ClassSource {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a class source that will attempt lookups in each of the given sources in the order they are in the array, and return the first value that is found.
|
||||
* @param sources - the class sources.
|
||||
* @return A new class source.
|
||||
*/
|
||||
public static ClassSource attemptLoadFrom(final ClassSource... sources) {
|
||||
ClassSource source = sources[0];
|
||||
for(int i = 1; i < sources.length; i++){
|
||||
source = source.retry(sources[i]);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a class source that will retry failed lookups in the given source.
|
||||
* @param other - the other class source.
|
||||
|
Loading…
Reference in New Issue
Block a user