SR-Game/src/main/java/me/unurled/sacredrealms/sr/Manager.java
unurled a3fbcbf32a
Some checks failed
Build / build (push) Failing after 56s
Format / formatting (push) Failing after 1m2s
fix: switch to 2.0 invui and translation
2025-06-25 23:18:12 +02:00

52 lines
1.3 KiB
Java

package me.unurled.sacredrealms.sr;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
/** The Manager class is a class that is used to manage data and events. */
public class Manager implements Listener {
/** Create a new manager */
public Manager() {
SR.plugin().managers().addManager(this);
Bukkit.getScheduler()
.runTaskAsynchronously(
SR.plugin(),
() -> {
load();
Bukkit.getPluginManager().registerEvents(this, SR.plugin());
});
}
/**
* Get an instance of a manager
*
* @param clazz The class of the manager
* @return The instance of the manager
* @param <T> The type of the manager
*/
public static <T extends Manager> T getInstance(@NotNull Class<T> clazz) {
return clazz.cast(SR.plugin().managers().getManager(clazz));
}
/** Load the manager */
public void load() {
loadData();
}
/** Unload the manager */
public void unload() {
saveData();
}
/** Save the data */
public void saveData() {
/* method empty, so it isn't required by the extended child to implement it */
}
/** Load the data */
public void loadData() {
/* method empty, so it isn't required by the extended child to implement it */
}
}