Package valorless.rarespawns.events
Class SoulEvent
java.lang.Object
valorless.rarespawns.events.SoulEvent
- All Implemented Interfaces:
org.bukkit.event.Listener
Bukkit event listener that enables "soulstone" items from the RareSpawns plugin
to spawn entities when a player right-clicks a block with the item in their main hand.
Behavior summary:
- Respects protection hooks: WorldGuard (build permission) and GriefPrevention (claim trust: "Build").
- Ignores cancelled interactions and off-hand clicks.
- If the held item is a registered RareSpawns item with a soulstone definition, calculates a spawn
location relative to the clicked block face, attempts to spawn a vanilla entity type if available,
otherwise falls back to spawning a configured rare entity.
- Consumes one item from the stack in non-creative modes and optionally plays a configured sound effect.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinit()Registers the SoulEvent listener with the Bukkit plugin manager.voidonPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) Handles right-click-on-block interactions using the player's main hand.
-
Constructor Details
-
SoulEvent
public SoulEvent()
-
-
Method Details
-
init
public static void init()Registers the SoulEvent listener with the Bukkit plugin manager. -
onPlayerInteract
public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) Handles right-click-on-block interactions using the player's main hand. Gatekeeping: - Off-hand clicks are ignored. - If WorldGuard is hooked and the player cannot build, the event is ignored. - If GriefPrevention is hooked and the player lacks "Build" trust in the claim, the event is ignored. - If the interaction is already cancelled, it is ignored. Soulstone handling: - Verifies the held item is a RareSpawns item, resolves its ID and ItemData. - When ItemData.soulstone is present, computes a spawn Location based on the clicked block face. - Tries to spawn a vanilla EntityType matching the soulstone; on failure, spawns a rare entity via EntityCreator. - Consumes one item unless the player is in CREATIVE. - Plays the configured soulstone sound, if any.- Parameters:
event- the player interaction event
-