autoFireWork自动放烟花

插件 autoFireWork自动放烟花 1.0.0

登录后下载
资源类型
原创
版权链接
#
API
1.0.8
依赖
BlocklyNukkit
语言
多语言
AutoFireWork

高度自定义的烟花装饰插件

插件功能:

高度自定义的烟火装饰! 可以自定义燃放频率,燃放位置,烟花飞行时间,烟花颜色,烟花形状,烟花轨迹和是否闪烁

全开源,高效运行,流畅不卡服

如何安装:

1、首先正确安装BlocklyNukkit,下载链接https://www.mcbbs.net/thread-987302-1-1.html

2、安装其python模块(本插件由纯python编写),使用命令
bninstall python
3、等待安装完毕,可能需要消耗1-2分钟时间,过程全自动

4、下载本帖附件中的jar包,放到服务器插件目录下,重启服务器即可

5、安装本插件后bn解释器启动会有6-7秒卡顿,属正常现象,因为bn解释器正在初始化python到java字节码的jit编译器

如何使用:

命令:

  • fire 间隔tick 烟花规则 ->新建一个燃放规则
  • fire remove ->打开移除规则gui
  • 命令权限节点autoFireWork.All,默认op
如何编写烟花规则:
  • 烟花规则是由英文分号;连缀逻辑组件表达式,项数是1到6项
  • 位置逻辑组件,用于标识烟花的燃放位置,不存在默认在主世界重生点燃放,格式为
    pos:x:y:z:世界名
  • 颜色逻辑组件,用于标识烟花爆炸产生的粒子的颜色,不存在系统随机取颜色,格式为
    color:颜色
    /* 可选的颜色
    * black red green brown blue purple cyan
    * lightgrey grey pink lightyellow yellow lightblue
    * magenta orange white
    */
  • 闪烁逻辑组件,用于标识烟花爆炸之后粒子是否闪烁,没有参数,存在即代表闪烁,不存在代表不闪烁,格式为
    flick
  • 轨迹逻辑组件,用于标识烟花是否拖着一串粒子轨迹上天,没有参数,存在即代表有,不存在代表无,格式为
    trail
  • 时间逻辑组件,用于标识烟花飞多久爆炸,没有则随机取时间格式为
    time:时间enum
    /*
    * 时间enum可取的值只能是0,1,2
    * 分别代表短,一般,长
    */
  • 形状逻辑组件,用于标识烟花爆炸之后的形状,没有则随机取形状,格式为
    shape:形状
    /*
    * 形状的可用值为:
    * smallball bigball star creeper burst
    */
例如命令 fire 10 pos:5:64:6:myworld;trail;shape:creeper
在myworld世界每10tick(0.5秒)燃放一个带有轨迹颜色随机飞行时间随机不闪烁的苦力怕型烟花
例如命令 fire 15 trail;flick;color:orange;time:2
在默认主世界重生点每15tick(0.75秒)燃放一个橙色带有轨迹和爆炸闪烁飞行时间长形状随机的烟花
源代码:
Python:
# -*- coding: UTF-8 -*-
# pragma Python
import json
import random
import cn.nukkit.level.Position as POS

def isChinese():
    return u"中文" in server.getLanguage().getName()

logger.info(u"自动烟花插件加载完成" if isChinese() else u"autoFireWork plugin successfully loaded!")
manager.createPermission("autoFireWork.All","autoFireWork Permission","OP")
manager.createCommand("fire",u"自动烟花设置" if isChinese() else u"autoFireWork settings","autoFireWorkCall","autoFireWork.All")

text = manager.readFile("./plugins/autoFireWork/config.json")
if text == "FILE NOT FOUND":
    manager.writeFile("./plugins/autoFireWork/config.json","[]")
    text = "[]"
config = json.loads(text)
manager.createLoopTask("dotickFireWork",1)

def dotickFireWork(tick):
    for entry in config:
        if tick%entry['interval'] == 0:
            mkfirewordk(entry['rule'])

def mkfirewordk(ruleEntry):
    ruleEntry = ruleEntry.replace(" ",'')
    group = ruleEntry.split(";")
    pos = server.getDefaultLevel().getSpawnLocation()
    color = random.randint(0,15)
    flick = False
    trail = False
    shape = random.randint(0,4)
    time = random.randint(0,3)
    for each in group:
        if each.startswith('pos'):
            each = each.replace("pos:","")
            tmpgroup = each.split(":")
            pos = POS.fromObject(manager.buildvec3(float(tmpgroup[0]),float(tmpgroup[1]),float(tmpgroup[2])),server.getLevelByName(tmpgroup[3]))
        elif each.startswith('color'):
            each = each.replace("color:","").replace("black","0").replace('red',"1").replace('green','2').replace("brown",'3').replace("blue",'4').replace("purple","5")
            each = each.replace("cyan","6").replace("lightgrey","7").replace("grey","8").replace('pink','9').replace('lightyellow','10').replace('yellow','11').replace('lightblue','12')
            each = each.replace("magenta",'13').replace("orange",'14').replace('white','15')
            color = int(each)
        elif each == 'flick':
            flick = True
        elif each == "trail":
            trail = True
        elif each.startswith("shape"):
            each = each.replace("shape:","").replace('smallball',"0").replace("bigball",'1').replace("star","2").replace('creeper','3').replace("burst",'4')
            shape = int(each)
        elif each.startswith("time"):
            each = each.replace("time:","")
            time = int(each)
    particle.drawFireWork(pos,color,flick,trail,shape,time)
    
def removecall(event):
    ruleentry = window.getEventCustomVar(event, 1, "dropdown").replace(u';',';')
    pl = event.getPlayer()
    for x in config:
        if ruleentry == x['rule']:
            config.remove(x)
            pl.sendMessage(u"§a规则"+ruleentry+u"成功移除" if isChinese() else u"§arule "+ruleentry+u" has been removed")
            manager.writeFile("./plugins/autoFireWork/config.json",json.dumps(config))


def autoFireWorkCall(sender,args):
    if not sender.isOp():
        sender.sendMessage(u"§c你没有权限使用此命令" if isChinese() else u"§cYou do not have the permission to use this command")
        return
    if len(args)<1:
        sender.sendMessage(u"§c命令参数太少了" if isChinese() else u"§cToo few arguments!")
        return
    if args[0] == "delete" or args[0] == 'remove':
        bd = window.getCustomWindowBuilder(u'移除自动烟花规则' if isChinese() else u'remove autoFireWork rules')
        bd.buildLabel(u'选择一条规则进行移除' if isChinese() else "Select a rule to remove")
        bd.buildDropdown(u'自动烟花规则' if isChinese() else u'autoFireWork rules',''.join(i['rule'].replace(";",u";")+";" for i in config))
        bd.showToPlayer(server.getPlayer(sender.getName()),'removecall')
    else:
        rules = args[1] if len(args)>1 else ""
        config.append({"interval":int(args[0]),"rule":rules})
        manager.writeFile("./plugins/autoFireWork/config.json",json.dumps(config))
        sender.sendMessage(u"§a成功添加新的自动烟花规则!" if isChinese() else u"§aSuccessfully added a new autoFireWork rule!")
预览图:


如果您的服务器预设语言为中文,窗口文字将自动变为中文
作者
超神的冰凉
价格
金粒30粒
下载
6
阅读
426
首次发布
最后更新
评分
0.00 星 0 次评分

超神的冰凉的更多资源