<commit_before>/* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.laytonsmith.abstraction.bukkit.events;

import com.laytonsmith.abstraction.*;
import com.laytonsmith.abstraction.bukkit.BukkitConvertor;
import com.laytonsmith.abstraction.bukkit.BukkitMCEntity;
import com.laytonsmith.abstraction.bukkit.BukkitMCItemStack;
import com.laytonsmith.abstraction.bukkit.BukkitMCLivingEntity;
import com.laytonsmith.abstraction.bukkit.BukkitMCPlayer;
import com.laytonsmith.abstraction.enums.MCDamageCause;
import com.laytonsmith.abstraction.enums.MCEntityType;
import com.laytonsmith.abstraction.enums.MCTargetReason;
import com.laytonsmith.abstraction.events.*;
import com.laytonsmith.annotations.abstraction;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;

/**
 *
 * @author EntityReborn
 */
public class BukkitEntityEvents {
	
    @abstraction(type = Implementation.Type.BUKKIT)
    public static class BukkitMCPlayerDropItemEvent implements MCPlayerDropItemEvent {
        PlayerDropItemEvent e;
        
        public BukkitMCPlayerDropItemEvent(PlayerDropItemEvent e) {
            this.e = e;
        }
        
        public MCItemStack getItemDrop() {
            return new BukkitMCItemStack(e.getItemDrop().getItemStack());
        }
        
        public void setItem(MCItemStack stack) {
            BukkitMCItemStack s = (BukkitMCItemStack) stack;
            e.getItemDrop().setItemStack(s.__ItemStack());
        }
        
        public boolean isCancelled() {
            return e.isCancelled();
        }
        
        public void setCancelled(boolean cancelled) {
            e.setCancelled(cancelled);
        }
        
        public MCPlayer getPlayer() {
            return new BukkitMCPlayer(e.getPlayer());
        }
        
        public Object _GetObject() {
            return e;
        }
    }
    
	@abstraction(type = Implementation.Type.BUKKIT)
	public static class BukkitMCPlayerPickupItemEvent implements MCPlayerPickupItemEvent {
		PlayerPickupItemEvent e;
		
		public BukkitMCPlayerPickupItemEvent(PlayerPickupItemEvent e) {
			this.e = e;
		}
		public int getRemaining() {
			return e.getRemaining();
		}

		public MCItemStack getItem() {
			return new BukkitMCItemStack(e.getItem().getItemStack());
		}

		public void setItem(MCItemStack stack) {
			BukkitMCItemStack s = (BukkitMCItemStack)stack;
			e.getItem().setItemStack(s.__ItemStack());
		}

		public boolean isCancelled() {
			return e.isCancelled();
		}

		public void setCancelled(boolean cancelled) {
			e.setCancelled(cancelled);
		}

		public MCPlayer getPlayer() {
			return new BukkitMCPlayer(e.getPlayer());
		}

		public Object _GetObject() {
			return e;
		}
	}
	
	@abstraction(type = Implementation.Type.BUKKIT)
    public static class BukkitMCEntityDamageEvent implements MCEntityDamageEvent {

        EntityDamageEvent event;

        public BukkitMCEntityDamageEvent(EntityDamageEvent e) {
            event = e;<commit_msg>fix an NPE with null items, and allow the item in item events to be removed<commit_after>/* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.laytonsmith.abstraction.bukkit.events;

import com.laytonsmith.abstraction.*;
import com.laytonsmith.abstraction.bukkit.BukkitConvertor;
import com.laytonsmith.abstraction.bukkit.BukkitMCEntity;
import com.laytonsmith.abstraction.bukkit.BukkitMCItemStack;
import com.laytonsmith.abstraction.bukkit.BukkitMCLivingEntity;
import com.laytonsmith.abstraction.bukkit.BukkitMCPlayer;
import com.laytonsmith.abstraction.enums.MCDamageCause;
import com.laytonsmith.abstraction.enums.MCEntityType;
import com.laytonsmith.abstraction.enums.MCTargetReason;
import com.laytonsmith.abstraction.events.*;
import com.laytonsmith.annotations.abstraction;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;

/**
 *
 * @author EntityReborn
 */
public class BukkitEntityEvents {
	
    @abstraction(type = Implementation.Type.BUKKIT)
    public static class BukkitMCPlayerDropItemEvent implements MCPlayerDropItemEvent {
        PlayerDropItemEvent e;
        
        public BukkitMCPlayerDropItemEvent(PlayerDropItemEvent e) {
            this.e = e;
        }
        
        public MCItemStack getItemDrop() {
            return new BukkitMCItemStack(e.getItemDrop().getItemStack());
        }
        
        public void setItem(MCItemStack stack) {
            BukkitMCItemStack s = (BukkitMCItemStack) stack;
            if(s.getTypeId() == 0) {
                e.getItemDrop().remove();
            } else {
                e.getItemDrop().setItemStack(s.__ItemStack());
            }
        }
        
        public boolean isCancelled() {
            return e.isCancelled();
        }
        
        public void setCancelled(boolean cancelled) {
            e.setCancelled(cancelled);
        }
        
        public MCPlayer getPlayer() {
            return new BukkitMCPlayer(e.getPlayer());
        }
        
        public Object _GetObject() {
            return e;
        }
    }
    
	@abstraction(type = Implementation.Type.BUKKIT)
	public static class BukkitMCPlayerPickupItemEvent implements MCPlayerPickupItemEvent {
		PlayerPickupItemEvent e;
		
		public BukkitMCPlayerPickupItemEvent(PlayerPickupItemEvent e) {
			this.e = e;
		}
		public int getRemaining() {
			return e.getRemaining();
		}

		public MCItemStack getItem() {
			return new BukkitMCItemStack(e.getItem().getItemStack());
		}

		public void setItem(MCItemStack stack) {
			BukkitMCItemStack s = (BukkitMCItemStack)stack;
			if(s.getTypeId() == 0) {
				e.getItem().remove();
			} else {
				e.getItem().setItemStack(s.__ItemStack());
			}
		}

		public boolean isCancelled() {
			return e.isCancelled();
		}

		public void setCancelled(boolean cancelled) {
			e.setCancelled(cancelled);
		}

		public MCPlayer getPlayer() {
			return new BukkitMCPlayer(e.getPlayer());
		}

		public Object _GetObject() {
			return e;
		}
	}
	
	@abstraction(type = Implementation.Type.BUKKIT)
    public static class BukkitMCEntityDamageEvent implements MCEntityDamageEvent {

        EntityDamageEvent event;

        public BukkitMCEntityDamageEvent(EntityDamageEvent e) {
            event = e;
{'fraction_non_alphanumeric': 0.09033674963396779, 'fraction_numerical': 0.00029282576866764275, 'mean_word_length': 3.258728179551122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4826883', 'n_tokens_mistral': 2307, 'n_tokens_neox': 2135, 'n_words': 380}