Search in sources :

Example 26 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class SuperPickaxeCommands method recursive.

@Command(name = "recursive", aliases = { "recur" }, desc = "Enable the recursive super pickaxe pickaxe mode")
@CommandPermissions("worldedit.superpickaxe.recursive")
public void recursive(Player player, LocalSession session, @Arg(desc = "The range of the recursive pickaxe") double range) throws WorldEditException {
    LocalConfiguration config = we.getConfiguration();
    if (range > config.maxSuperPickaxeSize) {
        player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
        return;
    }
    session.setSuperPickaxe(new RecursivePickaxe(range));
    session.enableSuperPickAxe();
    player.print(Caption.of("worldedit.tool.superpickaxe.mode.recursive"));
}
Also used : RecursivePickaxe(com.sk89q.worldedit.command.tool.RecursivePickaxe) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 27 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class GeneralCommands method limit.

@Command(name = "/limit", desc = "Modify block change limit")
@CommandPermissions("worldedit.limit")
public void limit(Actor actor, LocalSession session, @Arg(desc = "The limit to set", def = "") Integer limit) {
    LocalConfiguration config = worldEdit.getConfiguration();
    boolean mayDisable = actor.hasPermission("worldedit.limit.unrestricted");
    limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
    if (!mayDisable && config.maxChangeLimit > -1) {
        if (limit > config.maxChangeLimit) {
            actor.print(Caption.of("worldedit.limit.too-high", TextComponent.of(config.maxChangeLimit)));
            return;
        }
    }
    session.setBlockChangeLimit(limit);
    Component component = TextComponent.empty().append(Caption.of("worldedit.limit.set", TextComponent.of(limit)));
    if (limit != config.defaultChangeLimit) {
        component.append(TextComponent.space()).append(Caption.of("worldedit.limit.return-to-default"));
    }
    actor.print(component);
}
Also used : Component(com.sk89q.worldedit.util.formatting.text.Component) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 28 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class SessionManager method get.

/**
 * Get the session for an owner and create one if one doesn't exist.
 *
 * @param owner the owner
 * @return a session
 */
public synchronized LocalSession get(SessionOwner owner) {
    checkNotNull(owner);
    LocalSession session = getIfPresent(owner);
    LocalConfiguration config = worldEdit.getConfiguration();
    SessionKey sessionKey = owner.getSessionKey();
    // No session exists yet -- create one
    if (session == null) {
        try {
            session = store.load(getKey(sessionKey));
            session.postLoad();
        } catch (IOException e) {
            LOGGER.warn("Failed to load saved session", e);
            session = new LocalSession();
        }
        Request.request().setSession(session);
        session.setConfiguration(config);
        session.setBlockChangeLimit(config.defaultChangeLimit);
        session.setTimeout(config.calculationTimeout);
        // FAWE start
        /*
            try {
                if (owner.hasPermission("worldedit.selection.pos")) {
                    setDefaultWand(session.getWandItem(), config.wandItem, session, new SelectionWand());
                }
                if (owner.hasPermission("worldedit.navigation.jumpto.tool") || owner.hasPermission("worldedit.navigation.thru.tool")) {
                    setDefaultWand(session.getNavWandItem(), config.navigationWand, session, new NavigationWand());
                }
            } catch (InvalidToolBindException e) {
                if (!warnedInvalidTool) {
                    warnedInvalidTool = true;
                    log.warn("Invalid wand tool set in config. Tool will not be assigned: " + e.getItemType());
                }
            }
            */
        // FAWE end
        // Remember the session regardless of if it's currently active or not.
        // And have the SessionTracker FLUSH inactive sessions.
        sessions.put(getKey(owner), new SessionHolder(sessionKey, session));
    }
    if (shouldBoundLimit(owner, "worldedit.limit.unrestricted", session.getBlockChangeLimit(), config.maxChangeLimit)) {
        session.setBlockChangeLimit(config.maxChangeLimit);
    }
    if (shouldBoundLimit(owner, "worldedit.timeout.unrestricted", session.getTimeout(), config.maxCalculationTimeout)) {
        session.setTimeout(config.maxCalculationTimeout);
    }
    // Have the session use inventory if it's enabled and the owner
    // doesn't have an override
    session.setUseInventory(config.useInventory && !(config.useInventoryOverride && (owner.hasPermission("worldedit.inventory.unrestricted") || (config.useInventoryCreativeOverride && (!(owner instanceof Player) || ((Player) owner).getGameMode() == GameModes.CREATIVE)))));
    // Force non-locatable actors to use placeAtPos1
    if (!(owner instanceof Locatable)) {
        session.setPlaceAtPos1(true);
    }
    return session;
}
Also used : Player(com.sk89q.worldedit.entity.Player) LocalSession(com.sk89q.worldedit.LocalSession) IOException(java.io.IOException) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Locatable(com.sk89q.worldedit.extension.platform.Locatable)

Example 29 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class SessionManager method onConfigurationLoad.

@Subscribe
public void onConfigurationLoad(ConfigurationLoadEvent event) {
    LocalConfiguration config = event.getConfiguration();
    File dir = new File(config.getWorkingDirectoryPath().toFile(), "sessions");
    store = new JsonFileSessionStore(dir);
}
Also used : JsonFileSessionStore(com.sk89q.worldedit.session.storage.JsonFileSessionStore) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) File(java.io.File) Subscribe(com.sk89q.worldedit.util.eventbus.Subscribe)

Example 30 with LocalConfiguration

use of com.sk89q.worldedit.LocalConfiguration in project FastAsyncWorldEdit by IntellectualSites.

the class PlatformCommandManager method registerCommandsWith.

void registerCommandsWith(Platform platform) {
    LOGGER.info("Registering commands with " + platform.getClass().getCanonicalName());
    LocalConfiguration config = platform.getConfiguration();
    boolean logging = config.logCommands;
    String path = config.logFile;
    // Register log
    if (!logging || path.isEmpty()) {
        dynamicHandler.setHandler(null);
        COMMAND_LOG.setLevel(Level.OFF);
    } else {
        File file = new File(config.getWorkingDirectoryPath().toFile(), path);
        COMMAND_LOG.setLevel(Level.ALL);
        LOGGER.info("Logging WorldEdit commands to " + file.getAbsolutePath());
        try {
            dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true));
        } catch (IOException e) {
            LOGGER.warn("Could not use command log file " + path + ": " + e.getMessage());
        }
        dynamicHandler.setFormatter(new LogFormat(config.logFormat));
    }
    platform.registerCommands(commandManager);
}
Also used : LogFormat(com.sk89q.worldedit.util.logging.LogFormat) IOException(java.io.IOException) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) File(java.io.File) FileHandler(java.util.logging.FileHandler)

Aggregations

LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)31 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)20 Command (org.enginehub.piston.annotation.Command)20 File (java.io.File)12 IOException (java.io.IOException)9 URI (java.net.URI)7 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)6 Snapshot (com.sk89q.worldedit.world.snapshot.Snapshot)6 Snapshot (com.sk89q.worldedit.world.snapshot.experimental.Snapshot)6 MissingWorldException (com.sk89q.worldedit.world.storage.MissingWorldException)6 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)5 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)4 Logging (com.sk89q.worldedit.command.util.Logging)3 ClipboardFormat (com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat)3 Component (com.sk89q.worldedit.util.formatting.text.Component)3 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)3 TranslatableComponent (com.sk89q.worldedit.util.formatting.text.TranslatableComponent)3 Region (com.sk89q.worldedit.regions.Region)2 InvalidSnapshotException (com.sk89q.worldedit.world.snapshot.InvalidSnapshotException)2 URL (java.net.URL)2