Skip to content

Commit

Permalink
add context.entity to portal created event
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 14, 2019
1 parent 8ff528a commit 3f66ba0
Showing 1 changed file with 7 additions and 1 deletion.
@@ -1,5 +1,7 @@
package com.denizenscript.denizen.events.world;

import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.objects.WorldTag;
import com.denizenscript.denizen.events.BukkitScriptEvent;
Expand Down Expand Up @@ -29,6 +31,7 @@ public class PortalCreateScriptEvent extends BukkitScriptEvent implements Listen
// @Triggers when a portal is created.
//
// @Context
// <context.entity> returns the EntityTag that created the portal.
// <context.world> returns the WorldTag the portal was created in.
// <context.reason> returns an ElementTag of the reason the portal was created. (FIRE or OBC_DESTINATION)
// <context.blocks> returns a ListTag of all the blocks that will become portal blocks.
Expand Down Expand Up @@ -66,7 +69,10 @@ public String getName() {

@Override
public ObjectTag getContext(String name) {
if (name.equals("world")) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_14) && name.equals("entity") && event.getEntity() != null) {
return new EntityTag(event.getEntity());
}
else if (name.equals("world")) {
return new WorldTag(event.getWorld());
}
else if (name.equals("reason")) {
Expand Down

0 comments on commit 3f66ba0

Please sign in to comment.