I'm making a try/catch. But is this good? Code:java @EventHandler public void onPlayerDamage(EntityDamageEvent e) {//, final EntityDamageEvent event) { try{ Player p = (Player) e.getEntity(); if (e.getEntity() instanceof Player) { if(e.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)) { //Get the attack cause. for(Entity ent : p.getNearbyEntities(1.5D, 1.5D, 1.5D)) //Check nearby entities for possible damagecause { if((ent instanceof Zombie)) // If it equals to a zombie (almost only close range mob which counts as ENTITY_ATTACK) { p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 30, 1)); //Add the PotionEffect p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10, 1)); //Add the PotionEffect e.setDamage(3.5); } catch(Exception ex){
try/catch blocks are only for things that go wrong outside your range. If-statements should be the general error-checking part. (also performance-wise it's better to use if-statements) Are you aware of what methods could probably lead to unexpected errors and cause an exception?