Improves console logging
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2024-07-29 18:32:08 +02:00
parent f3372a13a5
commit 0993fbe15f
15 changed files with 81 additions and 74 deletions

View File

@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
/**
* A helper class for deciding the salvage returned if salvaging an item
@ -158,25 +157,25 @@ public final class SalvageHelper {
}
for (Recipe recipe : server.getRecipesFor(new ItemStack(salvagedItem.getType(), salvagedItem.getAmount()))) {
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Considering recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
BlacksmithPlugin.debug("Considering recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
// Only consider crafting table recipes
if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) {
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Recipe had invalid type");
BlacksmithPlugin.debug("Recipe had invalid type");
continue;
}
// Make sure the player has enough items
if (salvagedItem.getAmount() < recipe.getResult().getAmount()) {
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Too few items for recipe");
BlacksmithPlugin.debug("Too few items for recipe");
continue;
}
// Get actual salvage, as long as any can be produced
List<ItemStack> salvage = getRecipeSalvage(recipe, salvagedItem, trashSalvage);
if (salvage != null && !salvage.isEmpty()) {
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Valid recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Actual salvage: " + salvage);
BlacksmithPlugin.debug("Valid recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
BlacksmithPlugin.debug("Actual salvage: " + salvage);
return new RecipeResult(recipe, salvage);
}
}
@ -199,11 +198,11 @@ public final class SalvageHelper {
return null;
}
List<ItemStack> copy = copyItems(ingredients);
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Copied salvage: " + copy);
BlacksmithPlugin.debug("Copied salvage: " + copy);
List<ItemStack> salvage = getSalvage(copy, salvagedItem, trashSalvage);
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Combining salvage: " + salvage);
BlacksmithPlugin.debug("Combining salvage: " + salvage);
List<ItemStack> combined = combineStacks(salvage);
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Combined : " + combined);
BlacksmithPlugin.debug("Combined : " + combined);
return combined;
}
@ -244,10 +243,10 @@ public final class SalvageHelper {
durability = 1;
}
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Durability: " + durability + "/" + maxDurability);
BlacksmithPlugin.debug("Durability: " + durability + "/" + maxDurability);
double percentageRemaining = (double) durability / maxDurability;
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Remaining: " + percentageRemaining);
BlacksmithPlugin.debug("Remaining: " + percentageRemaining);
return pickRandomSalvage(recipeItems, trashSalvage, percentageRemaining);
}
@ -270,7 +269,7 @@ public final class SalvageHelper {
// If not damaged, just give everything
if (percentageRemaining == 1) {
BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "100% Remaining. Copying " + itemsToChooseFrom);
BlacksmithPlugin.debug("100% Remaining. Copying " + itemsToChooseFrom);
return copyItems(itemsToChooseFrom);
}