use of com.laytonsmith.abstraction.events.MCRedstoneChangedEvent in project CommandHelper by EngineHub.
the class BukkitServerListener method onBlockPhysics.
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
Map<MCLocation, Boolean> locations = ServerEvents.getRedstoneMonitors();
if (locations.isEmpty()) {
// Bail as quickly as we can if this isn't being used.
return;
}
final MCLocation blockLocation = new BukkitMCLocation(event.getBlock().getLocation());
if (locations.containsKey(blockLocation)) {
// This is a monitored location, so we will be triggering the event.
boolean wasPowered = locations.get(blockLocation);
final boolean isPowered = blockLocation.getBlock().isBlockPowered();
if (wasPowered != isPowered) {
// It was changed, so set the state appropriately now.
locations.put(blockLocation, isPowered);
EventUtils.TriggerListener(Driver.REDSTONE_CHANGED, "redstone_changed", new MCRedstoneChangedEvent() {
@Override
public boolean isActive() {
return isPowered;
}
@Override
public MCLocation getLocation() {
return blockLocation;
}
@Override
public Object _GetObject() {
return null;
}
});
}
}
}
Aggregations