<commit_before>package com.elmakers.mine.bukkit.plugins.magic;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import com.elmakers.mine.bukkit.utilities.InventoryUtils;

public class MagicPlugin extends JavaPlugin
{	
	/*
	 * Public API
	 */
	public Spells getSpells()
	{
		return spells;
	}

	/*
	 * Plugin interface
	 */
	
	public void onEnable() 
	{
	    initialize();
		
        PluginManager pm = getServer().getPluginManager();
		
        pm.registerEvents(spells, this);
        
        PluginDescriptionFile pdfFile = this.getDescription();
        log.info(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled");
	}
	
	protected void initialize()
	{
	    spells.initialize(this);
	}
	
	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
	{
	    String commandName = cmd.getName();
	    
        if (commandName.equalsIgnoreCase("magic") && args.length > 0)
        {
            String subCommand = args[0];
            if (sender instanceof Player)
            {
                if (!spells.hasPermission((Player)sender, "Magic.commands.magic." + subCommand)) return true;
            }
            if (subCommand.equalsIgnoreCase("reload"))
            {
                spells.clear();
                spells.load();
                return true;
            }
            if (subCommand.equalsIgnoreCase("reset"))
            {   
                spells.reset();
                return true;
            }
            
        }
        
	    // Everything beyond this point is is-game only
	    if (!(sender instanceof Player)) return false;
	    
	    Player player = (Player)sender;

        if (commandName.equalsIgnoreCase("wand"))
        {
            if (!spells.hasPermission(player, "Magic.commands.wand")) return true;
            return onWand(player, args);
        }
	    
	    if (commandName.equalsIgnoreCase("cast"))
        {
	        if (!spells.hasPermission(player, "Magic.commands.cast")) return true;
            return onCast(player, args);
        }

        if (commandName.equalsIgnoreCase("spells"))
        {
            if (!spells.hasPermission(player, "Magic.commands.spells")) return true;
            return onSpells(player, args);
        }
        
	    return false;
	}
	
    public boolean onWand(Player player, String[] parameters)
    {
    	boolean holdingWand = Spells.isWandActive(player);
    	
        if (parameters.length < 1)
        {
            if (!holdingWand)
            {
            	ItemStack itemStack = new ItemStack(Material.STICK);
                itemStack.addUnsafeEnchantment(Spells.MagicEnchantment, 1);
                Spells.updateWand(itemStack, 0);
                player.getInventory().addItem(itemStack);
                
                player.sendMessage("Use /wand again for help, /spells for spell list");
            }
            else 
            {
                showWandHelp(player);
            }
            return true;
        }
        <commit_msg>Try to handle switching from one wand to another.<commit_after>package com.elmakers.mine.bukkit.plugins.magic;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import com.elmakers.mine.bukkit.utilities.InventoryUtils;

public class MagicPlugin extends JavaPlugin
{	
	/*
	 * Public API
	 */
	public Spells getSpells()
	{
		return spells;
	}

	/*
	 * Plugin interface
	 */
	
	public void onEnable() 
	{
	    initialize();
		
        PluginManager pm = getServer().getPluginManager();
		
        pm.registerEvents(spells, this);
        
        PluginDescriptionFile pdfFile = this.getDescription();
        log.info(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled");
	}
	
	protected void initialize()
	{
	    spells.initialize(this);
	}
	
	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
	{
	    String commandName = cmd.getName();
	    
        if (commandName.equalsIgnoreCase("magic") && args.length > 0)
        {
            String subCommand = args[0];
            if (sender instanceof Player)
            {
                if (!spells.hasPermission((Player)sender, "Magic.commands.magic." + subCommand)) return true;
            }
            if (subCommand.equalsIgnoreCase("reload"))
            {
                spells.clear();
                spells.load();
                return true;
            }
            if (subCommand.equalsIgnoreCase("reset"))
            {   
                spells.reset();
                return true;
            }
            
        }
        
	    // Everything beyond this point is is-game only
	    if (!(sender instanceof Player)) return false;
	    
	    Player player = (Player)sender;

        if (commandName.equalsIgnoreCase("wand"))
        {
            if (!spells.hasPermission(player, "Magic.commands.wand")) return true;
            return onWand(player, args);
        }
	    
	    if (commandName.equalsIgnoreCase("cast"))
        {
	        if (!spells.hasPermission(player, "Magic.commands.cast")) return true;
            return onCast(player, args);
        }

        if (commandName.equalsIgnoreCase("spells"))
        {
            if (!spells.hasPermission(player, "Magic.commands.spells")) return true;
            return onSpells(player, args);
        }
        
	    return false;
	}
	
    public boolean onWand(Player player, String[] parameters)
    {
    	boolean holdingWand = Spells.isWandActive(player);
    	
        if (parameters.length < 1)
        {
            if (!holdingWand)
            {
            	ItemStack itemStack = new ItemStack(Material.STICK);
                itemStack.addUnsafeEnchantment(Spells.MagicEnchantment, 1);
                Spells.updateWand(itemStack, 0, "Wand");
                player.getInventory().addItem(itemStack);
                
                player.sendMessage("Use /wand again for help, /spells for spell list");
            }
            else 
            {
                showWandHelp(player);
            }
            return true;
        }
        
{'fraction_non_alphanumeric': 0.10562603419746276, 'fraction_numerical': 0.0013789299503585218, 'mean_word_length': 2.1008978195810175, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2277619', 'n_tokens_mistral': 2117, 'n_tokens_neox': 1976, 'n_words': 411}