2011-02-18 23:14:43 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
|
|
|
* WorldEdit
|
|
|
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.sk89q.worldedit.commands;
|
|
|
|
|
|
|
|
import com.sk89q.minecraft.util.commands.Command;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
|
|
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
|
|
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
|
|
|
import com.sk89q.worldedit.*;
|
|
|
|
import com.sk89q.worldedit.masks.Mask;
|
2011-02-19 07:33:43 +00:00
|
|
|
import com.sk89q.worldedit.patterns.Pattern;
|
2011-02-18 23:14:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tool commands.
|
|
|
|
*
|
|
|
|
* @author sk89q
|
|
|
|
*/
|
|
|
|
public class ToolUtilCommands {
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "/", "," },
|
2011-08-08 22:17:55 +00:00
|
|
|
usage = "[on|off]",
|
2011-02-18 23:14:43 +00:00
|
|
|
desc = "Toggle the super pickaxe pickaxe function",
|
|
|
|
min = 0,
|
2011-08-08 22:17:55 +00:00
|
|
|
max = 1
|
2011-02-18 23:14:43 +00:00
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.superpickaxe")
|
2011-02-18 23:14:43 +00:00
|
|
|
public static void togglePickaxe(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
2011-08-08 22:17:55 +00:00
|
|
|
String newState = args.getString(0, null);
|
|
|
|
if (session.hasSuperPickAxe()) {
|
|
|
|
if ("on".equals(newState)) {
|
|
|
|
player.printError("Super pick axe already enabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session.disableSuperPickAxe();
|
2011-02-18 23:14:43 +00:00
|
|
|
player.print("Super pick axe disabled.");
|
2011-10-26 20:50:46 +00:00
|
|
|
} else {
|
2011-08-08 22:17:55 +00:00
|
|
|
if ("off".equals(newState)) {
|
|
|
|
player.printError("Super pick axe already disabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
session.enableSuperPickAxe();
|
|
|
|
player.print("Super pick axe enabled.");
|
|
|
|
}
|
|
|
|
|
2011-02-18 23:14:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "superpickaxe", "pickaxe", "sp" },
|
2011-02-18 23:14:43 +00:00
|
|
|
desc = "Select super pickaxe mode"
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@NestedCommand(SuperPickaxeCommands.class)
|
2011-02-18 23:14:43 +00:00
|
|
|
public static void pickaxe(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-02-25 00:43:23 +00:00
|
|
|
aliases = {"tool"},
|
2011-02-18 23:14:43 +00:00
|
|
|
desc = "Select a tool to bind"
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@NestedCommand(ToolCommands.class)
|
2011-02-18 23:14:43 +00:00
|
|
|
public static void tool(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "mask" },
|
2011-02-18 23:14:43 +00:00
|
|
|
usage = "[mask]",
|
|
|
|
desc = "Set the brush mask",
|
|
|
|
min = 0,
|
2011-06-04 18:57:40 +00:00
|
|
|
max = -1
|
2011-02-18 23:14:43 +00:00
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.options.mask")
|
2011-02-18 23:14:43 +00:00
|
|
|
public static void mask(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
if (args.argsLength() == 0) {
|
|
|
|
session.getBrushTool(player.getItemInHand()).setMask(null);
|
|
|
|
player.print("Brush mask disabled.");
|
|
|
|
} else {
|
2011-06-04 18:57:40 +00:00
|
|
|
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
2011-02-18 23:14:43 +00:00
|
|
|
session.getBrushTool(player.getItemInHand()).setMask(mask);
|
|
|
|
player.print("Brush mask set.");
|
|
|
|
}
|
|
|
|
}
|
2011-02-19 07:33:43 +00:00
|
|
|
|
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "mat", "material", "fill" },
|
2011-02-19 07:33:43 +00:00
|
|
|
usage = "[pattern]",
|
|
|
|
desc = "Set the brush material",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.options.material")
|
2011-02-19 07:33:43 +00:00
|
|
|
public static void material(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
|
|
|
session.getBrushTool(player.getItemInHand()).setFill(pattern);
|
|
|
|
player.print("Brush material set.");
|
|
|
|
}
|
|
|
|
|
2011-06-22 22:28:56 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "range" },
|
2011-06-22 22:28:56 +00:00
|
|
|
usage = "[pattern]",
|
|
|
|
desc = "Set the brush range",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.options.range")
|
2011-06-22 22:28:56 +00:00
|
|
|
public static void range(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
int range = args.getInteger(0);
|
|
|
|
session.getBrushTool(player.getItemInHand()).setRange(range);
|
|
|
|
player.print("Brush range set.");
|
|
|
|
}
|
|
|
|
|
2011-02-19 07:33:43 +00:00
|
|
|
@Command(
|
2011-09-19 05:14:43 +00:00
|
|
|
aliases = { "size" },
|
2011-02-19 07:33:43 +00:00
|
|
|
usage = "[pattern]",
|
|
|
|
desc = "Set the brush size",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
2011-09-19 05:14:43 +00:00
|
|
|
@CommandPermissions("worldedit.brush.options.size")
|
2011-02-19 07:33:43 +00:00
|
|
|
public static void size(CommandContext args, WorldEdit we,
|
|
|
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
|
|
|
throws WorldEditException {
|
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-02-19 07:33:43 +00:00
|
|
|
int radius = args.getInteger(0);
|
|
|
|
if (radius > config.maxBrushRadius) {
|
|
|
|
player.printError("Maximum allowed brush radius: "
|
|
|
|
+ config.maxBrushRadius);
|
|
|
|
return;
|
|
|
|
}
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-02-19 07:33:43 +00:00
|
|
|
session.getBrushTool(player.getItemInHand()).setSize(radius);
|
|
|
|
player.print("Brush size set.");
|
|
|
|
}
|
2011-02-18 23:14:43 +00:00
|
|
|
}
|