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
Add Paper Only TargetHitScriptEvent #2604
base: dev
Are you sure you want to change the base?
Conversation
public void onProjectileHit(TargetHitEvent event) { | ||
this.event = event; | ||
projectile = new EntityTag(event.getEntity()); | ||
|
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.
stray newlines
if (projectile.getLocation() == null) { | ||
return; | ||
} | ||
if (Double.isNaN(projectile.getLocation().getDirection().normalize().getX())) { |
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.
This is clearly copypasted from the projectile hit event - is it even relevant to have here?
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.
Relatedly - is this actually a unique event? ie is it not already covered by the existing projectile hit event?
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.
Glance at source code public class TargetHitEvent extends ProjectileHitEvent
indicates it's not unique
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.
I don't see a reason why this should be needed. I copied it from the ProjectileHitEvent. In paper the Location of an entity is marked with @NotNull so I removed those checks
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.
Glance at source code
public class TargetHitEvent extends ProjectileHitEvent
indicates it's not unique
It has a different HandlerList so it's a different event
import org.bukkit.event.Listener; | ||
|
||
|
||
public class TargetHitScriptEvent extends BukkitScriptEvent implements Listener { |
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.
classname should match the Denizen name not the paper name - ie TargetBlockHitScriptEvent
|
||
@Override | ||
public boolean couldMatch(ScriptPath path) { | ||
return path.eventLower.matches("targetblock hit"); |
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.
This is the legacy couldMatch handling, should use the modern register handling
paper/src/main/java/com/denizenscript/denizen/paper/events/TargetBlockHitScriptEvent.java
Show resolved
Hide resolved
projectile = new EntityTag(event.getEntity()); | ||
hitBlock = new LocationTag(event.getHitBlock().getLocation()); | ||
shooter = projectile.getShooter(); | ||
strength = new ElementTag(event.getSignalStrength()); |
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.
This doesn't need to be read in advance, should just be in the getContext call
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.
I moved the Strengh attribute to the getContext call. The other Tags are used in other methods. If you want to move them too I would have to create new Tags every call.
10973ad
to
aeb41cf
Compare
Sorry for the delay of this PR. I rebased this PR and applied all PR comments |
Why the rebase? |
// @Context | ||
// <context.projectile> returns an EntityTag of the projectile. | ||
// <context.shooter> returns a EntityTag of the shooter of the projectile. | ||
// <context.hit_block> returns a LocationTag of the block |
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.
Needs periods at end of line
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.
... oh and, for that matter, the rest of the text lol.
Force of habit |
// <context.projectile> returns an EntityTag of the projectile. | ||
// <context.shooter> returns a EntityTag of the shooter of the projectile. | ||
// <context.hit_block> returns a LocationTag of the block. | ||
// <context.hit_face> returns a LocationTag of the face. |
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.
These were copied from the projectile hits
event, but cut short -- should probably just restore the full text from the other events docs into here
|
||
// <--[event] | ||
// @Events | ||
// targetblock hit |
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.
Event name should have a space (target block hit
)
Add the Event from Paper when a Target block is hit by an arrow to Denizen.