All pastes #430847 Raw Edit

Stuff

public java v1 · immutable
·published 2007-04-09 09:54 UTC
rendered paste body
import java.io.IOException;import java.util.Hashtable;public class InputHandler {	/**	 * Instance of the main method	 */	private UserHandler userHandler;	/**	 * The connection handler	 */	private ConnectionHandler connection;	private Join join;	private Ban ban;	private Mute mute;	private Part part;	private Quit quit;	private Say say;	private TempBan tempBan;	private TempMute tempMute;	private Hashtable<String, Object> handlerTable;	/**	 * CommandHandler constructor	 */	public InputHandler(ConnectionHandler connection) {		this.connection = connection;		userHandler = connection.getUserHandler();		setHandlers();	}	/**	 * Parses strings that don't contain commands	 * Used to protect users from being deopped, banned, etc	 */	public void parseString(String input) {		System.out.println("String parsing works");	}	/**	 * Processes the string with the command passed from the BotEngine class instance	 */	public void checkUser(String input) {		String[] parts = input.split(" ");		String[] hostName = parts[0].split("@");		try {			User commandUser = userHandler.getUser(hostName[1]);			if(commandUser != null) {				//Object handler = new Object(handlerTable.get(parts[3].substring(2)));				if(handler != null) {					handler.handleCommand(commandUser, input.substring(input.indexOf(" :" + Main.CMD_PREFIX) + 3), parts[2]);				}				//processCommand(commandUser, input.substring(input.indexOf(" :" + Main.CMD_PREFIX) + 3), parts[2]);			}		} catch(Exception e) {			e.printStackTrace();		}	}	private void setHandlers() {		join = new Join(this);		ban = new Ban(this);		mute = new Mute(this);		part = new Part(this);		quit = new Quit(this);		say = new Say(this);		tempBan = new TempBan(this);		tempMute = new TempMute(this);		handlerTable = new Hashtable<String, Object>(15);		handlerTable.put("join", join);		handlerTable.put("ban", ban);		handlerTable.put("unban", ban);		handlerTable.put("mute", mute);		handlerTable.put("unmute", mute);		handlerTable.put("part", part);		handlerTable.put("quit", quit);		handlerTable.put("say", say);		handlerTable.put("tempban", tempBan);		handlerTable.put("tempmute", tempMute);	}