mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-26 23:13:06 +00:00
Update buildscript, apply spotless (#175)
This commit is contained in:
1 parent
08d0ef617f
commit
a40ee7424f
1220 files changed
+95126
-109823
No files matched your search
@@ -18,20 +18,17 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import appeng.api.recipes.IRecipeHandler;
|
||||
import appeng.recipes.CustomRecipeConfig;
|
||||
import appeng.recipes.loader.ConfigLoader;
|
||||
import appeng.recipes.loader.JarLoader;
|
||||
import appeng.recipes.loader.RecipeResourceCopier;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
/**
|
||||
* handles the decision if recipes should be loaded from jar, loaded from file system or force copied from jar
|
||||
@@ -40,75 +37,70 @@ import java.net.URISyntaxException;
|
||||
* @version rv3 - 12.05.2015
|
||||
* @since rv3 12.05.2015
|
||||
*/
|
||||
public class RecipeLoader implements Runnable
|
||||
{
|
||||
/**
|
||||
* recipe path in the jar
|
||||
*/
|
||||
private static final String ASSETS_RECIPE_PATH = "/assets/appliedenergistics2/recipes/";
|
||||
public class RecipeLoader implements Runnable {
|
||||
/**
|
||||
* recipe path in the jar
|
||||
*/
|
||||
private static final String ASSETS_RECIPE_PATH = "/assets/appliedenergistics2/recipes/";
|
||||
|
||||
@Nonnull
|
||||
private final IRecipeHandler handler;
|
||||
@Nonnull
|
||||
private final CustomRecipeConfig config;
|
||||
@Nonnull
|
||||
private final File recipeDirectory;
|
||||
@Nonnull
|
||||
private final IRecipeHandler handler;
|
||||
|
||||
/**
|
||||
* @param config configuration for the knowledge how to handle the loading process
|
||||
* @param handler handler to load the recipes
|
||||
* @throws NullPointerException if handler is <tt>null</tt>
|
||||
*/
|
||||
public RecipeLoader( @Nonnull final File recipeDirectory, @Nonnull final CustomRecipeConfig config, @Nonnull final IRecipeHandler handler )
|
||||
{
|
||||
this.recipeDirectory = Preconditions.checkNotNull( recipeDirectory );
|
||||
Preconditions.checkArgument( !recipeDirectory.isFile() );
|
||||
this.config = Preconditions.checkNotNull( config );
|
||||
this.handler = Preconditions.checkNotNull( handler );
|
||||
}
|
||||
@Nonnull
|
||||
private final CustomRecipeConfig config;
|
||||
|
||||
@Override
|
||||
public final void run()
|
||||
{
|
||||
if( this.config.isEnabled() )
|
||||
{
|
||||
// setup copying
|
||||
final RecipeResourceCopier copier = new RecipeResourceCopier( "assets/appliedenergistics2/recipes/" );
|
||||
@Nonnull
|
||||
private final File recipeDirectory;
|
||||
|
||||
final File generatedRecipesDir = new File( this.recipeDirectory, "generated" );
|
||||
final File userRecipesDir = new File( this.recipeDirectory, "user" );
|
||||
/**
|
||||
* @param config configuration for the knowledge how to handle the loading process
|
||||
* @param handler handler to load the recipes
|
||||
* @throws NullPointerException if handler is <tt>null</tt>
|
||||
*/
|
||||
public RecipeLoader(
|
||||
@Nonnull final File recipeDirectory,
|
||||
@Nonnull final CustomRecipeConfig config,
|
||||
@Nonnull final IRecipeHandler handler) {
|
||||
this.recipeDirectory = Preconditions.checkNotNull(recipeDirectory);
|
||||
Preconditions.checkArgument(!recipeDirectory.isFile());
|
||||
this.config = Preconditions.checkNotNull(config);
|
||||
this.handler = Preconditions.checkNotNull(handler);
|
||||
}
|
||||
|
||||
// generates generated and user recipes dir
|
||||
// will clean the generated every time to keep it up to date
|
||||
// copies over the recipes in the jar over to the generated folder
|
||||
// copies over the readmes
|
||||
try
|
||||
{
|
||||
FileUtils.forceMkdir( generatedRecipesDir );
|
||||
FileUtils.forceMkdir( userRecipesDir );
|
||||
FileUtils.cleanDirectory( generatedRecipesDir );
|
||||
@Override
|
||||
public final void run() {
|
||||
if (this.config.isEnabled()) {
|
||||
// setup copying
|
||||
final RecipeResourceCopier copier = new RecipeResourceCopier("assets/appliedenergistics2/recipes/");
|
||||
|
||||
copier.copyTo( ".recipe", generatedRecipesDir );
|
||||
copier.copyTo( ".html", this.recipeDirectory );
|
||||
final File generatedRecipesDir = new File(this.recipeDirectory, "generated");
|
||||
final File userRecipesDir = new File(this.recipeDirectory, "user");
|
||||
|
||||
// parse recipes prioritising the user scripts by using the generated as template
|
||||
this.handler.parseRecipes( new ConfigLoader( generatedRecipesDir, userRecipesDir ), "index.recipe" );
|
||||
}
|
||||
// on failure use jar parsing
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
this.handler.parseRecipes( new JarLoader( ASSETS_RECIPE_PATH ), "index.recipe" );
|
||||
}
|
||||
catch( final URISyntaxException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
this.handler.parseRecipes( new JarLoader( ASSETS_RECIPE_PATH ), "index.recipe" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handler.parseRecipes( new JarLoader( ASSETS_RECIPE_PATH ), "index.recipe" );
|
||||
}
|
||||
}
|
||||
// generates generated and user recipes dir
|
||||
// will clean the generated every time to keep it up to date
|
||||
// copies over the recipes in the jar over to the generated folder
|
||||
// copies over the readmes
|
||||
try {
|
||||
FileUtils.forceMkdir(generatedRecipesDir);
|
||||
FileUtils.forceMkdir(userRecipesDir);
|
||||
FileUtils.cleanDirectory(generatedRecipesDir);
|
||||
|
||||
copier.copyTo(".recipe", generatedRecipesDir);
|
||||
copier.copyTo(".html", this.recipeDirectory);
|
||||
|
||||
// parse recipes prioritising the user scripts by using the generated as template
|
||||
this.handler.parseRecipes(new ConfigLoader(generatedRecipesDir, userRecipesDir), "index.recipe");
|
||||
}
|
||||
// on failure use jar parsing
|
||||
catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
this.handler.parseRecipes(new JarLoader(ASSETS_RECIPE_PATH), "index.recipe");
|
||||
} catch (final URISyntaxException e) {
|
||||
AELog.debug(e);
|
||||
this.handler.parseRecipes(new JarLoader(ASSETS_RECIPE_PATH), "index.recipe");
|
||||
}
|
||||
} else {
|
||||
this.handler.parseRecipes(new JarLoader(ASSETS_RECIPE_PATH), "index.recipe");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user