Java Code Examples for com.sk89q.worldedit.LocalSession#isToolControlEnabled()

The following examples show how to use com.sk89q.worldedit.LocalSession#isToolControlEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"toggleeditwand"},
        usage = "",
        desc = "Toggle functionality of the edit wand",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.wand.toggle")
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    session.setToolControl(!session.isToolControlEnabled());

    if (session.isToolControlEnabled()) {
        BBC.SELECTION_WAND_ENABLE.m().send(player);
    } else {
        BBC.SELECTION_WAND_DISABLE.send(player);
    }
}
 
Example 2
Source File: InspectBrush.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean perform(final Player player, LocalSession session, boolean rightClick) {
    if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) {
        player.print(BBC.getPrefix() + BBC.NO_PERM.f("worldedit.tool.inspect"));
        return false;
    }
    if (!Settings.IMP.HISTORY.USE_DATABASE) {
        player.print(BBC.getPrefix() + BBC.SETTING_DISABLE.f("history.use-database (Import with /frb #import )"));
        return false;
    }
    WorldVector target = getTarget(player, rightClick);
    final int x = target.getBlockX();
    final int y = target.getBlockY();
    final int z = target.getBlockZ();
    World world = player.getWorld();
    final FawePlayer fp = FawePlayer.wrap(player);
    EditSessionBuilder editSession = new EditSessionBuilder(world).player(fp);
    RollbackDatabase db = DBHandler.IMP.getDatabase(world);
    final AtomicInteger count = new AtomicInteger();
    db.getPotentialEdits(null, 0, target, target, new RunnableVal<DiskStorageHistory>() {
        @Override
        public void run(DiskStorageHistory value) {
            try {
                Iterator<MutableFullBlockChange> iter = value.getFullBlockIterator(null, 0, false);
                while (iter.hasNext()) {
                    MutableFullBlockChange change = iter.next();
                    if (change.x != x || change.y != y || change.z != z) {
                        continue;
                    }
                    int from = change.from;
                    int to = change.to;
                    UUID uuid = value.getUUID();
                    String name = Fawe.imp().getName(uuid);
                    int index = value.getIndex();
                    long age = System.currentTimeMillis() - value.getBDFile().lastModified();
                    String ageFormatted = MainUtil.secToTime(age / 1000);
                    BBC.TOOL_INSPECT_INFO.send(fp, name, FaweCache.getMaterialName(from), FaweCache.getMaterialName(to), ageFormatted);
                    count.incrementAndGet();
                    return;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }, new Runnable() {
        @Override
        public void run() {
            BBC.TOOL_INSPECT_INFO_FOOTER.send(fp, count);
        }
    }, false, false);
    return true;
}