事实上EntityPixelmon的获取也得延时获取,因为在丢出宝可梦到宝可梦出现的过程中,宝可梦还不算出现实体,这种获取必定是空指针的,因此这段代码总是会return
能否加个次数限制?不然玩家一直处在不能刷神的环境的话,这就变成一个卡服机了。神兽刷空,后要怎么补
我个人想法:原版补的话就是强制生成,这样走的mod的逻辑,事件也会触发,类似执行了dospawnlegend,我写个脚本处理刷空的时候执行指令,执行的就是上面我说的这个指令,因为这个指令也会触发生成,就会在再一次走脚本代码逻辑,依次循环,直到成功才会停下
好麻烦了QAQ!可以,限制方式连续生成超过5(自定义)次执行定时任务,每过设置的事件,就尝试生存一次,成功就结束任务
也可以不要连续生成的限制,直接开始定时任务
写成脚本了能否加个次数限制?不然玩家一直处在不能刷神的环境的话,这就变成一个卡服机了。
import com.pixelmonmod.pixelmon.api.events.spawning.LegendarySpawnEvent
import com.pixelmonmod.pixelmon.api.spawning.SpawnerCoordinator
import com.pixelmonmod.pixelmon.spawning.LegendarySpawner
import me.fullidle.ficore.ficore.common.api.event.ForgeEvent
import me.fullidle.fiscript.fiscript.Main
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.scheduler.BukkitRunnable
class LegendarySpawnEmptyAdd implements Listener {
/*多少秒检测一次是否刷成功,修改时间后直接重载FIScript插件*/
static def time = 5
/*尝试生成次数,次数到了后就直接结束掉(比如是5那么连续五次都空后就放弃生成了)*/
static def numberOfAttempts = 5
/*以下你不用动我全自动*/
static def i = 0
static def alreadyProduced = false;
static void main(String[] args) {
Bukkit.getServer().getPluginManager().registerEvents(new LegendarySpawnEmptyAdd(),Main.plugin);
}
@EventHandler
def onTest(ForgeEvent event){
if (event.getForgeEvent() instanceof LegendarySpawnEvent.ChoosePlayer){
def e = event.getForgeEvent() as LegendarySpawnEvent.ChoosePlayer
def spawner = e.spawner as LegendarySpawner
Bukkit.getScheduler().runTask(Main.plugin,()->{
SpawnerCoordinator.PROCESSOR.execute {
def spawns = spawner.possibleSpawns
if (spawns == null) {
Bukkit.getServer().broadcastMessage("§7[§bLegendarySpawn§3EmptyAdd§7]:§c本次神兽生成,刷空咯!(5s后补发)")
i = 0
alreadyProduced = false;
def runnable = new BukkitRunnable(){
@Override
void run() {
if (Bukkit.getOnlinePlayers().size() < 1){cancel()}
if (alreadyProduced) {cancel()}
Bukkit.getServer().broadcastMessage('§7[§bLegendarySpawn§3EmptyAdd§7]:§a由于刷空尝试再次生成(如果没有生成这条消息不久后再见!)')
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"dolegendaryspawn")
i = i+1
if (i >= numberOfAttempts){
Bukkit.getServer().broadcastMessage("§7[§bLegendarySpawn§3EmptyAdd§7]:§c重复刷空${numberOfAttempts}次,我放弃了~")
cancel()
}
}
}
runnable.runTaskTimer(Main.plugin,0,time * 20)
}
}
})
}
if (event.getForgeEvent() instanceof LegendarySpawnEvent.DoSpawn){
alreadyProduced = true
}
}
}
感谢大佬!我有空去试试。写成脚本了
使用方法:
1.安装FICore,FIScript
2.运行一次服务器,打开FIScript的配置文件夹内创建一个文件名字,编码格式:GBK,文件名字格式:xxxxx.groovy
3.复制脚本内容到 xxxxx.groovy 内
4.配置FIScript的config.yml,将xxxxx.groovy的文件名字填到config.yml内的enable列表下(注意格式是list)JavaScript:import com.pixelmonmod.pixelmon.api.events.spawning.LegendarySpawnEvent import com.pixelmonmod.pixelmon.api.spawning.SpawnerCoordinator import com.pixelmonmod.pixelmon.spawning.LegendarySpawner import me.fullidle.ficore.ficore.common.api.event.ForgeEvent import me.fullidle.fiscript.fiscript.Main import org.bukkit.Bukkit import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.scheduler.BukkitRunnable class LegendarySpawnEmptyAdd implements Listener { /*多少秒检测一次是否刷成功,修改时间后直接重载FIScript插件*/ static def time = 5 /*尝试生成次数,次数到了后就直接结束掉(比如是5那么连续五次都空后就放弃生成了)*/ static def numberOfAttempts = 5 /*以下你不用动我全自动*/ static def i = 0 static def alreadyProduced = false; static void main(String[] args) { Bukkit.getServer().getPluginManager().registerEvents(new LegendarySpawnEmptyAdd(),Main.plugin); } @EventHandler def onTest(ForgeEvent event){ if (event.getForgeEvent() instanceof LegendarySpawnEvent.ChoosePlayer){ def e = event.getForgeEvent() as LegendarySpawnEvent.ChoosePlayer def spawner = e.spawner as LegendarySpawner Bukkit.getScheduler().runTask(Main.plugin,()->{ SpawnerCoordinator.PROCESSOR.execute { def spawns = spawner.possibleSpawns if (spawns == null) { Bukkit.getServer().broadcastMessage("§7[§bLegendarySpawn§3EmptyAdd§7]:§c本次神兽生成,刷空咯!(5s后补发)") i = 0 alreadyProduced = false; def runnable = new BukkitRunnable(){ @Override void run() { if (Bukkit.getOnlinePlayers().size() < 1){cancel()} if (alreadyProduced) {cancel()} Bukkit.getServer().broadcastMessage('§7[§bLegendarySpawn§3EmptyAdd§7]:§a由于刷空尝试再次生成(如果没有生成这条消息不久后再见!)') Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"dolegendaryspawn") i = i+1 if (i >= numberOfAttempts){ Bukkit.getServer().broadcastMessage("§7[§bLegendarySpawn§3EmptyAdd§7]:§c重复刷空${numberOfAttempts}次,我放弃了~") cancel() } } } runnable.runTaskTimer(Main.plugin,0,time * 20) } } }) } if (event.getForgeEvent() instanceof LegendarySpawnEvent.DoSpawn){ alreadyProduced = true } } }
5.重启服务器/直接热重载FIScript插件
浏览附件7847
laotou的那个应该是改的神奇宝贝宝可梦,帖子内也写了重制版,理论上找一个对 神奇宝贝幸运方块mod 能进行提示的插件就行了你好啊 可以写一个支持laotou幸运方块mod的插件吗 关于开出任何精灵都会有全服提示的那种[这里指左下角聊天发出的] 变量:%player%玩家 开出的精灵%pokemon% 依赖mod: pokelucky-1.2.0 版本1.12.2