mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
add craftengine functions support
This commit is contained in:
@@ -69,8 +69,8 @@ dependencies {
|
||||
compileOnly("io.th0rgal:oraxen:1.168.0")
|
||||
compileOnly("com.nexomc:nexo:1.7.3")
|
||||
compileOnly("com.github.brcdev-minecraft:shopgui-api:3.0.0")
|
||||
compileOnly("net.momirealms:craft-engine-core:0.0.61")
|
||||
compileOnly("net.momirealms:craft-engine-bukkit:0.0.61")
|
||||
compileOnly("net.momirealms:craft-engine-core:0.0.65")
|
||||
compileOnly("net.momirealms:craft-engine-bukkit:0.0.65")
|
||||
// entity
|
||||
compileOnly("io.lumine:Mythic-Dist:5.6.2")
|
||||
// eco
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.momirealms.customfishing.bukkit.integration.action;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.api.BukkitAdaptors;
|
||||
import net.momirealms.craftengine.core.plugin.context.ContextHolder;
|
||||
import net.momirealms.craftengine.core.plugin.context.PlayerOptionalContext;
|
||||
import net.momirealms.craftengine.core.plugin.context.event.EventFunctions;
|
||||
import net.momirealms.craftengine.core.plugin.context.function.Function;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.action.ActionFactory;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CEActionExpansion implements ActionFactory<Player> {
|
||||
|
||||
public static void register() {
|
||||
BukkitCustomFishingPlugin.getInstance().getActionManager().registerAction(new CEActionExpansion(), "ce-function");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public Action<Player> process(Object arg, MathValue<Player> mathValue) {
|
||||
if (arg instanceof List<?> list) {
|
||||
List<Function<net.momirealms.craftengine.core.plugin.context.Context>> functions = new ArrayList<>();
|
||||
for (Object o : list) {
|
||||
if (o instanceof Map functionArguments) {
|
||||
functions.add(EventFunctions.fromMap(functionArguments));
|
||||
}
|
||||
}
|
||||
return context -> {
|
||||
PlayerOptionalContext ctx = PlayerOptionalContext.of(BukkitAdaptors.adapt(context.holder()), ContextHolder.builder());
|
||||
for (Function<net.momirealms.craftengine.core.plugin.context.Context> function : functions) {
|
||||
function.run(ctx);
|
||||
}
|
||||
};
|
||||
}
|
||||
return context -> {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user