CustomCrafterAPIPropertiesChangeEvent

Called when CustomCrafterAPI changeable properties changed.

Only changed. When an old value is same with new value, this won't be called this.

(External plugins cannot initialize this instance.)

// Example Code (Safe / Kotlin)
object PropertiesChangeListener: Listener {
@EventHandler
fun <T> CustomCrafterAPIPropertiesChangeEvent<T>.onChange() {
val baseKey = CustomCrafterAPIPropertiesChangeEvent.PropertyKey.BASE_BLOCK
if (this.propertyName != baseKey.name) {
return
}
val baseTypeOld: Material = this.oldValue.getOrNull(baseKey) ?: return
CustomCrafterAPI.setBaseBlock(baseTypeOld)
println("I rejected new setting... Hahaha!!!")
}
}
// Example Code (Safe / Java)
public class PropertiesChangeListener implements Listener {
@EventHandler
public void <T> onChange(CustomCrafterAPIPropertiesChangeEvent<T> event) {
String baseKey = CustomCrafterAPIPropertiesChangeEvent.PropertyKey.Companion.BASE_BLOCK;
if (!event.getPropertyName().equals(baseKey.getName())) {
return;
}
Material baseTypeOld = event.getOldValue().getOrNull(baseKey);
if (baseTypeOld == null) {
return;
}
CustomCrafterAPI.INSTANCE.setBaseBlock(baseTypeOld);
System.out.println("I rejected new setting... Hahaha!!!");
}
}

Since

5.0.11

Parameters

propertyName

Name of property

oldValue

An old value

newValue

A new value

Constructors

Link copied to clipboard
constructor(propertyName: String, oldValue: CustomCrafterAPIPropertiesChangeEvent.Property<T>, newValue: CustomCrafterAPIPropertiesChangeEvent.Property<T>, isAsync: Boolean = false)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Property<T>

A value of CustomCrafterAPI property.

Link copied to clipboard
class PropertyKey<T>

Key of Property<T>

Properties

Link copied to clipboard
@get:NotNull
open val eventName: @NotNull String
Link copied to clipboard
open override val handlers: HandlerList
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun callEvent(): Boolean
Link copied to clipboard
open override fun getHandlers(): HandlerList