Skip to content

Commit

Permalink
Add "on entity shoots arrow" event for bows. Try "-determine projecti…
Browse files Browse the repository at this point in the history
…le:pig"
  • Loading branch information
Morphan1 committed Jul 29, 2013
1 parent eb0439a commit e7af77e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Expand Up @@ -9,10 +9,8 @@
import net.aufdemrand.denizen.objects.aH;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dList;
import net.aufdemrand.denizen.objects.aH.ArgumentType;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.debugging.dB.Messages;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

Expand Down Expand Up @@ -64,7 +62,7 @@
* - NARRATE 'You can see through the night!' <br>
* </ol></tt>
*
* @author aufdemrand, Jeebiss
* @author aufdemrand, Jeebiss, Morphan1
*
*/
public class CastCommand extends AbstractCommand{
Expand Down
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
Expand All @@ -40,6 +41,7 @@
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
Expand Down Expand Up @@ -704,6 +706,28 @@ else if (entity instanceof Player) {
event.setAmount(aH.getDoubleFrom(determination));
}

@EventHandler
public void entityShootBow(EntityShootBowEvent event) {

Map<String, Object> context = new HashMap<String, Object>();
Entity entity = event.getEntity();
context.put("entity", new dEntity(entity));

String determination = doEvents(Arrays.asList
("entity shoots arrow",
entity.getType().name() + " shoots arrow"),
null, null, context);

if (determination.toUpperCase().startsWith("PROJECTILE")) {
Entity replaced = entity.getWorld().spawnEntity(entity.getLocation(), EntityType.valueOf(aH.getStringFrom(determination)));
event.setProjectile(replaced);
}

if (determination.toUpperCase().startsWith("CANCELLED"))
event.setCancelled(true);

}

@EventHandler
public void entityTame(EntityTameEvent event) {

Expand Down

0 comments on commit e7af77e

Please sign in to comment.