コード例 #1
0
 public boolean apply(SpellTargetEvent event) {
   Player player = event.getCaster();
   boolean check = condition.check(player, event.getTarget());
   if (check == false && type == ModifierType.REQUIRED) {
     event.setCancelled(true);
     return false;
   } else if (check == true && type == ModifierType.DENIED) {
     event.setCancelled(true);
     return false;
   } else if (check == true && type == ModifierType.STOP) {
     return false;
   } else if (check == false && type == ModifierType.CONTINUE) {
     return false;
   } else if (check == true && type == ModifierType.CAST) {
     Spell spell = MagicSpells.getSpellByInternalName(modifierVar);
     if (spell != null) {
       spell.cast(event.getCaster(), 1, null);
     }
   } else if (check == true && type == ModifierType.CAST_INSTEAD) {
     Spell spell = MagicSpells.getSpellByInternalName(modifierVar);
     if (spell != null) {
       if (spell instanceof TargetedEntitySpell) {
         ((TargetedEntitySpell) spell).castAtEntity(event.getCaster(), event.getTarget(), 1F);
       } else {
         spell.castSpell(event.getCaster(), SpellCastState.NORMAL, 1F, null);
       }
     }
   }
   return true;
 }
コード例 #2
0
 public boolean apply(ManaChangeEvent event) {
   Player player = event.getPlayer();
   boolean check = condition.check(player);
   if (check == false && type == ModifierType.REQUIRED) {
     event.setNewAmount(event.getOldAmount());
     return false;
   } else if (check == true && type == ModifierType.DENIED) {
     event.setNewAmount(event.getOldAmount());
     return false;
   } else if (check == true && type == ModifierType.STOP) {
     return false;
   } else if (check == false && type == ModifierType.CONTINUE) {
     return false;
   } else if (check == true && type == ModifierType.POWER) {
     int gain = event.getNewAmount() - event.getOldAmount();
     gain = Math.round(gain * modifierVarFloat);
     int newAmt = event.getOldAmount() + gain;
     if (newAmt > event.getMaxMana()) newAmt = event.getMaxMana();
     event.setNewAmount(newAmt);
   } else if (check == true && type == ModifierType.ADD_POWER) {
     int newAmt = event.getNewAmount() + (int) modifierVarFloat;
     if (newAmt > event.getMaxMana()) newAmt = event.getMaxMana();
     event.setNewAmount(newAmt);
   } else if (check == true && (type == ModifierType.CAST || type == ModifierType.CAST_INSTEAD)) {
     Spell spell = MagicSpells.getSpellByInternalName(modifierVar);
     if (spell != null) {
       spell.cast(event.getPlayer(), 1, null);
     }
   }
   return true;
 }
コード例 #3
0
 public boolean apply(SpellCastEvent event) {
   Player player = event.getCaster();
   boolean check = condition.check(player);
   if (check == false && type == ModifierType.REQUIRED) {
     event.setCancelled(true);
     return false;
   } else if (check == true && type == ModifierType.DENIED) {
     event.setCancelled(true);
     return false;
   } else if (check == true) {
     if (type == ModifierType.STOP) {
       return false;
     } else if (type == ModifierType.POWER) {
       event.increasePower(modifierVarFloat);
     } else if (type == ModifierType.ADD_POWER) {
       event.setPower(event.getPower() + modifierVarFloat);
     } else if (type == ModifierType.COOLDOWN) {
       event.setCooldown(modifierVarFloat);
     } else if (type == ModifierType.REAGENTS) {
       event.setReagents(event.getReagents().multiply(modifierVarFloat));
     } else if (type == ModifierType.CAST_TIME) {
       event.setCastTime(modifierVarInt);
     }
   } else if (check == false && type == ModifierType.CONTINUE) {
     return false;
   } else if (check == true && type == ModifierType.CAST) {
     Spell spell = MagicSpells.getSpellByInternalName(modifierVar);
     if (spell != null) {
       spell.cast(event.getCaster(), event.getPower(), event.getSpellArgs());
     }
   } else if (check == true && type == ModifierType.CAST_INSTEAD) {
     Spell spell = MagicSpells.getSpellByInternalName(modifierVar);
     if (spell != null) {
       spell.cast(event.getCaster(), event.getPower(), event.getSpellArgs());
     }
     event.setCancelled(true);
   }
   return true;
 }