-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(custom-events): revamp events system, introduce custom events (h…
…and interactions) Bump version to 1.0.19 Add CustomTwilightListener for custom event listeners and ease of unregistering on Twilight termination Added optional use said termination for plugin shutdown or other use-case to handle Twilight clean-up
- Loading branch information
Showing
11 changed files
with
201 additions
and
144 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ plugins { | |
} | ||
|
||
group = "gg.flyte" | ||
version = "1.0.18" | ||
version = "1.0.19" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
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
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
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
src/main/kotlin/gg/flyte/twilight/event/custom/PlayerMainHandInteractEvent.kt
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
src/main/kotlin/gg/flyte/twilight/event/custom/PlayerOffHandInteractEvent.kt
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/gg/flyte/twilight/event/custom/interact/PlayerMainHandInteractEvent.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,29 @@ | ||
package gg.flyte.twilight.event.custom.interact | ||
|
||
import gg.flyte.twilight.event.TwilightEvent | ||
import org.bukkit.block.Block | ||
import org.bukkit.block.BlockFace | ||
import org.bukkit.entity.Player | ||
import org.bukkit.event.block.Action | ||
import org.bukkit.event.player.PlayerInteractEvent | ||
import org.bukkit.inventory.ItemStack | ||
import org.bukkit.util.Vector | ||
|
||
/** | ||
* Represents an event where a player interacts with an item in their main-hand. | ||
* | ||
* @param player The Player who triggered the event. | ||
* @param action The action performed by the player (e.g., LEFT_CLICK_AIR, RIGHT_CLICK_BLOCK). | ||
* @param item The ItemStack in the player's off-hand. | ||
* @param clickedBlock The Block that was clicked, if applicable. | ||
* @param clickedFace The face of the clicked block, if applicable. | ||
* @param clickedPosition The position where the player clicked, if applicable. | ||
*/ | ||
class PlayerMainHandInteractEvent( | ||
val player: Player, | ||
val action: Action, | ||
val item: ItemStack?, | ||
val clickedBlock: Block?, | ||
val clickedFace: BlockFace, | ||
val clickedPosition: Vector? | ||
) : TwilightEvent() |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/gg/flyte/twilight/event/custom/interact/PlayerOffHandInteractEvent.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,28 @@ | ||
package gg.flyte.twilight.event.custom.interact | ||
|
||
import gg.flyte.twilight.event.TwilightEvent | ||
import org.bukkit.block.Block | ||
import org.bukkit.block.BlockFace | ||
import org.bukkit.entity.Player | ||
import org.bukkit.event.block.Action | ||
import org.bukkit.inventory.ItemStack | ||
import org.bukkit.util.Vector | ||
|
||
/** | ||
* Represents an event where a player interacts with an item in their off-hand. | ||
* | ||
* @param player The Player who triggered the event. | ||
* @param action The action performed by the player (e.g., LEFT_CLICK_AIR, RIGHT_CLICK_BLOCK). | ||
* @param item The ItemStack in the player's off-hand. | ||
* @param clickedBlock The Block that was clicked, if applicable. | ||
* @param clickedFace The face of the clicked block, if applicable. | ||
* @param clickedPosition The position where the player clicked, if applicable. | ||
*/ | ||
class PlayerOffHandInteractEvent( | ||
val player: Player, | ||
val action: Action, | ||
val item: ItemStack?, | ||
val clickedBlock: Block?, | ||
val clickedFace: BlockFace, | ||
val clickedPosition: Vector? | ||
) : TwilightEvent() |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/gg/flyte/twilight/event/custom/interact/listener/InteractEventListener.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,24 @@ | ||
package gg.flyte.twilight.event.custom.interact.listener | ||
|
||
import gg.flyte.twilight.Twilight | ||
import gg.flyte.twilight.event.CustomTwilightListener | ||
import gg.flyte.twilight.event.custom.interact.PlayerMainHandInteractEvent | ||
import gg.flyte.twilight.event.custom.interact.PlayerOffHandInteractEvent | ||
import gg.flyte.twilight.event.event | ||
import org.bukkit.event.player.PlayerInteractEvent | ||
import org.bukkit.inventory.EquipmentSlot | ||
|
||
object InteractEventListener : CustomTwilightListener() { | ||
|
||
init { | ||
events += event<PlayerInteractEvent>(ignoreCancelled = true) { | ||
Twilight.plugin.server.pluginManager.callEvent( | ||
if (hand == EquipmentSlot.HAND) | ||
PlayerMainHandInteractEvent(player, action, item, clickedBlock, blockFace, clickedPosition) | ||
else | ||
PlayerOffHandInteractEvent(player, action, item, clickedBlock, blockFace, clickedPosition) | ||
) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.