Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghost-chu/simplereloadlib
Simple but useful generic reload library for Java projects.
https://github.com/ghost-chu/simplereloadlib
java libraries reload simple
Last synced: about 8 hours ago
JSON representation
Simple but useful generic reload library for Java projects.
- Host: GitHub
- URL: https://github.com/ghost-chu/simplereloadlib
- Owner: Ghost-chu
- License: mit
- Created: 2022-01-31T18:29:08.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-16T11:00:17.000Z (over 1 year ago)
- Last Synced: 2024-04-19T16:12:48.221Z (7 months ago)
- Topics: java, libraries, reload, simple
- Language: Java
- Homepage:
- Size: 104 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleReloadLib
Simple Java generic reload library.## Introduce
SimpleReloadLib isvused to be a part of QuickShop-Reremake. But it is really easy to use and powerful, so I made it to a standalone lib.
You can insert this to any Java project including Bukkit, Paper, BungeeCord, Forge, Fabric etc.
This lib is already used in QuickShop-Reremake over 1 year and no errors were found.## Features
* Reloading mechanism based on registration order, no need to worry about reload order。
* Simple and easy to use, just need to register with eyes closed.
* Lightweight, powered by 5 java classes. You can package it into any project.
* WeakReference to save your memory and prevent memory leaking.
* Support both object and static method.## How to use
1. Create a Reload Manager
```java
ReloadManager reloadManager = new ReloadManager();
```2. Implement Reloadable and register it into ReloadManager (or static method if register for static util)
```java
public class Example implements Reloadable {
public Example(){
Instance.getReloadManager().register(this);
}
@Override
public ReloadResult reloadModule() throws Exception {
try{
// Reload code here
return ReloadResult.builder().status(ReloadStatus.SUCCESS).build();
} catch (IllegalStateException scheduleException) {
return ReloadResult.builder().status(ReloadStatus.SCHEDULED).reason("Resource in use").build();
} catch (RuntimeException requireRestartException) {
return ReloadResult.builder().status(ReloadStatus.REQUIRE_RESTART).reason("Restart required").build();
} catch (Exception otherException){
return ReloadResult.builder().status(ReloadStatus.EXCEPTION).exception(otherException).reason("Unkown error raised").build();
}
// If there have any Exception not be catched, Manager will catch it and report with ReloadStatus.EXCEPTION
}
}
```3. Reload it!
```java
Map results = reloadManager.reload();
Map results = reloadManager.reload(Example.class);
```## Registerable reloadables
* Any classes that implement Reloadable
* Any no args and returns ReloadResult static Method## Get summary
SimpleReloadLib offers a Map contains ReloadContainer and ReloadResults:
* SUCCESS - Successfully to reloading.
* OUTDATED - WeakReferenced object already invalid and will be removed in next reload.
* REQUIRE_RESTART - Reload is impossible, restart required.
* SCHEDULED - Cannot reload in this time but already scheduled reloading if possible.
* EXCEPTION - Something just exploded## Maven
We're in central.
```xml
com.ghostchu
simplereloadlib
1.1.2
```## License
MIT