An open-source component of TabLight project "Base-API"

Overview

DataAddons

This library is an open-source component of TabLight project "Base-API"

Have a question or want to discuss this library? Join our discord server

DataAddons is a library (or framework?) created for Minecraft providing comfortable abstractions making additions over already existing data, generally, it is anti-pattern ans YOU SHOULDN'T USE IT in normal programms.
So why is it needed? It is needed for loading, storing, registering and processing of data addons and composing them out of different "sources" of data.

Downloading

For now this library has no public repository artifact, so the only way you can use it is via jar.

dependencies {
    compileOnly(files("DataAddons-vX.X.jar"))
}

Later We'll publish an artifact to a public repository.

Main concepts

Let's call types which have some data along with Minecraft's one data addons. These types have both native (Minecraft's) data and custom (plugin dev's) data. Usually native data serializes when Minecraft server stops, so every developer who has ever made "customX" class makes the same pattern every time:

  1. On server startup:
    • Execute a service looking for "native" data which has some tag distinguishes it from usual native data.
    • Execute service looking for "custom" data from its storage. (DB, serialized object, etc.)
    • Compose "native" and "custom" data into objects and "hold" these objects somewhere for further processing.
  2. While server running:
    • Process "held" objects.
    • Make new "custom" data from "native" if needed.
  3. On server shutdown:
    • Mark "custom" data generated from "native" while server running with "tag" which saves along with native data. (generally - NBT tag)
    • Save "custom" data to its storage. (DBs, serialization etc.)

As you probably noticed "these objects" which we construct, hold, process and store are data addons.

Quick Start.

In your JavaPlugin class make bootstrap.

public final class ExamplePlugin extends JavaPlugin {
    final DataAddonBootstrap bootstrap = new DataAddonBootstrap();
    
    @Override
    public void onEnable() {
        bootstrap.setContainer(GlobalGroupContainer.getInstance()); // 1.
        bootstrap.bootstrapRegistries("com.example.registries"); 
        bootstrap.bootstrapDataAddons("com.example.addons");
    }

    @Override
    public void onDisable() {
        logger.info("Disabling Tablight Entities plugin...");
    }
}
  1. It uses static GlobalGroupContainer, so you can interact with other registered types of other users,
    For non-static GroupContainer write new GroupContainer();.

What is com.example.registries? We call "registries" TypeRegistry, TypeHolder and StoreLoadController classes, what each registry do we'll discuss later. In com.example.registries you should define classes as:

@Registry("example-group")
public class ExampleTypeRegistry extends DefaultTypeRegistry {
}
@Holder("example-group")
public class ExampleTypeHolder extends ConcurrentTypeHolder {
}
@Controller("example-group")
public class ExampleController extends DefaultStoreLoadController {
}

Note that for proper connection these classes should have the same "group tag". And You can override their methods to define your own behaviour for "pre-processing" and "post-processing".

What is com.example.addons? It is our data addons classes, we use them in "registries". You should define data addon class as:

@DataAddon(
		identifier = "example", // 1.
		groupTag = "example-group", // 2.
		nativeClass = NativeExampleClass.class, // 3.
		lookup = ExampleDataAddonLookup.class
)
public class ExampleDataAddon {
	private String someString;
	private String someNativeStringData;

	public String getSomeString() {
		return someString;
	}

	public String getSomeNativeStringData() {
		return someNativeStringData;
	}

	public void setSomeNativeStringData(String someNativeStringData) {
		this.someNativeStringData = someNativeStringData;
	}

	@Store // 4
	public void store() {
		someString = "store";
	}

	@Load // 5
	public void load() {
		someString = "load";
	}
}
  1. identifier is a unique ID in group in which this data addon registered.
  2. groupTag is the same group tag as you registered "registries" before, it tells a bootstrap that this data addon processes in "registries" which have the same groupTag in their annotations.
  3. nativeClass is a class which have "native" data.
  4. @Store annotation identifies method which stores "custom" data to its storage.
  5. @Load annotation is the same as @Store but loads "custom" data from its storage.

What is lookup? lookup is a class which looks for a "native" data (in Minecraft server) marked with some tag, and instantiates data addon with ONLY with "native" data, and puts this instance into a TypeHolder.
Let's take a look at this example:

public class NativeExample {
    private final String someNativeString;
    public NativeDummy(String nativeString) {
        this.someNativeString = nativeString;
    } 

    public String getSomeNativeString() {
        return someNativeString;
    }
}
> lookup() { // We return "lazy" Supplier returning collection instead of collection itself. return () -> nativeExamples.stream().map(nativeExamples -> { var dummy = new ExampleDataAddon(); dummy.setSomeNativeStringData(nativeExamples.getSomeNativeString()); return dummy; }).toList(); } @Override public Stream getNatives() { // We return "lazy" Stream instead of usual Collection. return nativeDummiesContainer.stream(); } }">
public class ExampleDataAddonLookup implements StoreLoadLookup<ExampleDataAddon, NativeExample> {

    private final Collection<NativeExample> nativeExamples = Lists.newArrayList( // we use a collection as an example, in plugins we use server data.
            new NativeExample("native1")
    );

    @Override
    public Supplier<Collection<ExampleDataAddon>> lookup() { // We return "lazy" Supplier returning collection instead of collection itself.
        return () -> nativeExamples.stream().map(nativeExamples -> {
            var dummy = new ExampleDataAddon();
            dummy.setSomeNativeStringData(nativeExamples.getSomeNativeString());
            return dummy;
        }).toList();
    }

    @Override
    public Stream<NativeExample> getNatives() { // We return "lazy" Stream instead of usual Collection.
        return nativeDummiesContainer.stream();
    }
}

I've written it all, how do I use it?
Now, let's back to DataAddonBootstrap, it has everything configured, look at this example:

heldExamples = typeHolder.getHeld(ExampleDataAddon.class); // You can obtain all configured data addons using holder. heldExamples.forEach(heldExample -> { System.out.println("Handling: " + heldExample.toString()); // And you handle them. }); controller.store(ExampleDataAddon.class); // And you store it back. } }">
public final class ExamplePlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        //...
        var typeReg = bootstrap.getRegistry(ExampleTypeRegistry.class);
        var typeHolder = bootstrap.getRegistry(ExampleTypeHolder.class);
        var controller = bootstrap.getRegistry(ExampleController.class);
        
        controller.lookupAndLoad(ExampleDataAddon.class); // it looks for this class using its lookup and loads "custom" data into "looked up" objects instances.
        Collection<ExampleDataAddon> heldExamples = typeHolder.getHeld(ExampleDataAddon.class); // You can obtain all configured data addons using holder.
        heldExamples.forEach(heldExample -> {
            System.out.println("Handling: " + heldExample.toString()); // And you handle them.
        });
        controller.store(ExampleDataAddon.class); // And you store it back.
    }
}

That's all! For further reading, read the java docs in files. This Library has more functional I didn't show in this quick start, such as LMAX Disruptor events in TypeHolder, or manual bootstrapping without annotations.

Contributing

Contributions are welcome! But you need to understand that your code will be used on TabLight's servers, so very slow or very hacky contributions will be denied.

You might also like...

This project is a specialized fork of Checkstyle to support older runtime environments of users who can't upgrade

This project is a specialized fork of Checkstyle to support older runtime environments of users who can't upgrade

checkstyle-backport-jre8 The latest release version can be found at GitHub releases or at Maven repo. This project is a specialized fork of Checkstyle

Apr 21, 2022

The project was created using the API of the Spotify application.

Spotify API The project was created using the API of the Spotify application.

Jan 27, 2022

Sceneform React Native AR Component using ARCore and Google Filament as 3D engine. This the Sceneform Maintained Component for React Native

Sceneform React Native AR Component using ARCore and Google Filament as 3D engine. This the Sceneform Maintained Component for React Native

Discord Server Join us on Discord if you need a hand or just want to talk about Sceneform and AR. Features Remote and local assets Augmented Faces Clo

Dec 17, 2022

An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or to turn an existing project into a devops project using open source software (Git, Docker, Jenkins..)

An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or to turn an existing project into a devops project using open source software (Git, Docker, Jenkins..)

DevOpsify Description An assistance platform made using Spring framework that analyses your code, and helps you either to start a devops project, or t

Nov 8, 2022

This open source project allows you to easily integrate Camunda's External Task Clients into Micronaut projects: simply add a dependency in your Micronaut project

micronaut-camunda-external-client This open source project allows you to easily integrate Camunda 's External Task Clients into Micronaut projects. Mi

Dec 18, 2022

A React Native project starter with Typescript, a theme provider with hook to easy styling component, a folder architecture ready and some configs to keep a codebase clean.

React Native Boilerplate Folder structure : src ├── assets │   ├── audios │   ├── fonts │   ├── icons │   └── images ├── components │   ├── Layout.tsx

Sep 1, 2022

Sourcetrail - free and open-source interactive source explorer

Sourcetrail - free and open-source interactive source explorer

Sourcetrail Sourcetrail is a free and open-source cross-platform source explorer that helps you get productive on unfamiliar source code. Windows: Lin

Jan 5, 2023

Source code of APK-Explorer-Editor (AEE), an open-source tool to explore the contents of an installed APK!

Source code of APK-Explorer-Editor (AEE),  an open-source tool to explore the contents of an installed APK!

APK Explorer & Editor (AEE) APK Explorer & Editor, an open-source tool to explore the contents of an installed APK, is strictly made with an aim to in

Jan 8, 2023

GWT Open Source Project

GWT GWT is the official open source project for GWT releases 2.5 and onwards. In this document you have some quick instructions to build the SDK from

Jan 5, 2023

HornetQ is an open source project to build a multi-protocol, embeddable, very high performance, clustered, asynchronous messaging system.

HornetQ If you need information about the HornetQ project please go to http://community.jboss.org/wiki/HornetQ http://www.jboss.org/hornetq/ This file

Dec 3, 2022

Unofficial Clubhouse web app client. For personal use only. It's a personal open-source project and not affiliated with any company.

Unofficial Clubhouse web app client. For personal use only. It's a personal open-source project and not affiliated with any company.

Purpose of this web app That's a personal project and not affiliated with any company. This is the web client app to make your Club House experience b

Nov 15, 2022

log4j-scanner is a project derived from other members of the open-source community by CISA's Rapid Action Force team to help organizations identify potentially vulnerable web services affected by the log4j vulnerabilities.

Log4j Scanner This repository provides a scanning solution for the log4j Remote Code Execution vulnerabilities (CVE-2021-44228 & CVE-2021-45046). The

Dec 22, 2022

BioJava is an open-source project dedicated to providing a Java framework for processing biological data.

BioJava is an open-source project dedicated to providing a Java framework for processing biological data.

Welcome to BioJava is an open-source project dedicated to providing a Java framework for processing biological data. It provides analytical and statis

Dec 31, 2022

The open source CyborgFlow project is an out-of-the-box (OOTB) solution to perform load test on your online system.

The open source CyborgFlow project is an out-of-the-box (OOTB) solution to perform load test on your online system.

CyborgFlow CyborgFlow provides an out-of-the-box (OOTB) solution to perform load test on your online system, powered by Apache APISIX, Apache SkyWalki

Nov 30, 2022

Ultimate Component Suite for JavaServer Faces

Ultimate Component Suite for JavaServer Faces

PrimeFaces This is an overview page, please visit PrimeFaces.org for more information. Overview PrimeFaces is one of the most popular UI libraries in

Jan 3, 2023

Apache Wicket - Component-based Java web framework

Apache Wicket - Component-based Java web framework

What is Apache Wicket? Apache Wicket is an open source, java, component based, web application framework. With proper mark-up/logic separation, a POJO

Dec 31, 2022

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)

Sentinel: The Sentinel of Your Microservices Introduction As distributed systems become increasingly popular, the reliability between services is beco

Dec 31, 2022

The metric correlation component of Etsy's Kale system

The metric correlation component of Etsy's Kale system

Oculus is an Archived Project Oculus is no longer actively maintained. Your mileage with patches may vary. Oculus Oculus is the anomaly correlation co

Oct 14, 2022

A JavaFX 3D Visualization and Component Library

A JavaFX 3D Visualization and Component Library

FXyz3D FXyz3D Core: FXyz3D Client: FXyz3D Importers: A JavaFX 3D Visualization and Component Library How to build The project is managed by gradle. To

Aug 23, 2020
Releases(extended-holders)
Owner
XXR
Denery's organization making experimental projects...
XXR
An open source, modular alternative of sketchware. Create your own app in android using block programming like scratch!

OpenBlocks An open source, modular alternative of sketchware. Create your own app in android using block programming like scratch! What is OpenBlocks?

OpenBlocks 30 Dec 16, 2022
RealmeDirac - an open-source Android application written in java

RealmeDirac is an open-source Android application written in java. RealmeDirac is a feature introduced by realme & dirac in realmeUI for sound optimisation, trying to recreate same thing, this is scratch written app aiming to provide same features as realmeDirac..

psionicprjkt 4 Feb 21, 2022
A Parser That parses OpenAPI definitions in JSON or YAML format and Generates Pact files That contain HTTP request/response interactions by parsing Given Open API specifications

This is a Parser That parses OpenAPI definitions in JSON or YAML format and Generates Pact files That contain HTTP request/response interactions by parsing Given Open API specifications.

dev-rgupta 2 Mar 19, 2022
Cobaltstrike4.1 Source

CobaltstrikeSource Cobaltstrike4.1 Source 这是反编译后的Cobaltstrike4.1源码,修改了一点反编译后的bug,teamserver与agressor均能正常调试使用,若想自己修改调试那个文件只需把该文件复制到src下即可。 这是魔改Cobaltst

rooster 623 Sep 7, 2021
This repository holds the source code for TML (Tecknix Mod Loader)'s API.

This repository contains the modding API not the MDK (Mod Development Kit). This repository will not give you the ability to mod Tecknix Client but you can contribute to the repository if you have events you would like to add.

Tecknix Client 6 Aug 1, 2022
A harness to build the source code from openjdk.java.net using Free Software tools and dependencies

A harness to build the source code from openjdk.java.net using Free Software tools and dependencies

IcedTea 2 Mar 5, 2022
The easiest way to integrate Maven into your project!

Maven Wrapper Ongoing Migration to Apache Maven The project codebase has been accepted to be included in the upstream Apache Maven project itself. Cur

null 1.6k Dec 23, 2022
a little project that will help you get in jail

Heftgen [ˈhɛftçən] ausgesprochen: Heftchen Development Install this npm module globally (https://www.npmjs.com/package/git-conventional-commits) Enabl

null 5 Jun 26, 2021
YDI_B It is a project to download videos from YouTube

YDI-B in this project will be Application based YouTube url extractor . downloader youtube video and audio from url Gradle To always build from the la

ismail belgacem 6 Jun 27, 2022
This is a basic Java project focused on applying object-oriented design in a real world application

Email-Administration-System-in-Java This is a basic Java project focused on applying object-oriented design in a real world application. Email Adminis

Muhammad Asad 5 Feb 4, 2022