<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.service.internal.dropclear;

import com.google.common.base.Optional;
import com.skelril.skree.service.DropClearService;
import org.spongepowered.api.Game;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandException;
import org.spongepowered.api.util.command.CommandResult;
import org.spongepowered.api.util.command.CommandSource;
import org.spongepowered.api.util.command.args.CommandContext;
import org.spongepowered.api.util.command.spec.CommandExecutor;
import org.spongepowered.api.util.command.spec.CommandSpec;
import org.spongepowered.api.world.World;

import static org.spongepowered.api.util.command.args.GenericArguments.*;

public class DropClearCommand implements CommandExecutor {

    private Game game;
    private DropClearService service;
    private int maxDelay;

    public DropClearCommand(Game game, DropClearService service, int maxDelay) {
        this.game = game;
        this.service = service;
        this.maxDelay = maxDelay;
    }

    @Override
    public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

        // World resolution
        Optional<World> optWorld = Optional.absent();
        Optional<String> optWorldName = args.<String>getOne("world");

        if (optWorldName.isPresent()) {
            optWorld = game.getServer().getWorld(optWorldName.get());
        } else if (src instanceof Player) {
            optWorld = Optional.of(((Player) src).getWorld());
        } else {
            src.sendMessage(Texts.of("You are not a player and need to specify a world!"));
        }
<commit_msg>Fixed an issue where the user gets two error messages if the user is the console, and doesn't provide a world<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.service.internal.dropclear;

import com.google.common.base.Optional;
import com.skelril.skree.service.DropClearService;
import org.spongepowered.api.Game;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandException;
import org.spongepowered.api.util.command.CommandResult;
import org.spongepowered.api.util.command.CommandSource;
import org.spongepowered.api.util.command.args.CommandContext;
import org.spongepowered.api.util.command.spec.CommandExecutor;
import org.spongepowered.api.util.command.spec.CommandSpec;
import org.spongepowered.api.world.World;

import static org.spongepowered.api.util.command.args.GenericArguments.*;

public class DropClearCommand implements CommandExecutor {

    private Game game;
    private DropClearService service;
    private int maxDelay;

    public DropClearCommand(Game game, DropClearService service, int maxDelay) {
        this.game = game;
        this.service = service;
        this.maxDelay = maxDelay;
    }

    @Override
    public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

        // World resolution
        Optional<World> optWorld;
        Optional<String> optWorldName = args.<String>getOne("world");

        if (optWorldName.isPresent()) {
            optWorld = game.getServer().getWorld(optWorldName.get());
        } else if (src instanceof Player) {
            optWorld = Optional.of(((Player) src).getWorld());
        } else {
            src.sendMessage(Texts.of("You are not a player and need to specify a world!"));
            return CommandResult.empty();
        }

{'fraction_non_alphanumeric': 0.10055583628094998, 'fraction_numerical': 0.00202122283981809, 'mean_word_length': 3.663133097762073, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5015491', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1101, 'n_words': 285}