Class CustomCrafterAPIPropertiesChangeEvent
-
- All Implemented Interfaces:
public final class CustomCrafterAPIPropertiesChangeEvent<T extends Object> extends Event
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.BASE_BLOCK; if (!event.getPropertyName().equals(baseKey.getName())) { return; } Material baseTypeOld = event.getOldValue().getOrNull(baseKey); if (baseTypeOld == null) { return; } CustomCrafterAPI.setBaseBlock(baseTypeOld); System.out.println("I rejected new setting... Hahaha!!!"); } }- Since:
5.0.11
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classCustomCrafterAPIPropertiesChangeEvent.PropertyA value of CustomCrafterAPI property.
Tis a type of instance contains value.public final classCustomCrafterAPIPropertiesChangeEvent.PropertyKeyKey of
Property<T>
-
Field Summary
Fields Modifier and Type Field Description public final static HandlerListHANDLER_LISTprivate final StringpropertyNameprivate final CustomCrafterAPIPropertiesChangeEvent.Property<T>oldValueprivate final CustomCrafterAPIPropertiesChangeEvent.Property<T>newValueprivate final BooleanisAsynchronousprivate final HandlerListhandlersprivate final StringeventName
-
Constructor Summary
Constructors Constructor Description CustomCrafterAPIPropertiesChangeEvent(String propertyName, CustomCrafterAPIPropertiesChangeEvent.Property<T> oldValue, CustomCrafterAPIPropertiesChangeEvent.Property<T> newValue, Boolean isAsync)
-
Method Summary
Modifier and Type Method Description final StringgetPropertyName()final CustomCrafterAPIPropertiesChangeEvent.Property<T>getOldValue()final CustomCrafterAPIPropertiesChangeEvent.Property<T>getNewValue()HandlerListgetHandlers()final static HandlerListgetHandlerList()-
Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous -
Methods inherited from class io.github.sakaki_aruka.customcrafter.event.CustomCrafterAPIPropertiesChangeEvent
getHandlers -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
CustomCrafterAPIPropertiesChangeEvent
CustomCrafterAPIPropertiesChangeEvent(String propertyName, CustomCrafterAPIPropertiesChangeEvent.Property<T> oldValue, CustomCrafterAPIPropertiesChangeEvent.Property<T> newValue, Boolean isAsync)
- Parameters:
propertyName- Name of propertyoldValue- An old valuenewValue- A new value
-
-
Method Detail
-
getPropertyName
final String getPropertyName()
-
getOldValue
final CustomCrafterAPIPropertiesChangeEvent.Property<T> getOldValue()
-
getNewValue
final CustomCrafterAPIPropertiesChangeEvent.Property<T> getNewValue()
-
getHandlers
HandlerList getHandlers()
-
getHandlerList
final static HandlerList getHandlerList()
-
-
-
-