autoFireWork

autoFireWork 1.0.0

Compatible API Versions
1.0.9
Contributors
Superice666
AutoFireWork
Highly customized fireworks decoration plug-in
Plug in function:
Highly customized fireworks decoration! You can customize the frequency, location, flight time, color, shape, trajectory and flicker of fireworks
Full open source, efficient operation, smooth without card service
How to install:
1. First install the blocklynukkit correctly and download the link https://www.mcbbs.net/thread-987302-1-1.html
2. Install its Python module (this plug-in is written by pure Python), and use the command
bninstall python
3. Waiting for the installation to complete, it may take 1-2 minutes, the process is fully automatic
4. Download the jar package in the attachment of this post, put it in the server plug-in directory, and restart the server
5. After the plug-in is installed, the BN interpreter will start up for 6-7 seconds, which is normal, because the BN interpreter is initializing the JIT compiler from Python to Java bytecode
How to use:
Command:
/fire interval_tick fireworks_rule > create a new firework rule
/fire remove > Open remove rule GUI

Command permission node autoFireWork.All , default op
How to write fireworks rules:
The fireworks rule is composed of English semicolons; the logical component expression is concatenated, and the number of items is 1 to 6
The location logic component is used to identify the location of fireworks. There is no default rebirth and lighting in the main world. The format is
pos:x : Y: Z: world name
The color logic component is used to identify the color of particles generated by fireworks explosion. There is no system to select colors randomly. The format is
Color: color
/*Optional colors
* black red green brown blue purple cyan
* lightgrey grey pink lightyellow yellow lightblue
* magenta orange white
*/

Flicker logic component is used to identify whether the particles flicker after the fireworks explosion. If there is no parameter, if there is no parameter, it means flashing; if not, it means no flashing. The format is
flick
Whether there is a string of parameters, that is, whether there is a string of particles or not
trail
The time logic component is used to mark how long the fireworks will explode. If there is no time logic component, the time format will be selected randomly
time: time enum
/ *
*The value of time enum can only be 0,1,2
*They are short, general and long
*/

The shape logic component is used to identify the shape after the fireworks explosion. If there is no shape, the shape will be selected randomly. The format is
shape: shape
/ *
*Available values for shapes are:
* smallball bigball star creeper burst
*/

For example, the command fire 10 pos:5:64:6:myworld;trail;shape:creeper
In myworld, a coolie fireworks with track color, random flight time and no flicker will be set off every 10 ticks (0.5 seconds)
For example, the command fire 15 trail;flick;color:eek:range;time:2
At the default main world regeneration point, an orange fireworks with trajectory and explosion flicker is set off every 15 ticks (0.75 seconds)

source code:
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!")
pictures:



Author
superice666
Downloads
820
Views
2,144
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from superice666

Top