juliarn / npc-lib

Asynchronous, high-performance Minecraft NPC library for 1.8-1.21 servers.
MIT License
320 stars 50 forks source link

Hologram lib integration for multiple lines #59

Closed unldenis closed 2 years ago

unldenis commented 2 years ago

Given the need to create npc with multiple name lines, #56 #48 I implemented my new Hologram-Lib library in this one. (Already tried and everything seems to work.) My library uses ProtocolLib to create holograms with different features (You can also contribute in case).

In the integration I created a subclass of Hologram because the two show and hide methods in the library removed it from the list of seeing players.

The most essential thing was to create the teams to remove the npc nametag.

I don't think I need to comment on everything since my hologram library is also open source, but if you need to, I'll answer it.

A simple use:

public void appendNPC(Location location) {
        // building the NPC
        NPC npc = NPC.builder()
                .profile(this.createProfile())
                .location(location)
                .imitatePlayer(false)
                .lookAtPlayer(false)
                .addLine("Hello world")
                .addLine("Hello %%player%%")
                .addLine(new ItemStack(Material.EMERALD_BLOCK))
                .addPlaceholder("%%player%%", Player::getName)
                // appending it to the NPC pool
                .build(this.npcPool);

        npc.hologram().setAnimation(2, AnimationType.CIRCLE);
}

Preview: 2022-01-06_20 03 15

unldenis commented 2 years ago

The reason is that if you noticed to have the holograms I have to remove the nametag from the npc. Making the name editable could lead to problems in case it matches the names of some players for example. Compared to the other question: 1) the user is not obliged to add this text 2) why add other Bukkit tasks if I can make the npc visible together with the text 3) the user should remove the nametag himself 4) the library is opensource and uses packets like this

Just knowing it's a dependency doesn't make it a problem, or at least in my opinion this functionality in my plugin is necessary and worth it. I also look forward to

Bloeckchengrafik commented 2 years ago

I think this feature would be a great addition, but in my oppinion, the dependency should be optional and only be used if multiline nametags are needed, "normal" nametags should be possible either way.

derklaro commented 2 years ago

Yes i meant that, sorry if that was not so clear :). The main reason why this is currently not the best thing to integrate is because of the library design itself... There is currently no real way for extensions to be integrated (which we might address when doing a rewrite which is currently not a thing I nor juliarn have time for)

mxuricerm commented 2 years ago

Where can i get the libary with multiplie lines?

derklaro commented 2 years ago

It's linked in the initial description...

mxuricerm commented 2 years ago

Are there both libraries in one somewhere? Because I can only find both libraries individually

unldenis commented 2 years ago

For those who need the integration, the fork is here! https://github.com/unldenis/NPC-Lib/tree/hologramlib-integration