--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/creative/GeneralContractorCommands.java 2012/03/12 20:08:39 1724 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/creative/GeneralContractorCommands.java 2012/03/12 20:16:29 1725 @@ -62,8 +62,14 @@ } - void slopeArea(Player player, Location loc, String[] args) { - int radius = Integer.parseInt(args[1]); + void slopeArea(Player player, Location loc, String[] split) { + int radius; + try { + radius = Integer.parseInt(split[0]); + } catch (Exception e) { + player.sendMessage("setsurface: radius must be an integer"); + return; + } System.out.println("Player " + player.getName() + " used slopearea with radius=" + radius); @@ -98,7 +104,7 @@ - if (split.length != 3) { + if (split.length != 2) { player.sendMessage("Usage /setsurface [radius] [blockID]"); return; } @@ -106,7 +112,7 @@ int radius; try { - radius = Integer.parseInt(split[1]); + radius = Integer.parseInt(split[0]); } catch (Exception e) { player.sendMessage("setsurface: radius must be an integer"); return; @@ -120,7 +126,7 @@ int blockid; try { - blockid = Integer.parseInt(split[2]); + blockid = Integer.parseInt(split[1]); } catch (Exception e) { player.sendMessage("setsurface: blockid must be an integer"); return; @@ -161,31 +167,31 @@ } } - private boolean validateLevelOrFill(Player player, String[] split) { - if (split.length < 2 || split.length > 3) { - player.sendMessage("Usage: " + split[0] + " [radius]"); + private boolean validateLevelOrFill(Player player, String label, String[] split) { + if (split.length < 1 || split.length > 2) { + player.sendMessage("Usage: " + label + " [radius]"); return false; } int radius; try { - radius = Integer.parseInt(split[1]); + radius = Integer.parseInt(split[0]); } catch (Exception e) { - player.sendMessage(split[0] + ": radius must be an integer"); + player.sendMessage(label + ": radius must be an integer"); return false; } if (radius > 20) { - player.sendMessage(split[0] + ": radius may not exceed 20"); + player.sendMessage(label + ": radius may not exceed 20"); return false; } - if (split.length == 3) { + if (split.length == 2) { int id; try { - id = Integer.parseInt( split[2] ); + id = Integer.parseInt( split[1] ); } catch (Exception e) { - player.sendMessage(split[0] + ": id must be an integer"); + player.sendMessage(label + ": id must be an integer"); return false; } if ( id == 46) { @@ -199,12 +205,12 @@ } private void fillArea(Player player, Location loc, String[] split) { - int radius = Integer.parseInt(split[1]); + int radius = Integer.parseInt(split[0]); int material = Material.DIRT.getId(); - if (split.length == 3) { - material = Integer.parseInt( split[2] ); + if (split.length == 2) { + material = Integer.parseInt( split[1] ); } System.out.println("Player " + player.getName() + " used fillarea with radius=" + radius); @@ -232,7 +238,7 @@ private void levelArea(Player player, Location loc, String[] split) { - int radius = Integer.parseInt(split[1]); + int radius = Integer.parseInt(split[0]); System.out.println("Player " + player.getName() + " used levelarea with radius=" + radius);