-
Notifications
You must be signed in to change notification settings - Fork 0
AstraLibs
IAstraManager - Interface for your EventManager classes. You should call onDisable() on plugin reload.
/**
* Handler for all your events
*/
class EventHandler() : IAstraManager {
/**
* Example event
* @see TemplateEvent
*/
private val templateEvent: TemplateEvent = TemplateEvent()
override val handlers: MutableList<IAstraListener> = mutableListOf()
/**
* Every event you declared in EventHandler must have onDisable method and should be called in this onDisable method
*/
public override fun onDisable(){
templateEvent.onDisable()
}
}
IAstraListener - Interface for Event class. You should call onEnable() on init. Also you should implement onDisable(), where you disable all your events.
class TemplateEvent : IAstraListener {
/**
* Sample event which is called when Block is placed
*/
@EventHandler
public fun blockPlaceEvent(e: BlockPlaceEvent) {
return
}
/**
* Here you should add listener to this class
*/
init {
AstraTemplate.
instance.
server.
pluginManager.
registerEvents(this, AstraTemplate.instance)
}
/**
* As said in EventHandler, every Event must have onDisable method, which disabling events
* Here BlockPlaceEvent is unregistering
* @see blockPlaceEvent
* @see EventHandler
*/
public override fun onDisable() {
BlockPlaceEvent.getHandlerList().unregister(this)
}
}
FileManager("config.yml") - this class allows you to load or save any file. If this file exists in your resource folder - it will be taken from resource folder. If it's not - new file will be created.
val config = FileManager("config.yml")
AstraLibs. If you've been using runAsyncTask from AstraLibs, you should call AstraLibs.clearAllTasks() to cancel all tasks.
In onEnable you should call this, so AstraLibs can identify your plugin
override fun onEnable() {
AstraLibs.create(this)
}
AstraUtils contains A LOT of useful fuctions. Best to check it by yourself.
HEX Patterns, catching errors, asyncTasks
HEXPattern(listOf("strings"))
HEXPattern("strings")
"string".HEX()
runAsyncTask{
println("Async thread")
}
catching{
throw java.lang.Exception("Exception")
}