<commit_before>package com.comandante.creeper.command;


import com.comandante.creeper.Items.Item;
import com.comandante.creeper.Items.ItemType;
import com.comandante.creeper.managers.GameManager;
import com.google.common.collect.Lists;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;

import java.util.Arrays;
import java.util.List;

import static com.comandante.creeper.server.Color.RESET;

public class InventoryCommand extends Command {

    final static List<String> validTriggers = Arrays.asList("inventory", "i");
    final static String description = "View your inventory.";
    final static String correctUsage = "inventory";

    public InventoryCommand(GameManager gameManager) {
        super(gameManager, validTriggers, description, correctUsage);
    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        configure(e);
        try {
            List<Item> inventory = entityManager.getInventory(player);
            if (inventory == null) {
                write("You aren't carrying anything.");
                return;
            }
            StringBuilder sb = new StringBuilder();
            sb.append("You are carrying:\r\n");
            sb.append(RESET);
            List<String> invStrings = Lists.newArrayList();
            for (Item item : inventory) {
                sb.append(item.getItemName());
                int maxUses = ItemType.itemTypeFromCode(item.getItemTypeId()).getMaxUses();
                if (maxUses > 0) {
                    int remainingUses = maxUses - item.getNumberOfUses();
                    sb.append(" - ").append(remainingUses);
                    if (remainingUses == 1) {
                        sb.append(" use left.");
                    } else {
                        sb.append(" uses left.");
                    }
                }
                sb.append("\r\n");
            }
            write(sb.toString());
        } finally {
            super.messageReceived(ctx, e);
        }
    }
}<commit_msg>rollup on this inventory command<commit_after>package com.comandante.creeper.command;


import com.comandante.creeper.Items.Item;
import com.comandante.creeper.Items.ItemType;
import com.comandante.creeper.managers.GameManager;
import com.google.common.collect.Maps;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static com.comandante.creeper.server.Color.RESET;

public class InventoryCommand extends Command {

    final static List<String> validTriggers = Arrays.asList("inventory", "i");
    final static String description = "View your inventory.";
    final static String correctUsage = "inventory";

    public InventoryCommand(GameManager gameManager) {
        super(gameManager, validTriggers, description, correctUsage);
    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        configure(e);
        try {
            List<Item> inventory = entityManager.getInventory(player);
            if (inventory == null) {
                write("You aren't carrying anything.");
                return;
            }
            StringBuilder inventoryString = new StringBuilder();
            inventoryString.append("You are carrying:\r\n");
            inventoryString.append(RESET);
            Map<String, Integer> itemAndCounts = Maps.newHashMap();
            for (Item item : inventory) {
                StringBuilder invItem = new StringBuilder();
                invItem.append(item.getItemName());
                int maxUses = ItemType.itemTypeFromCode(item.getItemTypeId()).getMaxUses();
                if (maxUses > 0) {
                    int remainingUses = maxUses - item.getNumberOfUses();
                    invItem.append(" - ").append(remainingUses);
                    if (remainingUses == 1) {
                        invItem.append(" use left.");
                    } else {
                        invItem.append(" uses left.");
                    }
                }
                if (itemAndCounts.containsKey(invItem.toString())) {
                    Integer integer = itemAndCounts.get(invItem.toString());
                    integer = integer + 1;
                    itemAndCounts.put(invItem.toString(), integer);
                } else {
                    itemAndCounts.put(invItem.toString(), 1);
                }
            }
            for (Map.Entry<String, Integer> next : itemAndCounts.entrySet()) {
                if (next.getValue() > 1) {
                    inventoryString.append(next.getKey()).append(" (").append(next.getValue()).append(")").append("\r\n");
                } else {
                    inventoryString.append(next.getKey()).append("\r\n");
                }
            }
            write(inventoryString.toString());
        } finally {
            super.messageReceived(ctx, e);
        }
    }
}
{'fraction_non_alphanumeric': 0.1098186119873817, 'fraction_numerical': 0.0013801261829652998, 'mean_word_length': 2.008896797153025, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, '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': '7590111', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1305, 'n_words': 267}