<commit_before>package info.tregmine.listeners;

import info.tregmine.Tregmine;
import info.tregmine.api.TregminePlayer;

import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;

public class ItemFrameListener implements Listener
{
    private Tregmine plugin;
    
    public ItemFrameListener(Tregmine instance)
    {
        this.plugin = instance;
    }
    
    @EventHandler
    public void onRotate(PlayerInteractEntityEvent event)
    {
        if (!(event.getRightClicked().getType().equals(EntityType.ITEM_FRAME))) { // Before we do anything lets check were interacting with ItemFrames
            return;
        }
        
        TregminePlayer player = plugin.getPlayer(event.getPlayer());

        Location location = event.getRightClicked().getLocation();
        
        if (!player.hasBlockPermission(location, true)) {
            event.setCancelled(true);
        }
    }
    
}<commit_msg>Fix's itemframes dropping items on left click without valid permission.<commit_after>package info.tregmine.listeners;

import info.tregmine.Tregmine;
import info.tregmine.api.TregminePlayer;

import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;

public class ItemFrameListener implements Listener
{
    private Tregmine plugin;
    
    public ItemFrameListener(Tregmine instance)
    {
        this.plugin = instance;
    }
    
    @EventHandler
    public void onRotate(PlayerInteractEntityEvent event)
    {
        if (!(event.getRightClicked().getType().equals(EntityType.ITEM_FRAME))) { // Before we do anything lets check were interacting with ItemFrames
            return;
        }
        
        TregminePlayer player = plugin.getPlayer(event.getPlayer());

        Location location = event.getRightClicked().getLocation();
        
        if (!player.hasBlockPermission(location, true)) {
            event.setCancelled(true);
        }
    }
    
    @EventHandler
    public void onDamage(EntityDamageByEntityEvent event)
    {
        if (!(event.getEntity() instanceof ItemFrame)) {
            return;
        }
        
        if (!(event.getDamager() instanceof Player)) {
            return;
        }
        
        TregminePlayer player = plugin.getPlayer((Player) event.getDamager());
        
        if (!player.hasBlockPermission(event.getEntity().getLocation(), true)) {
            event.setCancelled(true);
        }
    }
    
}
{'fraction_non_alphanumeric': 0.09515260323159784, 'fraction_numerical': 0.0, 'mean_word_length': 2.8965034965034966, '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': '2885070', 'n_tokens_mistral': 793, 'n_tokens_neox': 776, 'n_words': 152}