예제 #1
0
 /**
  * Prioritized event notification - Ensuring that this listener will be the first to receive
  * notification.<br>
  * Also this method interrupts notification to other listeners and taking over return if somehow
  * it wasn't the first one to set.<br>
  * This method will be invoked as soon a a creature dies.<br>
  * This listener is registered into global players container.
  *
  * @param event
  * @return termination return preventing the base code execution if needed.
  */
 @RegisterEvent(EventType.ON_CREATURE_KILL)
 @RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
 @Priority(Integer.MAX_VALUE)
 public TerminateReturn onPlayerDeath(OnCreatureKill event) {
   if (event.getTarget().isGM()) {
     _log.log(
         Level.INFO,
         getClass().getSimpleName()
             + ": Player: "
             + event.getTarget()
             + " was prevented from dying!");
     return new TerminateReturn(true, true, true);
   }
   return null;
 }
예제 #2
0
 // Annotation listener registration
 @RegisterEvent(EventType.ON_CREATURE_KILL)
 @RegisterType(ListenerRegisterType.NPC)
 @Id(20432)
 @Id(22228)
 public void onCreatureKill(OnCreatureKill event) {
   _log.log(
       Level.INFO,
       getClass().getSimpleName()
           + ": "
           + event.getClass().getSimpleName()
           + " invoked attacker: "
           + event.getAttacker()
           + " target: "
           + event.getTarget());
 }
예제 #3
0
  /**
   * Prioritized event notification <br>
   * This method will be invoked as soon as creature from level range between 1 and 10 dies.<br>
   * This listener is registered into individual npcs container.
   *
   * @param event
   */
  @RegisterEvent(EventType.ON_CREATURE_KILL)
  @RegisterType(ListenerRegisterType.NPC)
  @NpcLevelRange(from = 1, to = 10)
  @Priority(100)
  public void OnCreatureKill(OnCreatureKill event) {
    // 70% chance to drop
    if (Rnd.get(100) >= 70) {
      return;
    }

    // Make sure a player killed this monster.
    if ((event.getAttacker() != null)
        && event.getAttacker().isPlayable()
        && event.getTarget().isAttackable()) {
      final L2Attackable monster = (L2Attackable) event.getTarget();
      monster.dropItem(
          event.getAttacker().getActingPlayer(), new ItemHolder(57, Rnd.get(100, 1000)));
    }
  }