Guest User

Untitled

a guest
Feb 19th, 2014
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. package com.rs2.event;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. public abstract class Event {
  6.     /**
  7.      * Logger instance for more detailed printing.
  8.      */
  9.     private static final Logger LOGGER = Logger.getLogger(Event.class.getName());
  10.  
  11.     /**
  12.      * Checks if the event is running.
  13.      */
  14.     private boolean running;
  15.    
  16.     /**
  17.      * Method that contains the contents of what we want to execute.
  18.      */
  19.     public abstract void execute();
  20.  
  21.     /**
  22.      * The name of the running event.
  23.      */
  24.     public abstract String getName();
  25.  
  26.     /**
  27.      * Initiate the event instance.
  28.      */
  29.     public Event() {
  30.         this.setRunning(true);
  31.     }
  32.  
  33.     /**
  34.      * Executes the event if the event is suppose to be running.
  35.      *
  36.      * @return If the event is running.
  37.      */
  38.     public boolean tick() {
  39.         if (isRunning()) {
  40.             execute();
  41.         }
  42.         return running;
  43.     }
  44.  
  45.     /**
  46.      * Stop the event from running.
  47.      */
  48.     public void stop() {
  49.         if (!isRunning()) {
  50.             LOGGER.warning("The event has already stopped!");
  51.             return;
  52.         }
  53.         setRunning(false);
  54.     }
  55.  
  56.     /**
  57.      * Check if event is running.
  58.      */
  59.     public boolean isRunning() {
  60.         return running;
  61.     }
  62.  
  63.     /**
  64.      * Set the the true/false state for the running state.
  65.      */
  66.     public boolean setRunning(boolean running) {
  67.         return this.running = running;
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment