Skip to content
LeeGod edited this page Aug 27, 2022 · 1 revision

Hologram module is a powerful module for minecraft developers to add floating text in the world. Fairy's Hologram is a thread-safety, cross-platform, packet-based system. Which provides the best experience for development.

Code example...

    // plugin enable example
    @Override
    public void onPluginEnable() {
        Log.info("Plugin Enabled.");

        // listen to a player join event
        GlobalEventNode.get().addListener(MCPlayerJoinEvent.class, event -> {
            MCPlayer player = event.player();

            // creates a hologram on player join
            Hologram.create(player.pos())
                    .withLine(HologramLine.create(Component.text("Good morning!", Style.style()
                            .decorate(TextDecoration.ITALIC)
                            .build())))
                    .withLine(HologramLine.create(Component.text(player.getName(), NamedTextColor.AQUA)))
                    // how far can the hologram be viewed.
                    .withViewDistance(1)
                    // different handlers whenever player interacts with the entity.
                    .withAttackHandler(mcPlayer -> mcPlayer.sendMessage("You left clicked the hologram."))
                    .withInteractHandler(mcPlayer -> mcPlayer.sendMessage("You right clicked the hologram."))
                    // now spawn it!
                    .spawn();
        });
    }
Clone this wiki locally