Skip to content

Project Architecture

Risto Lahtela edited this page Oct 30, 2019 · 13 revisions

Plan Header

Project Architecture (How the plugin is put together)

This page attempts to help new developers start contributing to Plan.

It does not go over the build tool & commands for building as those are detailed in Project Setup.

Page version: 5.0 build 263 Commit

Table of contents

  • Java
    • Modules & Dependencies between modules
    • Dagger & Dependency injection
    • Structure outline of common-module
    • About Platform APIs
  • Web dev
    • Technology stack
    • Template-like html
    • Static Resources

Modules & Dependencies between modules

Module Role
api Contains code for public API interface classes
extensions Contains built-in extensions that use DataExtension API (in public API)
common Main package for everything
bukkit, bungee, sponge, velocity Platform specific modules
plugin Creates a single jar out of the modules

Most of the time work is done in common module as platforms are abstracted away.

Build order

api -> extensions -> common -> bukkit, bungee, sponge, velocity -> plugin

From the build order, the dependencies between the modules should be apparent.

Dagger & Dependency Injection

Dagger (https://dagger.dev/) is used extensively around the project. It was used as a remedy to reduce static usage. (See decisions here Refactor plugin to use static getters and Dependency Injection: Dagger)

@Singleton annotations are used to tell Dagger that only a single instance should exist per initialized Component (So that each PlanSystem only has one DatabaseSystem instead of returning a new one every time the database is needed.)

@Inject annotations are used in Constructors to tell Dagger to resolve the dependencies for constructing a new instance of this class.

Note that the Inject constructors allow Injecting an instance of the class the constructor is in to another object:

public class Foo {
    @Inject
    public Foo() {}
}

public class Bar {
    @Inject
    public Bar(Foo foo) {}
}

This is the main mechanism used for instantiating different system level objects, more about those below.

Structure outline of common-module

Under construction

Clone this wiki locally