Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set a queue for dragons? #10

Open
Kumkfat opened this issue Dec 25, 2023 · 3 comments
Open

How to set a queue for dragons? #10

Kumkfat opened this issue Dec 25, 2023 · 3 comments
Assignees
Labels
Enhancement New feature or request

Comments

@Kumkfat
Copy link

Kumkfat commented Dec 25, 2023

I want my dragons to spawn in order from weakest to strongest. When i use weight system in this plugin for example. Dragon1 has weight 1 and Dragon2 has weight 2 it just spawns randomly.

@iXanadu13
Copy link
Owner

Yes, you are right.
Currently the plugin cannot specify exactly what the next dragon's type is. I think your advice is good, but it is unfortunate that this function depends on persistent data storage(for example, database) which are to be implemented.

@iXanadu13 iXanadu13 self-assigned this Dec 27, 2023
@iXanadu13
Copy link
Owner

But if you take groovy script into consideration, maybe it will be easy.
I can update some code of plugin and then show you an example.

@iXanadu13 iXanadu13 added the Enhancement New feature or request label Dec 27, 2023
@iXanadu13
Copy link
Owner

iXanadu13 commented Dec 27, 2023

dragon_type_decider.zip

(1) Decompress "dragon_type_decider.zip", you will get a groovy script.
(2) Reverse the unique_name of groovy script to adapt to your configuration.("zero","one","two","three","the 100th dragon",etc)
(3) Ensure you are using EnderDragon 2.4.0+

Note: The groovy script engine is disabled in default.
Click here to know how to enable it.

dragon_type_decider.groovy:

import groovy.transform.Field
import pers.xanadu.enderdragon.event.DragonRespawnPostEvent
import pers.xanadu.enderdragon.manager.DragonManager
import pers.xanadu.enderdragon.metadata.DragonInfo
import pers.xanadu.enderdragon.script.Events

static @Field List<String> list = ["zero","one","two","three"]

static void enable(){
    Events.register(DragonRespawnPostEvent.class, e->{
        DragonInfo info = e.getDragonInformation()
        String unique_name = info.unique_name
        int id = DragonManager.getCount()
        if(id==100){
            unique_name = "the 100th dragon"
        }
        else if(id==500){
            unique_name = "the 500th dragon"
        }
        else{
            unique_name = list[id % 4] //id mod 4. (100->"zero", 101->"one", 150->"two")
        }
        //set to the DragonInfo object, the change applies
        info.unique_name = unique_name
    })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants