From 7f8dda4375a0172ef7f0041d8f45870d1e05cb9c Mon Sep 17 00:00:00 2001 From: Koponya Date: Wed, 13 Feb 2013 07:04:32 +0100 Subject: [PATCH] edit to use instanceof, not try --- .../explodingarrows/ExplodingArrows.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/explodingarrows/src/com/gmail/goodfaceforradio/explodingarrows/ExplodingArrows.java b/explodingarrows/src/com/gmail/goodfaceforradio/explodingarrows/ExplodingArrows.java index 4eb17da..b854f3e 100644 --- a/explodingarrows/src/com/gmail/goodfaceforradio/explodingarrows/ExplodingArrows.java +++ b/explodingarrows/src/com/gmail/goodfaceforradio/explodingarrows/ExplodingArrows.java @@ -53,18 +53,17 @@ public void onProjectileHit(ProjectileHitEvent event) { Player player; // Only interested in arrows. - try { - arrow = (Arrow) projectile; - } catch (ClassCastException e) { + if(!(projectile instanceof Arrow)) { return; } + + arrow = (Arrow) projectile; // Only interested in players shooting. - try { - player = (Player) arrow.getShooter(); - } catch (ClassCastException e) { + if(!(arrow.getShooter() instanceof Player)) { return; } + player = (Player) arrow.getShooter(); // Player needs to have one or more blaze rods in inventory to // get exploding arrows. @@ -105,4 +104,4 @@ public void onPlayerUse(PlayerInteractEvent event){ this.bGrantedArrow = 1; } } -} \ No newline at end of file +}