-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from DevScyu/sync-event
Add cancellable sync event
- Loading branch information
Showing
2 changed files
with
83 additions
and
46 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/derongan/minecraft/deeperworld/event/BlockSyncEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.derongan.minecraft.deeperworld.event | ||
|
||
import org.bukkit.block.Block | ||
import org.bukkit.event.Cancellable | ||
import org.bukkit.event.HandlerList | ||
import org.bukkit.event.block.BlockEvent | ||
|
||
class BlockSyncEvent( | ||
block: Block, | ||
type: SyncType | ||
) : BlockEvent(block), Cancellable { | ||
private var cancelled = false | ||
|
||
override fun isCancelled() = cancelled | ||
|
||
override fun setCancelled(cancel: Boolean) { | ||
cancelled = cancel | ||
} | ||
|
||
override fun getHandlers() = handlerList | ||
|
||
companion object { | ||
@JvmStatic | ||
val handlerList = HandlerList() | ||
} | ||
} | ||
|
||
enum class SyncType { | ||
PLACE, | ||
BREAK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters