This module is packed with useful utilities and features that can enhance your projects in various ways. It's a versatile collection that will be updated regularly with new content.
dependencies {
compileOnly(files("libs/commons-1.0-SNAPSHOT.jar"))
}
The VarHandleReflectionInjector is an injector designed to work seamlessly with VarHandleAutoInjection. It simplifies the process of assigning VarHandle
without the need for verbose code.
public class Example {
public static void main(String[] args) {
Test test = new Test();
// Use TField_HANDLE to set the value
Test.TField_HANDLE.set(test, 2);
// Prints 2
System.out.println(test.getTField());
}
}
@Getter
@Setter
public class Test {
private volatile int tField = 100;
@VarHandleAutoInjection(fieldName = "tField")
public static VarHandle TField_HANDLE;
static {
// Managed by Fairy IoC or can be created directly
InjectorFactory.createVarHandleReflectionInjector().inject(Test.class);
}
}
The TaskInterface simplifies task scheduling by providing convenient methods that align with the Fairy Framework's MCScheduler.
public class Example {
public static void main(String[] args) {
TaskInterface taskInterface = new TaskInterface() {
@Override
public ScheduledTask<?> start() {
// Prints "Hello, world!" every second
return scheduleAtFixedRate(() -> System.out.println("Hello, world!"), 0, 1000);
}
};
// Start the task
taskInterface.start();
}
}
Utilize TaskAutoStartAnnotation to automate the start of tasks at specific times, reducing manual management.
@TaskAutoStartAnnotation(isFromFairyIoC = false)
public class Example implements TaskInterface {
@Override
public ScheduledTask<?> start() {
// Prints "Hello, world!" every second
return scheduleAtFixedRate(() -> System.out.println("Hello, world!"), 0, 1000);
}
}
For details on making annotation processors work with your plugins, refer to the annotation module.
This project is licensed under the MIT License - see the LICENSE file for details.