-
-
Notifications
You must be signed in to change notification settings - Fork 108
Adds the paper-only dragon egg forms
event
#2669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heypr
wants to merge
8
commits into
DenizenScript:dev
Choose a base branch
from
heypr:dragon-egg
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
72ea6b4
Added event
heypr d9fdb5b
Update meta
heypr 768816c
Merge remote-tracking branch 'upstream/dev' into dragon-egg
heypr ad0f5c0
Merge remote-tracking branch 'upstream/dev' into dragon-egg
heypr 828ef11
Merge branch 'dragon-egg' of https://github.com/heypr/Denizen into dr…
heypr 7de57b7
Add new meta entry + context tag
heypr 97a5bfe
Enum constructor
heypr d2816f6
Merge remote-tracking branch 'upstream/dev' into dragon-egg
heypr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
75 changes: 75 additions & 0 deletions
75
paper/src/main/java/com/denizenscript/denizen/paper/events/DragonEggFormScriptEvent.java
This file contains hidden or 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,75 @@ | ||
package com.denizenscript.denizen.paper.events; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.LocationTag; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.core.ListTag; | ||
import io.papermc.paper.event.block.DragonEggFormEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class DragonEggFormScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// dragon egg forms | ||
// | ||
// @Plugin Paper | ||
// | ||
// @Group Paper | ||
// | ||
// @Location true | ||
// | ||
// @Triggers when the ender dragon is defeated and the dragon egg forms. | ||
// | ||
// @Context | ||
// <context.entity> returns the EntityTag of the ender dragon right before it's removed. | ||
// <context.location> returns the LocationTag of the dragon egg. | ||
// <context.end_portal_location> returns the LocationTag of the end portal. | ||
// <context.previously_killed> returns an ElementTag(Boolean) of whether the dragon has been previously killed. | ||
// <context.respawn_phase> returns an ElementTag of the respawn phase. Valid values can be found at <@link url https://jd.papermc.io/paper/1.21.3/org/bukkit/boss/DragonBattle.RespawnPhase.html>. | ||
// <context.healing_crystals> returns a ListTag(EntityTag) of the healing end crystals. | ||
// <context.respawn_crystals> returns a ListTag(EntityTag) of the respawn end crystals. | ||
// | ||
// --> | ||
|
||
public DragonEggFormScriptEvent() { | ||
registerCouldMatcher("dragon egg forms"); | ||
} | ||
|
||
public LocationTag location; | ||
public EntityTag entity; | ||
public DragonEggFormEvent event; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if (!runInCheck(path, location)) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "entity" -> entity; | ||
case "location" -> location; | ||
case "end_portal_location" -> new LocationTag(event.getDragonBattle().getEndPortalLocation()); | ||
case "previously_killed" -> new ElementTag(event.getDragonBattle().hasBeenPreviouslyKilled()); | ||
case "respawn_phase" -> new ElementTag(event.getDragonBattle().getRespawnPhase().name()); | ||
case "healing_crystals" -> new ListTag(event.getDragonBattle().getHealingCrystals(), EntityTag::new); | ||
case "respawn_crystals" -> new ListTag(event.getDragonBattle().getRespawnCrystals(), EntityTag::new); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onDragonEggForms(DragonEggFormEvent event) { | ||
location = new LocationTag(event.getBlock().getLocation()); | ||
entity = new EntityTag(event.getDragonBattle().getEnderDragon()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ref. Discord may need |
||
this.event = event; | ||
fire(event); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ElementTag
enum constructor - otherwise lgtm