mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-14 23:38:34 +00:00
Copy paste/merge FAWE classes to this WorldEdit fork
- so certain people can look at the diff and complain about my sloppy code :( Signed-off-by: Jesse Boyd <jessepaleg@gmail.com>
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.InspectBrush;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
@ -27,6 +29,8 @@ import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
||||
@ -37,12 +41,13 @@ import com.sk89q.worldedit.command.tool.LongRangeBuildTool;
|
||||
import com.sk89q.worldedit.command.tool.QueryTool;
|
||||
import com.sk89q.worldedit.command.tool.TreePlanter;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@Command(aliases = {"brush", "br", "tool"}, desc = "Bind functions to held items: [More Info](https://goo.gl/xPnPxj)")
|
||||
public class ToolCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -51,181 +56,134 @@ public class ToolCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "none" },
|
||||
usage = "",
|
||||
desc = "Unbind a bound tool from your current item",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void none(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||
player.print("Tool unbound from your current item.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "info" },
|
||||
usage = "",
|
||||
desc = "Block information tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
aliases = {"info", "/info"},
|
||||
usage = "",
|
||||
desc = "Block information tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.info")
|
||||
public void info(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
public void info(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new QueryTool(), player);
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new QueryTool());
|
||||
player.print("Info tool bound to "
|
||||
+ itemStack.getType().getName() + ".");
|
||||
BBC.TOOL_INFO.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "tree" },
|
||||
usage = "[type]",
|
||||
desc = "Tree generator tool",
|
||||
min = 0,
|
||||
max = 1
|
||||
aliases = {"inspect"},
|
||||
usage = "",
|
||||
desc = "Inspect edits within a radius",
|
||||
help =
|
||||
"Chooses the inspect brush",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.inspect")
|
||||
public void inspectBrush(Player player, LocalSession session, @Optional("1") double radius) throws WorldEditException {
|
||||
session.setTool(new InspectBrush(), player);
|
||||
BBC.TOOL_INSPECT.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"tree"},
|
||||
usage = "[type]",
|
||||
desc = "Tree generator tool",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.tree")
|
||||
public void tree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
TreeGenerator.TreeType type = args.argsLength() > 0
|
||||
? TreeGenerator.lookup(args.getString(0))
|
||||
: TreeGenerator.TreeType.TREE;
|
||||
|
||||
if (type == null) {
|
||||
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new TreePlanter(type));
|
||||
player.print("Tree tool bound to " + itemStack.getType().getName() + ".");
|
||||
@SuppressWarnings("deprecation")
|
||||
public void tree(Player player, LocalSession session, @Optional("tree") TreeGenerator.TreeType type, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new TreePlanter(type), player);
|
||||
BBC.TOOL_TREE.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "repl" },
|
||||
usage = "<block>",
|
||||
desc = "Block replacer tool",
|
||||
min = 1,
|
||||
max = 1
|
||||
aliases = {"repl"},
|
||||
usage = "<block>",
|
||||
desc = "Block replacer tool",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.replacer")
|
||||
public void repl(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
context.setRestricted(true);
|
||||
context.setPreferringWildcard(false);
|
||||
|
||||
BlockStateHolder targetBlock = we.getBlockFactory().parseFromInput(args.getString(0), context);
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new BlockReplacer(targetBlock));
|
||||
player.print("Block replacer tool bound to " + itemStack.getType().getName() + ".");
|
||||
public void repl(Player player, LocalSession session, Pattern pattern) throws WorldEditException {
|
||||
session.setTool(new BlockReplacer(pattern), player);
|
||||
BBC.TOOL_REPL.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "cycler" },
|
||||
usage = "",
|
||||
desc = "Block data cycler tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
aliases = {"cycler"},
|
||||
usage = "",
|
||||
desc = "Block data cycler tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.data-cycler")
|
||||
public void cycler(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void cycler(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new BlockDataCyler());
|
||||
player.print("Block data cycler tool bound to " + itemStack.getType().getName() + ".");
|
||||
session.setTool(new BlockDataCyler(), player);
|
||||
BBC.TOOL_CYCLER.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "floodfill", "flood" },
|
||||
usage = "<pattern> <range>",
|
||||
desc = "Flood fill tool",
|
||||
min = 2,
|
||||
max = 2
|
||||
aliases = {"floodfill", "flood"},
|
||||
usage = "<pattern> <range>",
|
||||
desc = "Flood fill tool",
|
||||
min = 2,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.flood-fill")
|
||||
public void floodFill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
public void floodFill(Player player, EditSession editSession, LocalSession session, Pattern pattern, double range) throws WorldEditException {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
int range = args.getInteger(1);
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
|
||||
return;
|
||||
}
|
||||
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new FloodFillTool(range, pattern));
|
||||
player.print("Block flood fill tool bound to " + itemStack.getType().getName() + ".");
|
||||
session.setTool(new FloodFillTool((int) range, pattern), player);
|
||||
BBC.TOOL_FLOOD_FILL.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "deltree" },
|
||||
aliases = {"deltree"},
|
||||
usage = "",
|
||||
desc = "Floating tree remover tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.deltree")
|
||||
public void deltree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new FloatingTreeRemover());
|
||||
player.print("Floating tree remover tool bound to "
|
||||
+ itemStack.getType().getName() + ".");
|
||||
public void deltree(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new FloatingTreeRemover(), player);
|
||||
BBC.TOOL_DELTREE.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "farwand" },
|
||||
aliases = {"farwand"},
|
||||
usage = "",
|
||||
desc = "Wand at a distance tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.farwand")
|
||||
public void farwand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new DistanceWand());
|
||||
player.print("Far wand tool bound to " + itemStack.getType().getName() + ".");
|
||||
public void farwand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new DistanceWand(), player);
|
||||
BBC.TOOL_FARWAND.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "lrbuild", "/lrbuild" },
|
||||
aliases = {"lrbuild", "/lrbuild"},
|
||||
usage = "<leftclick block> <rightclick block>",
|
||||
desc = "Long-range building tool",
|
||||
min = 2,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.lrbuild")
|
||||
public void longrangebuildtool(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
context.setRestricted(true);
|
||||
context.setPreferringWildcard(false);
|
||||
|
||||
BlockStateHolder secondary = we.getBlockFactory().parseFromInput(args.getString(0), context);
|
||||
BlockStateHolder primary = we.getBlockFactory().parseFromInput(args.getString(1), context);
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
|
||||
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary));
|
||||
player.print("Long-range building tool bound to " + itemStack.getType().getName() + ".");
|
||||
player.print("Left-click set to " + secondary.getBlockType().getName() + "; right-click set to "
|
||||
+ primary.getBlockType().getName() + ".");
|
||||
public void longrangebuildtool(Player player, LocalSession session, Pattern secondary, Pattern primary) throws WorldEditException {
|
||||
session.setTool(new LongRangeBuildTool(primary, secondary), player);
|
||||
BBC.TOOL_LRBUILD_BOUND.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
BBC.TOOL_LRBUILD_INFO.send(player, secondary, primary);
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> inject() {
|
||||
return ToolCommands.class;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user