开发环境为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();
}
}
}
官方代码如下:
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();
}
}
}
官方代码如下: