<commit_before>/*
 * ClearInventoryCommand.java
 *
 * Copyright (c) 2014 <NAME> <graham_howden1 at yahoo.co.uk>.
 *
 * This file is part of UltraHardcore.
 *
 * UltraHardcore 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.
 *
 * UltraHardcore 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 UltraHardcore.  If not, see <http ://www.gnu.org/licenses/>.
 */

package com.publicuhc.ultrahardcore.commands;

import com.publicuhc.pluginframework.commands.annotation.CommandMethod;
import com.publicuhc.pluginframework.commands.annotation.RouteInfo;
import com.publicuhc.pluginframework.commands.requests.CommandRequest;
import com.publicuhc.pluginframework.commands.requests.SenderType;
import com.publicuhc.pluginframework.commands.routes.RouteBuilder;
import com.publicuhc.pluginframework.configuration.Configurator;
import com.publicuhc.pluginframework.shaded.inject.Inject;
import com.publicuhc.pluginframework.translate.Translate;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;

public class ClearInventoryCommand extends SimpleCommand {

    public static final String CLEAR_SELF_PERMISSION = "UHC.ci.self";
    public static final String CLEAR_OTHER_PERMISSION = "UHC.ci.other";
    public static final String CLEAR_IMMUNE_PERMISSION = "UHC.ci.immune";

    /**
     * @param configManager the config manager
     * @param translate the translator
     */
    @Inject
    private ClearInventoryCommand(Configurator configManager, Translate translate) {
        super(configManager, translate);
    }

    /**
     * Ran on /ciself
     * @param request request params
     */
    @CommandMethod
    public void clearInventorySelf(CommandRequest request){
        clearInventory((HumanEntity) request.getSender());
        request.sendMessage(translate("ci.cleared", request.getLocale()));
    }

    /**
     * Run on /ciself
     *
     * @param builder the builder
     */
    @RouteInfo
    public void clearInventorySelfDetails(RouteBuilder builder) {
        builder.restrictCommand("ciself")
                .restrictPermission(CLEAR_SELF_PERMISSION)
                .restrictSenderType(SenderType.PLAYER);
    }

    /**
     * Ran on /ci {name}*
     * @param request request params
     */
    @CommandMethod
    public void clearInventoryCommand(CommandRequest request){
        List<String> arguments = request.getArgs();
        int amount = request.getArgs().size();
        AbstractList<String> namesNotFound = new ArrayList<String>();
        for (int i = 0; i < amount; i++) {
            Player p = request.getPlayer(i);
            if (p == null) {
                namesNotFound.add(p.getName());
                continue;
            }
            if (p.hasPermission(CLEAR_IMMUNE_PERMISSION)) {
                request.sendMessage(translate("ci.immune", request.getLocale(), "name", p.getName()));
            } else {
                clearInventory(p);
                p.sendMessage(translate("ci.tell", request.getLocale(), "name", request.getSender().getName()));
            }
        }
        request.sendMessage("ci.cleared");
        if (!namesNotFound.isEmpty()) {
            StringBuilder message = new StringBuilder();
            for (String s : namesNotFound) {
                message.append(' ').append(s);
            }
            request.sendMessage(translate("ci.not_found", request.getLocale(), "list", message.toString()));
        }
    }
<commit_msg>get name from arguments not from the null player translate the ci.cleared string, not print it<commit_after>/*
 * ClearInventoryCommand.java
 *
 * Copyright (c) 2014 <NAME> <graham_howden1 at yahoo.co.uk>.
 *
 * This file is part of UltraHardcore.
 *
 * UltraHardcore 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.
 *
 * UltraHardcore 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 UltraHardcore.  If not, see <http ://www.gnu.org/licenses/>.
 */

package com.publicuhc.ultrahardcore.commands;

import com.publicuhc.pluginframework.commands.annotation.CommandMethod;
import com.publicuhc.pluginframework.commands.annotation.RouteInfo;
import com.publicuhc.pluginframework.commands.requests.CommandRequest;
import com.publicuhc.pluginframework.commands.requests.SenderType;
import com.publicuhc.pluginframework.commands.routes.RouteBuilder;
import com.publicuhc.pluginframework.configuration.Configurator;
import com.publicuhc.pluginframework.shaded.inject.Inject;
import com.publicuhc.pluginframework.translate.Translate;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;

import java.util.AbstractList;
import java.util.ArrayList;

public class ClearInventoryCommand extends SimpleCommand {

    public static final String CLEAR_SELF_PERMISSION = "UHC.ci.self";
    public static final String CLEAR_OTHER_PERMISSION = "UHC.ci.other";
    public static final String CLEAR_IMMUNE_PERMISSION = "UHC.ci.immune";

    /**
     * @param configManager the config manager
     * @param translate the translator
     */
    @Inject
    private ClearInventoryCommand(Configurator configManager, Translate translate) {
        super(configManager, translate);
    }

    /**
     * Ran on /ciself
     * @param request request params
     */
    @CommandMethod
    public void clearInventorySelf(CommandRequest request){
        clearInventory((HumanEntity) request.getSender());
        request.sendMessage(translate("ci.cleared", request.getLocale()));
    }

    /**
     * Run on /ciself
     *
     * @param builder the builder
     */
    @RouteInfo
    public void clearInventorySelfDetails(RouteBuilder builder) {
        builder.restrictCommand("ciself")
                .restrictPermission(CLEAR_SELF_PERMISSION)
                .restrictSenderType(SenderType.PLAYER);
    }

    /**
     * Ran on /ci {name}*
     * @param request request params
     */
    @CommandMethod
    public void clearInventoryCommand(CommandRequest request){
        int amount = request.getArgs().size();
        AbstractList<String> namesNotFound = new ArrayList<String>();
        for (int i = 0; i < amount; i++) {
            Player p = request.getPlayer(i);
            if (p == null) {
                namesNotFound.add(request.getArg(i));
                continue;
            }
            if (p.hasPermission(CLEAR_IMMUNE_PERMISSION)) {
                request.sendMessage(translate("ci.immune", request.getLocale(), "name", p.getName()));
            } else {
                clearInventory(p);
                p.sendMessage(translate("ci.tell", request.getLocale(), "name", request.getSender().getName()));
            }
        }
        request.sendMessage(translate("ci.cleared", request.getLocale()));
        if (!namesNotFound.isEmpty()) {
            StringBuilder message = new StringBuilder();
            for (String s : namesNotFound) {
                message.append(' ').append(s);
            }
            request.sendMessage(translate("ci.not_found", request.getLocale(), "list", message.toString()));
        }
    }

{'fraction_non_alphanumeric': 0.10129620739318292, 'fraction_numerical': 0.0016802688430148825, 'mean_word_length': 3.1375372393247267, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7663039', 'n_tokens_mistral': 2331, 'n_tokens_neox': 2248, 'n_words': 587}