Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Description

<!-- Summarize the change and, which issue is fixed. Include relevant motivation and context. -->
<!-- sample: `Closes #100` -->

## How Has This Been Tested?

Expand All @@ -10,18 +10,3 @@
- [ ] Integration tests
- [ ] Manual testing
- [ ] Other (please describe)

## Checklist:

- [ ] Follow style guidelines of this project.
- [ ] Perform self-review of the code.
- [ ] Comment on hard-to-understand areas.
- [ ] Update documentation accordingly.
- [ ] Ensure changes generate no new warnings.
- [ ] Add tests proving the fix is effective, or the feature works.
- [ ] Verify new and existing unit tests pass locally.
- [ ] Ensure dependent changes are merged and published.

## Additional context:

<!-- Add any other context about the PR here. -->
13 changes: 13 additions & 0 deletions src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

package org.xodium.vanillaplus.modules

import org.bukkit.Material
import org.bukkit.entity.*
import org.bukkit.event.EventHandler
import org.bukkit.event.entity.EntityChangeBlockEvent
import org.bukkit.event.entity.EntityDeathEvent
import org.bukkit.event.entity.EntityExplodeEvent
import org.bukkit.inventory.ItemStack
import org.xodium.vanillaplus.interfaces.ModuleInterface
import kotlin.random.Random

/** Represents a module handling entity mechanics within the system. */
internal class EntityModule : ModuleInterface<EntityModule.Config> {
Expand All @@ -24,6 +28,14 @@ internal class EntityModule : ModuleInterface<EntityModule.Config> {
if (shouldCancelGrief(event.entity)) event.blockList().clear()
}

@EventHandler
fun on(event: EntityDeathEvent) {
if (!enabled() || event.entity.killer == null) return
if (Random.nextDouble() <= config.entityEggDropChance) {
event.drops.add(ItemStack.of(Material.matchMaterial("${event.entity.type.name}_SPAWN_EGG") ?: return))
}
}

/**
* Determines whether an entity's griefing behaviour should be cancelled based on configuration settings.
* @param entity The entity whose griefing behaviour is being evaluated.
Expand All @@ -49,5 +61,6 @@ internal class EntityModule : ModuleInterface<EntityModule.Config> {
var disableEndermanGrief: Boolean = true,
var disableGhastGrief: Boolean = true,
var disableWitherGrief: Boolean = true,
var entityEggDropChance: Double = 0.1,
) : ModuleInterface.Config
}
Loading