/*
 * This file is part of DropletRules.
 *
 * Copyright (c) 2013 Spout LLC <http://www.spout.org/>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.spout.droplet.rules.commands;

import java.util.List;

import org.spout.api.command.CommandContext;
import org.spout.api.command.CommandSource;
import org.spout.api.command.annotated.Command;
import org.spout.api.exception.CommandException;
import org.spout.droplet.rules.DropletRules;

public class DropletCommand {
	private final DropletRules plugin;

	public DropletCommand(DropletRules plugin) {
		this.plugin = plugin;
	}

	@Command(aliases = { "ruleset", "rules" }, desc = "Displays the rules")
	public void rules(CommandContext args, CommandSource source) throws CommandException {
		int page = 0;
		if (args.length() > 0) {
			if (args.isInteger(0)) {
				page = args.getInteger(0);
			} else {
				throw new CommandException(args.getString(0) + " is not a valid integer!");
			}
		}
		try {
			List<String> list = plugin.getRules().get(page);
			if (list == null) {
				throw new CommandException("That page doesn't exist!");
			}
			for (String rule : list) {
				source.sendMessage(rule);
			}
			source.sendMessage("To see the next page, do /rules " + (page + 1));
		} catch (NullPointerException e) {
			source.sendMessage("There are no rules on that poge :O");
		}
	}
}

@@ -1980,17 +1980,8 @@
 %09%09%7D%0A
-%09%09try %7B%0A%09
 %09%09Li
@@ -2027,17 +2027,16 @@
 (page);%0A
-%09
 %09%09if (li
@@ -2048,25 +2048,24 @@
  null) %7B%0A%09%09%09
-%09
 throw new Co
@@ -2108,24 +2108,22 @@
 ist!%22);%0A
-%09
 %09%09%7D%0A%09%09
-%09
 for (Str
@@ -2144,17 +2144,16 @@
 t) %7B%0A%09%09%09
-%09
 source.s
@@ -2174,16 +2174,14 @@
 e);%0A
-%09
 %09%09%7D%0A%09%09
-%09
 sour
@@ -2249,110 +2249,8 @@
 ));%0A
-%09%09%7D catch (NullPointerException e) %7B%0A%09%09%09source.sendMessage(%22There are no rules on that poge :O%22);%0A%09%09%7D%0A
 %09%7D%0A%7D

Remove redundant try-catch