Skip to main content

MVEL 函数注册事件

开始

本事件用于注册和管理带有 @SKPFunction 注解的静态方法,并将其注册到 MVEL 表达式引擎中供数据包使用。


开发环境设置

第一步设置你的开发环境,本模组可通过CurseMaven/ModrinthMaven导入,如下:

repositories {
//对于CurseMaven
maven {
name = "Curse Maven"
url = "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}

//对于ModrinthMaven
maven {
url = "https://api.modrinth.com/maven"
}
}

将 SKP 添加到依赖项是一件很简单的事情,你可以:

//对于CurseMaven
implementation fg.deobf("curse.maven:smart-key-prompts-1300195:${SKP_id}")

//对于ModrinthMaven
implementation fg.deobf("maven.modrinth:smart-key-prompts:${SKP_version}")

配置完成后,就随意发挥你的想象吧!


使用示例

注册函数类

@Mod.EventBusSubscriber(modid = "yourmod", value = Dist.CLIENT)
public class YourModSKPIntegration {
@SubscribeEvent(priority = EventPriority.HIGH)
public static void onFunctionRegistration(FunctionRegistryEvent event) {
event.registerFunctionClass(YourModFunctions.class, "yourmod");
}
}

定义函数

@SKPFunction(value = "isHoldingItem", description = "检查玩家是否持有指定物品")
public static boolean isHoldingItem(String itemId) {
// 实现逻辑
return false;
}