Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rs2.event;
- import java.util.logging.Logger;
- public abstract class Event {
- /**
- * Logger instance for more detailed printing.
- */
- private static final Logger LOGGER = Logger.getLogger(Event.class.getName());
- /**
- * Checks if the event is running.
- */
- private boolean running;
- /**
- * Method that contains the contents of what we want to execute.
- */
- public abstract void execute();
- /**
- * The name of the running event.
- */
- public abstract String getName();
- /**
- * Initiate the event instance.
- */
- public Event() {
- this.setRunning(true);
- }
- /**
- * Executes the event if the event is suppose to be running.
- *
- * @return If the event is running.
- */
- public boolean tick() {
- if (isRunning()) {
- execute();
- }
- return running;
- }
- /**
- * Stop the event from running.
- */
- public void stop() {
- if (!isRunning()) {
- LOGGER.warning("The event has already stopped!");
- return;
- }
- setRunning(false);
- }
- /**
- * Check if event is running.
- */
- public boolean isRunning() {
- return running;
- }
- /**
- * Set the the true/false state for the running state.
- */
- public boolean setRunning(boolean running) {
- return this.running = running;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment