Fixed shading issues
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user