Platform - Dani-error/velar GitHub Wiki

🧱 Velar Platform

đŸ› ī¸ What Is a Platform?

In Velar, the Platform object represents the core logic required to create, manage, and control NPCs. It handles version-specific features, scheduling, event management, world/profile resolution, and more.


âš™ī¸ Creating & Configuring the Platform

Usually all classes you need provide a builder and shouldn't be instantiated directly. To obtain a platform builder use the following:

On Bukkit

BukkitPlatform.bukkitNpcPlatformBuilder()

To set up the platform (using as an example Bukkit):

val platform = BukkitPlatform.bukkitNpcPlatformBuilder()
    .debug() // optional: enables debug logs
    .extension(plugin) // REQUIRED: your plugin instance
    .logger(plugin.logger) // optional: defaults to plugin logger
    .eventManager(customEventManager) // optional
    .npcTracker(customTracker) // optional
    .taskManager(customScheduler) // optional
    .profileResolver(customResolver) // optional
    .worldAccessor(customWorldAccessor) // optional
    .versionAccessor(customVersionAccessor) // optional
    .packetFactory(customPacketAdapter) // optional
    .actionController {
        it.flag(NPCActionController.SPAWN_DISTANCE, 5)
    }
    .build()

â„šī¸ Note: If .actionController {} isn't called, built-in imitation, spawn distance control, and related behavior won't work.


🧱 Platform Builder Method Reference

Method Description Wiki Page
logger(logger: PlatformLogger) Defines a custom logger for internal logging. PlatformLogger
eventManager(eventManager: NPCEventManager) Custom event propagation logic. EventManager
npcTracker(npcTracker: NPCTracker) Tracks all created NPCs. NPCTracker
taskManager(taskManager: PlatformTaskManager) Schedules tasks (sync/async). TaskManager
profileResolver(profileResolver: ProfileResolver) Resolves UUIDs and skin textures. ProfileResolver
worldAccessor(worldAccessor: PlatformWorldAccessor) Resolve worlds by names or ids. WorldAccessor
versionAccessor(versionAccessor: PlatformVersionAccessor) Gives version info and compatibility. VersionAccessor
packetFactory(packetFactory: PlatformPacketAdapter) Handles packet sending. PacketAdapter
actionController { ... } Enables default NPC behaviors like imitation. ActionController

đŸ—’ī¸ .extension() is required and must always be set. Other components are optional and use platform defaults if omitted.


🚀 Creating NPCs

Once you've built the platform, you can begin spawning NPCs using:

val npcBuilder = platform.newNPCBuilder()

In depth NPCs docs.