Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe Support #7150

Open
wants to merge 61 commits into
base: dev/feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2b18331
Starter Commit
TheAbsolutionism Oct 8, 2024
5301401
Shapeless Addition
TheAbsolutionism Oct 9, 2024
5aaf2a6
Testing Stuff
TheAbsolutionism Oct 9, 2024
bd2c23f
Testing Fix
TheAbsolutionism Oct 9, 2024
50bb139
More additions
TheAbsolutionism Oct 10, 2024
29bc2e8
Additional Updates + Changes
TheAbsolutionism Oct 11, 2024
d73bad2
Further Additions
TheAbsolutionism Oct 12, 2024
23d4dc0
Fuse Changes
TheAbsolutionism Oct 12, 2024
fbefde4
Tests (Stopping Point)
TheAbsolutionism Oct 12, 2024
a687e0f
Some Fixes
TheAbsolutionism Oct 13, 2024
1f79ed6
Additional Changes + Fixes
TheAbsolutionism Oct 15, 2024
5c3a8c0
Fuzes Wishlist
TheAbsolutionism Oct 15, 2024
78c5411
Almost Done
TheAbsolutionism Oct 16, 2024
ebc9428
Fix Imports
TheAbsolutionism Oct 16, 2024
793c3ee
One more fix
TheAbsolutionism Oct 16, 2024
9a628ea
Fix Test
TheAbsolutionism Oct 16, 2024
9307a02
Merge remote-tracking branch 'upstream/dev/feature' into dev/Recipes
TheAbsolutionism Oct 16, 2024
ed8f1db
Change RecipeType class register
TheAbsolutionism Oct 16, 2024
1cc3c24
Module + Changes
TheAbsolutionism Oct 16, 2024
48a6c1f
Fuse's Changes
TheAbsolutionism Oct 16, 2024
db3e501
Partial Changes
TheAbsolutionism Oct 17, 2024
2d611e0
More Partial Changes
TheAbsolutionism Oct 19, 2024
3c37524
RecipeWrapper
TheAbsolutionism Oct 31, 2024
250c69f
Merge remote-tracking branch 'upstream/dev/feature' into dev/Recipes
TheAbsolutionism Oct 31, 2024
3bd9c4a
Additional Changes
TheAbsolutionism Nov 1, 2024
06d8346
Remove "runtime"
TheAbsolutionism Nov 5, 2024
4b8ba57
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Nov 6, 2024
530ac32
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Nov 8, 2024
0b712cc
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Nov 11, 2024
76716cb
Merge branch 'dev/feature' into dev/Recipes
Efnilite Nov 12, 2024
1087525
Requested Changes
TheAbsolutionism Nov 13, 2024
e801263
Additional Changes
TheAbsolutionism Nov 13, 2024
ab7edc5
Fix Errors
TheAbsolutionism Nov 13, 2024
99250ad
Fix Docs
TheAbsolutionism Nov 13, 2024
e2193ea
Requested Changes
TheAbsolutionism Nov 16, 2024
2eea7a6
More Changes
TheAbsolutionism Nov 16, 2024
6268513
Whoops
TheAbsolutionism Nov 16, 2024
149b842
Partial Changes
TheAbsolutionism Nov 17, 2024
14972f3
Merge remote-tracking branch 'upstream/dev/feature' into dev/Recipes
TheAbsolutionism Nov 23, 2024
0e5e1e4
Secspressions!
TheAbsolutionism Nov 23, 2024
cb52649
Remove Duplicated Module
TheAbsolutionism Nov 24, 2024
f6bdb2f
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Dec 9, 2024
04ba9fc
Changes + Additions
TheAbsolutionism Dec 9, 2024
9f97e4f
Fix Cond
TheAbsolutionism Dec 9, 2024
64834b0
Merge branch 'dev/Recipes' of https://github.com/TheAbsolutionism/Skr…
TheAbsolutionism Dec 9, 2024
b4e809c
Check Lambda
TheAbsolutionism Dec 9, 2024
449148b
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Dec 15, 2024
3788025
Partial Changes
TheAbsolutionism Dec 16, 2024
56ea7a4
Fix Tests
TheAbsolutionism Dec 16, 2024
f4d0e77
Additional Changes
TheAbsolutionism Dec 17, 2024
b36656c
Merge remote-tracking branch 'upstream/dev/feature' into dev/Recipes
TheAbsolutionism Dec 19, 2024
b143f26
Update EventValues
TheAbsolutionism Dec 19, 2024
ea18385
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Dec 20, 2024
1679f2d
Fix Comparator Issue
TheAbsolutionism Dec 20, 2024
bbc007a
Remove NamespacedUtils
TheAbsolutionism Dec 20, 2024
e1c2fac
Requested Changes
TheAbsolutionism Dec 20, 2024
a30c03b
Lowercase
TheAbsolutionism Dec 21, 2024
b179275
Merge remote-tracking branch 'upstream/dev/feature' into dev/Recipes
TheAbsolutionism Dec 24, 2024
a7175fe
Merge branch 'dev/feature' into dev/Recipes
TheAbsolutionism Dec 24, 2024
22b0ea0
SPE Update
TheAbsolutionism Dec 25, 2024
40a04f9
Changes
TheAbsolutionism Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 8 additions & 49 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,19 @@
import ch.njol.skript.aliases.Aliases;
import ch.njol.skript.bukkitutil.BurgerHelper;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.classes.data.BukkitClasses;
import ch.njol.skript.classes.data.BukkitEventValues;
import ch.njol.skript.classes.data.DefaultComparators;
import ch.njol.skript.classes.data.DefaultConverters;
import ch.njol.skript.classes.data.DefaultFunctions;
import ch.njol.skript.classes.data.DefaultOperations;
import ch.njol.skript.classes.data.JavaClasses;
import ch.njol.skript.classes.data.SkriptClasses;
import ch.njol.skript.classes.data.*;
import ch.njol.skript.command.Commands;
import ch.njol.skript.doc.Documentation;
import ch.njol.skript.events.EvtSkript;
import ch.njol.skript.hooks.Hook;
import ch.njol.skript.lang.Condition;
import ch.njol.skript.lang.Condition.ConditionType;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionInfo;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.Section;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptEventInfo;
import ch.njol.skript.lang.Statement;
import ch.njol.skript.lang.SyntaxElementInfo;
import ch.njol.skript.lang.Trigger;
import ch.njol.skript.lang.TriggerItem;
import ch.njol.skript.lang.Condition.ConditionType;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.localization.ArgsMessage;
import ch.njol.skript.localization.Language;
import ch.njol.skript.localization.Message;
import ch.njol.skript.localization.PluralizingArgsMessage;
import ch.njol.skript.log.BukkitLoggerFilter;
import ch.njol.skript.log.CountingLogHandler;
import ch.njol.skript.log.ErrorDescLogHandler;
import ch.njol.skript.log.ErrorQuality;
import ch.njol.skript.log.LogEntry;
import ch.njol.skript.log.LogHandler;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.skript.log.Verbosity;
import ch.njol.skript.log.*;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.registrations.Feature;
Expand All @@ -50,13 +25,7 @@
import ch.njol.skript.update.ReleaseStatus;
import ch.njol.skript.update.UpdateManifest;
import ch.njol.skript.util.Date;
import ch.njol.skript.util.EmptyStacktraceException;
import ch.njol.skript.util.ExceptionUtils;
import ch.njol.skript.util.FileUtils;
import ch.njol.skript.util.Getter;
import ch.njol.skript.util.Task;
import ch.njol.skript.util.Utils;
import ch.njol.skript.util.Version;
import ch.njol.skript.util.*;
import ch.njol.skript.util.chat.BungeeConverter;
import ch.njol.skript.util.chat.ChatMessages;
import ch.njol.skript.variables.Variables;
Expand All @@ -66,12 +35,9 @@
import ch.njol.util.StringUtils;
import ch.njol.util.coll.iterator.CheckedIterator;
import ch.njol.util.coll.iterator.EnumerationIterable;

import com.google.common.collect.Lists;
import com.google.gson.Gson;

import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
Expand Down Expand Up @@ -100,6 +66,7 @@
import org.skriptlang.skript.bukkit.fishing.FishingModule;
import org.skriptlang.skript.bukkit.input.InputModule;
import org.skriptlang.skript.bukkit.loottables.LootTableModule;
import org.skriptlang.skript.bukkit.recipes.RecipeModule;
import org.skriptlang.skript.lang.comparator.Comparator;
import org.skriptlang.skript.lang.comparator.Comparators;
import org.skriptlang.skript.lang.converter.Converter;
Expand All @@ -123,17 +90,8 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -553,6 +511,7 @@ public void onEnable() {
InputModule.load();
FurnaceModule.load();
LootTableModule.load();
RecipeModule.load();
} catch (final Exception e) {
exception(e, "Could not load required .class files: " + e.getLocalizedMessage());
setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ public Player get(final PrepareItemCraftEvent e) {
return null;
}
}, 0);

// CraftEvents - recipe namespaced key strings
EventValues.registerEventValue(CraftItemEvent.class, String.class, new Getter<String, CraftItemEvent>() {
@Nullable
Expand Down Expand Up @@ -1238,6 +1239,7 @@ public ItemStack get(CraftItemEvent e) {
return e.getRecipe().getResult();
}
}, 0);

//InventoryOpenEvent
EventValues.registerEventValue(InventoryOpenEvent.class, Player.class, new Getter<Player, InventoryOpenEvent>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package org.skriptlang.skript.bukkit.recipes;

import org.bukkit.NamespacedKey;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableTransmuteRecipe;
import org.skriptlang.skript.bukkit.recipes.RecipeUtils.RecipeType;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableCookingRecipe.MutableBlastingRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableCookingRecipe.MutableCampfireRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableCookingRecipe.MutableFurnaceRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableCookingRecipe.MutableSmokingRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableCraftingRecipe.MutableShapedRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableCraftingRecipe.MutableShapelessRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableSmithingRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableSmithingRecipe.MutableSmithingTransformRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableSmithingRecipe.MutableSmithingTrimRecipe;
import org.skriptlang.skript.bukkit.recipes.MutableRecipe.MutableStonecuttingRecipe;

/**
* Event class used with ExprSecCreateRecipe to allow the creation of MutableRecipe
*/
public class CreateRecipeEvent extends Event {
private boolean errorInSection = false;
private RecipeType recipeType;
private MutableRecipe mutableRecipe;

public CreateRecipeEvent(NamespacedKey key, RecipeType recipeType) {
this.recipeType = recipeType;
this.mutableRecipe = switch (recipeType) {
case SHAPED -> new MutableShapedRecipe(key);
case SHAPELESS -> new MutableShapelessRecipe(key);
case BLASTING -> new MutableBlastingRecipe(key);
case FURNACE -> new MutableFurnaceRecipe(key);
case SMOKING -> new MutableSmokingRecipe(key);
case CAMPFIRE -> new MutableCampfireRecipe(key);
case SMITHING -> new MutableSmithingRecipe(key, recipeType);
case SMITHING_TRANSFORM -> new MutableSmithingTransformRecipe(key);
case SMITHING_TRIM -> new MutableSmithingTrimRecipe(key);
case STONECUTTING -> new MutableStonecuttingRecipe(key);
case TRANSMUTE -> new MutableTransmuteRecipe(key);
default -> null;
};
}

public void setErrorInSection() {
this.errorInSection = true;
}

TheAbsolutionism marked this conversation as resolved.
Show resolved Hide resolved
public boolean getErrorInSection() {
return errorInSection;
}

public RecipeType getRecipeType() {
return recipeType;
}

public MutableRecipe getMutableRecipe() {
return mutableRecipe;
}

/**
* Specific event to determine if the mutableRecipe is of MutableCraftingRecipe
*/
public static class CraftingRecipeEvent extends CreateRecipeEvent {

public CraftingRecipeEvent(NamespacedKey key, RecipeType recipeType) {
super(key, recipeType);
};

/**
* Specific event to determine if the mutableRecipe is of MutableShapedRecipe
*/
public static class ShapedRecipeEvent extends CraftingRecipeEvent {
public ShapedRecipeEvent(NamespacedKey key) {
super(key, RecipeType.SHAPED);
};
}

/**
* Specific event to determine if the mutableRecipe is of MutableShapelessRecipe
*/
public static class ShapelessRecipeEvent extends CraftingRecipeEvent {
public ShapelessRecipeEvent(NamespacedKey key) {
super(key, RecipeType.SHAPELESS);
};
}
}

/**
* Specific event to determine if the mutableRecipe is of MutableCookingRecipe
*/
public static class CookingRecipeEvent extends CreateRecipeEvent {

public CookingRecipeEvent(NamespacedKey key, RecipeType recipeType) {
super(key, recipeType);
};

public static class BlastingRecipeEvent extends CookingRecipeEvent {
public BlastingRecipeEvent(NamespacedKey key) {
super(key, RecipeType.BLASTING);
}
}

public static class CampfireRecipeEvent extends CookingRecipeEvent {
public CampfireRecipeEvent(NamespacedKey key) {
super(key, RecipeType.CAMPFIRE);
}
}

public static class FurnaceRecipeEvent extends CookingRecipeEvent {
public FurnaceRecipeEvent(NamespacedKey key) {
super(key, RecipeType.FURNACE);
}
}

public static class SmokingRecipeEvent extends CookingRecipeEvent {
public SmokingRecipeEvent(NamespacedKey key) {
super(key, RecipeType.SMOKING);
}
}
}

public static class SmithingRecipeEvent extends CreateRecipeEvent {
public SmithingRecipeEvent(NamespacedKey key, RecipeType recipeType) {
super(key, recipeType);
}

public static class SmithingTransformRecipeEvent extends SmithingRecipeEvent {
public SmithingTransformRecipeEvent(NamespacedKey key) {
super(key, RecipeType.SMITHING_TRANSFORM);
}
}

public static class SmithingTrimRecipeEvent extends SmithingRecipeEvent {
public SmithingTrimRecipeEvent(NamespacedKey key) {
super(key, RecipeType.SMITHING_TRIM);
}
}
}

public static class StonecuttingRecipeEvent extends CreateRecipeEvent {
public StonecuttingRecipeEvent(NamespacedKey key) {
super(key, RecipeType.STONECUTTING);
}
}

public static class TransmuteRecipeEvent extends CreateRecipeEvent {
public TransmuteRecipeEvent(NamespacedKey key) {
super(key, RecipeType.TRANSMUTE);
}
}

@Override
public @NotNull HandlerList getHandlers() {
throw new IllegalStateException();
}
}
Loading
Loading