Added more tree generators, removed CraftBukkit/MC dependency (yay!).

This commit is contained in:
sk89q
2011-01-30 14:54:42 -08:00
parent 68b12f4c7d
commit 10b48e9344
14 changed files with 430 additions and 472 deletions

View File

@ -23,6 +23,7 @@ import com.sk89q.util.commands.Command;
import com.sk89q.util.commands.CommandContext;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.util.TreeGenerator;
/**
* Generation commands.
@ -132,7 +133,7 @@ public class GenerationCommands {
@Command(
aliases = {"forestgen"},
usage = "[size] [density] ",
usage = "[size] [type] [density]",
desc = "Generate a forest",
min = 0,
max = 2
@ -141,35 +142,24 @@ public class GenerationCommands {
public static void forestGen(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
double density = args.argsLength() > 1 ? Double.parseDouble(args.getString(1)) / 100 : 0.05;
TreeGenerator.TreeType type = args.argsLength() > 1 ?
type = TreeGenerator.lookup(args.getString(1))
: TreeGenerator.TreeType.TREE;
double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05;
if (type == null) {
player.printError("Tree type '" + args.getString(1) + "' is unknown.");
return;
} else {
}
int affected = editSession.makeForest(player.getPosition(),
size, density, false);
size, density, new TreeGenerator(type));
player.print(affected + " trees created.");
}
@Command(
aliases = {"pinegen"},
usage = "[size] [density]",
desc = "Generate a pine forest",
min = 0,
max = 2
)
@CommandPermissions({"worldedit.generation.forest"})
public static void pineGen(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
double density = args.argsLength() > 1 ? Double.parseDouble(args.getString(1)) / 100 : 0.05;
int affected = editSession.makeForest(player.getPosition(),
size, density, true);
player.print(affected + " pine trees created.");
}
@Command(
aliases = {"pumpkins"},
usage = "[size]",

View File

@ -24,6 +24,7 @@ import com.sk89q.util.commands.CommandContext;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.superpickaxe.*;
import com.sk89q.worldedit.util.TreeGenerator;
/**
* Super pickaxe commands.
@ -152,55 +153,30 @@ public class SuperPickaxeCommands {
@Command(
aliases = {"tree"},
usage = "",
usage = "[type]",
desc = "Tree generator tool",
min = 0,
max = 0
max = 1
)
@CommandPermissions({"worldedit.superpickaxe.tree"})
public static void tree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
TreeGenerator.TreeType type = args.argsLength() > 0 ?
type = TreeGenerator.lookup(args.getString(0))
: TreeGenerator.TreeType.TREE;
if (type == null) {
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
return;
}
session.setArmSwingMode(null);
session.setRightClickMode(new TreePlanter());
session.setRightClickMode(new TreePlanter(new TreeGenerator(type)));
player.print("Tree tool equipped. Right click grass with a pickaxe.");
}
@Command(
aliases = {"bigtree"},
usage = "",
desc = "Big tree generator tool",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.tree.big"})
public static void bigTree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setArmSwingMode(null);
session.setRightClickMode(new BigTreePlanter());
player.print("Big tree tool equipped. Right click grass with a pickaxe.");
}
@Command(
aliases = {"pinetree"},
usage = "",
desc = "Pine tree generator tool",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.superpickaxe.tree.pine"})
public static void pineTree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
session.setArmSwingMode(null);
session.setRightClickMode(new PineTreePlanter());
player.print("Pine tree tool equipped. Right click a block with a pickaxe.");
}
@Command(
aliases = {"repl"},
usage = "<block>",