@Override
	public void run() {
		Logger logger = BukkitCLI.getPlugin().getLogger();
		if (command == null) {
			logger.warning("Unable to execute command. Cannot be null.");
			return;
		}
		try {
			Process p;
			if(dir == null) {
				p = runtime.exec(command);
			} else {
				p = runtime.exec(command, null, dir);
			}
			int exitCode = p.waitFor();
			if (callback != null) {
				callback.onExecute(exitCode,readFromStream(p.getInputStream()), readFromStream(p.getErrorStream()));
			} else if (exitCode != 0) {
				logger.warning(String.format("Failed to execute '%s'. Exit code: %d", command, exitCode));
			}
			return;
		} catch (IOException e) {
			onError(e, String.format("Unable to execute '%s'. %s: %s", command, e.getClass().getSimpleName(), e.getMessage()));
		} catch (IllegalArgumentException e) {
			onError(e, "Unable to execute command. Cannot be empty.");
		} catch (InterruptedException e) {
			onError(e, "Interrupted while waiting for process to end.");
		}
	}