Search in sources :

Example 1 with Npc

use of com.rs.entity.npc.Npc in project runesource by PureCS.

the class WorldHandler method tick.

/**
     * Performs the processing of all world functions.
     */
public void tick() throws Exception {
    // Perform any logic processing for players.
    for (Player player : players) {
        if (player == null) {
            continue;
        }
        try {
            player.tick();
        } catch (Exception ex) {
            ex.printStackTrace();
            player.disconnect();
        }
    }
    // Perform any logic processing for NPCs.
    for (Npc npc : npcs) {
        if (npc == null) {
            continue;
        }
        try {
            npc.tick();
        } catch (Exception ex) {
            ex.printStackTrace();
            unregister(npc);
        }
    }
    // Process all plugins.
    PluginHandler.tick();
    // Process all tasks
    TaskHandler.tick();
    // Update all players.
    for (Player player : players) {
        if (player == null) {
            continue;
        }
        try {
            PlayerUpdating.update(player);
            NpcUpdating.update(player);
        } catch (Exception ex) {
            ex.printStackTrace();
            player.disconnect();
        }
    }
    // Reset all players after tick.
    for (Player player : players) {
        if (player == null) {
            continue;
        }
        try {
            player.reset();
        } catch (Exception ex) {
            ex.printStackTrace();
            player.disconnect();
        }
    }
    // Reset all NPCs after tick.
    for (Npc npc : npcs) {
        if (npc == null) {
            continue;
        }
        try {
            npc.reset();
        } catch (Exception ex) {
            ex.printStackTrace();
            unregister(npc);
        }
    }
}
Also used : Npc(com.rs.entity.npc.Npc) Player(com.rs.entity.player.Player)

Aggregations

Npc (com.rs.entity.npc.Npc)1 Player (com.rs.entity.player.Player)1