Skip to content

Commit

Permalink
Add <context.item> to FireworkBurst event.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fortifier42 committed Mar 6, 2016
1 parent 68cccd8 commit e6c8fb0
Showing 1 changed file with 11 additions and 1 deletion.
Expand Up @@ -2,15 +2,19 @@

import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dItem;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Firework;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.inventory.ItemStack;

public class FireworkBurstsScriptEvent extends BukkitScriptEvent implements Listener {

Expand All @@ -26,6 +30,7 @@ public class FireworkBurstsScriptEvent extends BukkitScriptEvent implements List
//
// @Context
// <context.entity> returns the firework that exploded.
// <context.item> returns the firework item.
// <context.location> returns the dLocation the firework exploded at.
//
// -->
Expand All @@ -35,9 +40,9 @@ public FireworkBurstsScriptEvent() {
}

public static FireworkBurstsScriptEvent instance;
public FireworkExplodeEvent event;
public dEntity entity;
public dLocation location;
public FireworkExplodeEvent event;

@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
Expand Down Expand Up @@ -81,6 +86,11 @@ public dObject getContext(String name) {
else if (name.equals("location")) {
return location;
}
else if (name.equals("item")) {
ItemStack itemStack = new ItemStack(Material.FIREWORK);
itemStack.setItemMeta(event.getEntity().getFireworkMeta());
return new dItem(itemStack);
}
return super.getContext(name);
}

Expand Down

0 comments on commit e6c8fb0

Please sign in to comment.