Skip to content

Commit

Permalink
Add dLocation-type <context.source> tag + code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MusicScore committed Nov 11, 2018
1 parent bc805f7 commit 2d30dc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Expand Up @@ -3,6 +3,7 @@
import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.Duration;
import net.aufdemrand.denizencore.objects.Element;
Expand All @@ -12,6 +13,7 @@
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustByBlockEvent;
Expand All @@ -34,7 +36,7 @@ public class EntityCombustsScriptEvent extends BukkitScriptEvent implements List
// @Context
// <context.entity> returns the entity that caught fire.
// <context.duration> returns the length of the burn.
// <context.source> returns the dEntity that caused the fire, if any. NOTE: If the source is a location, just use <context.entity.location> or <context.entity.location.above>
// <context.source> returns the dEntity or dLocation that caused the fire, if any. NOTE: Currently, if the source is a dLocation, the tag will return a null. It is expected that this will be fixed by Spigot in the future.
// <context.source_type> returns the type of the source, which can be: ENTITY, LOCATION, NONE.
//
// @Determine
Expand Down Expand Up @@ -117,6 +119,12 @@ else if (name.equals("source")) {
if (event instanceof EntityCombustByEntityEvent) {
return new dEntity(((EntityCombustByEntityEvent) event).getCombuster());
}
else if (event instanceof EntityCombustByBlockEvent) {
Block combuster = ((EntityCombustByBlockEvent) event).getCombuster();
if (combuster != null) {
return new dLocation(combuster.getLocation());
}
}
}
else if (name.equals("source_type")) {
if (event instanceof EntityCombustByEntityEvent) {
Expand Down
Expand Up @@ -6,6 +6,7 @@
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.tags.Attribute;
import org.bukkit.Location;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.EntityType;

Expand Down Expand Up @@ -68,9 +69,9 @@ public String getAttribute(Attribute attribute) {
// Returns the target location of the ender crystal's beam, if any.
// -->
if (attribute.startsWith("beam_target")) {
if (((EnderCrystal) dentity.getBukkitEntity()).getBeamTarget() != null) {
return new dLocation(((EnderCrystal) dentity.getBukkitEntity()).getBeamTarget())
.getAttribute(attribute.fulfill(1));
Location beamTarget = ((EnderCrystal) dentity.getBukkitEntity()).getBeamTarget();
if (beamTarget != null) {
return new dLocation(beamTarget).getAttribute(attribute.fulfill(1));
}
}

Expand Down

0 comments on commit 2d30dc5

Please sign in to comment.