How figt/mesh works
Project type and purpose
• This is a Java library (distributed via Maven Central) that provides a Spigot‐based abstraction over CompletableFuture, letting plugin authors “mesh” together asynchronous and synchronous tasks in a pipeline while automatically switching thread contexts.
• Evidence: pom.xml (Maven project), src/main/java/us/figt/mesh, plugin.yml (Spigot plugin descriptor), README description.
File structure
• Top level:
• .github/ – CI and issue templates
• pom.xml – Maven build config
• src/main/java/us/figt/mesh – core library code
• src/main/java/us/figt/mesh/example – sample plugin to illustrate usage
• src/main/resources/plugin.yml – plugin metadata
• Core packages:
• mesh – Mesh.java (public API), MeshRunnables.java (task definitions)
• utils – PluginUtil.java (loader/initialization), ThreadContext.java (enum for SYNC vs ASYNC)
• No frontend, no external microservices, purely an embeddable library/plugin.
Extract additional insights from README
• Mesh is intended to be shaded & relocated to avoid dependency conflicts.
• Usage revolves around constructing a mesh of tasks (like CompletableFuture chains) where each stage can be executed on a different thread context (main thread or async thread via Bukkit scheduler).
a. Mesh Library Core
• Mesh API (Mesh.java)
• MeshRunnables (defines units of work)
• ThreadContext (SYNC, ASYNC)
• PluginUtil (initializes context, registers scheduler hooks)
b. Spigot Server (external service)
• BukkitScheduler (schedules sync/async tasks)
• Server main thread
c. Example Plugin (us.figt.mesh.example)
• Consumes Mesh API to define a task graph
d. End user / plugin author code (builds mesh pipelines)
Relationships and interactions
• Plugin author code → calls Mesh API to create a Mesh instance.
• Mesh internally uses MeshRunnables and ThreadContext to break down the pipeline.
• For each stage: Mesh invokes PluginUtil to hand off runnable to BukkitScheduler, using ThreadContext to pick sync or async queue.
• BukkitScheduler routes tasks to the server main thread or background worker threads.
• Completion of one stage triggers the next stage in the pipeline until the mesh is drained.
Architectural patterns and design principles
• Fluent‐style / builder pattern for composing tasks.
• Adapter/facade over Java’s CompletableFuture + Bukkit scheduler.
• Separation of concerns: core library vs external scheduler vs example usage.
• Lightweight, embeddable plugin model.
Technologies, frameworks, libraries
• Java 8+ (CompletableFuture)
• Spigot API (BukkitScheduler)
• Maven for build and dependency management
• Optional shading via Maven Shade Plugin
• “Example Plugin” (user code)
• “Mesh API”
• “MeshRunnables & ThreadContext”
• “PluginUtil”
• “BukkitScheduler”
• “Server Main Thread” and “Async Thread Pool”
• From Example Plugin → Mesh API → internal utils → BukkitScheduler → thread pools.
• From thread pools back into Mesh to trigger next stage.
• Green for user/plugin code
• Blue for library internals
• Orange for external Spigot components
• Rectangles for services and libraries