• 游客, 欢迎您来到九域资源社区,如果您是新人,请前往 论坛公告 板块查看新人引导教程 或者 点我打开
    如果您发现没有下载许可, 请先验证邮箱再进行下载;金锭可通过每日登陆或资源出售获取,目前没有其他渠道可获取。

如何编写Battle Pass的宝可梦附属任务插件?

XKZC

Lv.1 泥土
2023-11-14
7
0
0
钻石
0.00 钻石
金锭
225 金锭
开发环境为1.16.5 JAVA11,目前研究的代码如下,下一步就不会了,官方提供的示例代码似乎过时了而且也没注释,最好是能够指定宝可梦的等级、属性等参数,求各位大佬解答!

public class CapturePokemon extends ActionQuestExecutor {

/**
* @param javaPlugin
* @param s
* @deprecated
*/
public CapturePokemon(JavaPlugin javaPlugin, String s) {
super(javaPlugin, s);
}
@EventHandler
public void onCapturePokemon(ForgeEventV2 forgeEventV2) {
if (forgeEventV2.getForgeEvent() instanceof CaptureEvent.SuccessfulCapture) {
CaptureEvent.SuccessfulCapture e = (CaptureEvent.SuccessfulCapture) forgeEventV2.getForgeEvent();
Player player = e.getPlayer().getBukkitEntity();
Pokemon pokemon = e.getPokemon().getPokemon();;
super.execute("", player, result -> {
return result.root();
}, replacer -> replacer.set();
}
}
}

官方代码如下:
1728447779298.png
 
Java:
public class BattlePassModule implements IModel, Listener {
    private static BattlePassQuestExecutor battlePassQuestExecutor;

    @EventHandler
    public void onPluginReload(PluginReloadEvent event) {
        BattlePlugin.getApi().getActionRegistry().hook("PsExtras", (instance) -> {
            battlePassQuestExecutor = new BattlePassQuestExecutor();
            return battlePassQuestExecutor;
        });
    }

    /**
     * 调用此处提交你的参数并做条件处理即可
     */
    @Override
    public void submit(Player player, String questType, String condition, int amount, Pokemon pokemon) {
        if (battlePassQuestExecutor != null) {
            battlePassQuestExecutor.submit(player, questType, condition, amount);
        }
    }

    public static class BattlePassQuestExecutor extends ActionQuestExecutor {

        public BattlePassQuestExecutor() {
            super(PsExtras.getInstance(), "psextras");
        }

        public void submit(Player player, String questType, String condition, int amount) {
            super.execute(questType, player, amount, (action) -> action.root(condition));
        }
    }
}
 
Java:
public class BattlePassModule implements IModel, Listener {
    private static BattlePassQuestExecutor battlePassQuestExecutor;

    @EventHandler
    public void onPluginReload(PluginReloadEvent event) {
        BattlePlugin.getApi().getActionRegistry().hook("PsExtras", (instance) -> {
            battlePassQuestExecutor = new BattlePassQuestExecutor();
            return battlePassQuestExecutor;
        });
    }

    /**
     * 调用此处提交你的参数并做条件处理即可
     */
    @Override
    public void submit(Player player, String questType, String condition, int amount, Pokemon pokemon) {
        if (battlePassQuestExecutor != null) {
            battlePassQuestExecutor.submit(player, questType, condition, amount);
        }
    }

    public static class BattlePassQuestExecutor extends ActionQuestExecutor {

        public BattlePassQuestExecutor() {
            super(PsExtras.getInstance(), "psextras");
        }

        public void submit(Player player, String questType, String condition, int amount) {
            super.execute(questType, player, amount, (action) -> action.root(condition));
        }
    }
}
1728450728859.png
谢谢大佬答复!请问能够否再详细说明下如何使用?这几个标红的地方我不知道应该怎么处理。
 
你可以加我 QQ,我提供代码给你,1349905649