Skip to content

Commit

Permalink
Adds the EndermanAttackPlayer event to skript (#6596)
Browse files Browse the repository at this point in the history
* Adds the EndermanAttackPlayer event to skript

* Remove version from required plugins

Co-authored-by: sovdee <[email protected]>

* Simplify event description

Co-authored-by: sovdee <[email protected]>

* Remove redundant event-value registration

Co-authored-by: Patrick Miller <[email protected]>

---------

Co-authored-by: sovdee <[email protected]>
Co-authored-by: Moderocky <[email protected]>
Co-authored-by: Patrick Miller <[email protected]>
  • Loading branch information
4 people authored Jun 28, 2024
1 parent 39acfe3 commit df620e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import ch.njol.skript.util.slot.InventorySlot;
import ch.njol.skript.util.slot.Slot;
import com.destroystokyo.paper.event.block.AnvilDamagedEvent;
import com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent;
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
import io.papermc.paper.event.entity.EntityMoveEvent;
Expand Down Expand Up @@ -691,6 +692,15 @@ public Entity get(LightningStrikeEvent event) {
return event.getLightning();
}
}, 0);
// EndermanAttackPlayerEvent
if (Skript.classExists("com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent")) {
EventValues.registerEventValue(EndermanAttackPlayerEvent.class, Player.class, new Getter<Player, EndermanAttackPlayerEvent>() {
@Override
public Player get(EndermanAttackPlayerEvent event) {
return event.getPlayer();
}
}, EventValues.TIME_NOW);
}

// --- PlayerEvents ---
EventValues.registerEventValue(PlayerEvent.class, Player.class, new Getter<Player, PlayerEvent>() {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/ch/njol/skript/events/SimpleEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,22 @@ public class SimpleEvents {
.since("INSERT VERSION")
.requiredPlugins("Spigot 1.19.4+");
}

if (Skript.classExists("com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent")) {
Skript.registerEvent("Enderman Enrage", SimpleEvent.class, com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent.class, "enderman (enrage|anger)")
.description(
"Called when an enderman gets mad because a player looked at them.",
"Note: This does not stop enderman from targeting the player as a result of getting damaged."
)
.examples(
"# Stops endermen from getting angry players with the permission \"safeFrom.enderman\"",
"on enderman enrage:",
"\tif player has permission \"safeFrom.enderman\":",
"\t\tcancel event"
)
.since("INSERT VERSION")
.requiredPlugins("Paper");
}
}

}

0 comments on commit df620e4

Please sign in to comment.