Ejemplo n.º 1
0
 /**
  * Fires the 'On Spawn:' action in an NPCs Assignment, if set.
  *
  * @param event NPCSpawnEvent
  */
 @EventHandler
 public void onSpawn(NPCSpawnEvent event) {
   _registerNPC(event.getNPC());
   // Do world script event 'On NPC spawns'
   OldEventManager.doEvents(
       Arrays.asList("npc spawns"),
       new BukkitScriptEntryData(null, dNPC.mirrorCitizensNPC(event.getNPC())),
       null);
   // On Spawn action
   getDenizen(event.getNPC()).action("spawn", null);
 }
Ejemplo n.º 2
0
  /**
   * Fires a world script event and then NPC action when the NPC despawns.
   *
   * @param event NPCDespawnEvent
   */
  @EventHandler
  public void despawn(NPCDespawnEvent event) {
    dNPC npc = getDenizen(event.getNPC().getId());

    // Do world script event 'On NPC Despawns'
    if (npc != null) {
      OldEventManager.doEvents(
          Arrays.asList("npc despawns"), new BukkitScriptEntryData(null, npc), null);
    }

    if (npc != null) {
      npc.action("despawn", null);
    }
  }
  // <--[event]
  // @Events
  // votifier vote
  // @Triggers when a Votifier vote is made.
  // @Context
  // <context.time> returns the time the vote was sent.
  // <context.service> returns what service was used to send the vote.
  // <context.username> returns the username input with the vote.
  // @Plugin Depenizen, Votifier
  // -->
  @EventHandler
  public void onVotifierEvent(VotifierEvent event) {

    Map<String, dObject> context = new HashMap<String, dObject>();
    Vote vote = event.getVote();

    context.put("time", new Element(vote.getTimeStamp()));
    context.put("service", new Element(vote.getServiceName()));
    context.put("username", new Element(vote.getUsername()));

    OldEventManager.doEvents(
        Arrays.asList("votifier vote"),
        new BukkitScriptEntryData(dPlayer.valueOf(vote.getUsername()), null),
        context);
  }