Fixed shading issues

This commit is contained in:
Auxilor
2021-01-14 19:24:13 +00:00
parent b0971e5124
commit b74ab5349a
3 changed files with 35 additions and 2 deletions

View File

@@ -1,17 +1,22 @@
package com.willfp.eco.util.recipes.lookup;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.recipes.parts.ComplexRecipePart;
import com.willfp.eco.util.recipes.parts.EmptyRecipePart;
import com.willfp.eco.util.recipes.parts.RecipePart;
import com.willfp.eco.util.recipes.parts.SimpleRecipePart;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.scoreboard.ScoreboardManager;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.function.Function;
import java.util.function.Predicate;
@UtilityClass
public final class RecipePartUtils {
@@ -42,10 +47,33 @@ public final class RecipePartUtils {
* @return The generated recipe part, or null if invalid.
*/
public RecipePart lookup(@NotNull final String key) {
Object recipePartUncast = null;
try {
return (RecipePart) lookupMethod.invoke(instance, key);
recipePartUncast = lookupMethod.invoke(instance, key);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return new EmptyRecipePart();
}
if (recipePartUncast.getClass().toString().contains("EmptyRecipePart")) {
return new EmptyRecipePart();
}
try {
if (recipePartUncast.getClass().toString().contains("SimpleRecipePart")) {
Material material = (Material) recipePartUncast.getClass().getDeclaredMethod("getMaterial").invoke(recipePartUncast);
return new SimpleRecipePart(material);
}
if (recipePartUncast.getClass().toString().contains("ComplexRecipePart")) {
Predicate<ItemStack> predicate = (Predicate<ItemStack>) recipePartUncast.getClass().getDeclaredMethod("getPredicate").invoke(recipePartUncast);
ItemStack displayed = (ItemStack) recipePartUncast.getClass().getDeclaredMethod("getDisplayed").invoke(recipePartUncast);
return new ComplexRecipePart(predicate, displayed);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
return new EmptyRecipePart();

View File

@@ -1,5 +1,6 @@
package com.willfp.eco.util.recipes.parts;
import lombok.Getter;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -10,11 +11,13 @@ public class ComplexRecipePart implements RecipePart {
/**
* The test for itemstacks to pass.
*/
@Getter
private final Predicate<ItemStack> predicate;
/**
* Displayed itemstack: what the user should see.
*/
@Getter
private final ItemStack displayed;
/**

View File

@@ -1,5 +1,6 @@
package com.willfp.eco.util.recipes.parts;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -9,6 +10,7 @@ public class SimpleRecipePart implements RecipePart {
/**
* The material.
*/
@Getter
private final Material material;
/**