<commit_before>package com.gmail.nossr50.listeners;

import java.io.File;
import java.util.ArrayList;

import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldUnloadEvent;

import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;

public class WorldListener implements Listener {
    private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();

    private final mcMMO plugin;

    public WorldListener(final mcMMO plugin) {
        this.plugin = plugin;
    }

    /**
     * Monitor StructureGrow events.
     *
     * @param event The event to watch
     */
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onStructureGrow(StructureGrowEvent event) {
        Location location = event.getLocation();

        if (mcMMO.getPlaceStore().isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) {
            for (BlockState blockState : event.getBlocks()) {
                mcMMO.getPlaceStore().setFalse(blockState);
            }
        }
    }

    /**
     * Monitor WorldInit events.
     *
     * @param event The event to watch
     */
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onWorldInit(WorldInitEvent event) {
        World world = event.getWorld();
        File dataDir = new File(world.getWorldFolder(), "mcmmo_data");

        if (!dataDir.exists() || plugin == null) {
            return;
        }

        plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");

        BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
        converter.run();
        converters.add(converter);
    }

    /**
     * Monitor WorldUnload events.
     *<commit_msg>Little more cleaning.<commit_after>package com.gmail.nossr50.listeners;

import java.io.File;
import java.util.ArrayList;

import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldUnloadEvent;

import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;

public class WorldListener implements Listener {
    private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
    private final mcMMO plugin;

    public WorldListener(final mcMMO plugin) {
        this.plugin = plugin;
    }

    /**
     * Monitor StructureGrow events.
     *
     * @param event The event to watch
     */
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onStructureGrow(StructureGrowEvent event) {
        if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
            return;
        }

        for (BlockState blockState : event.getBlocks()) {
            mcMMO.getPlaceStore().setFalse(blockState);
        }
    }

    /**
     * Monitor WorldInit events.
     *
     * @param event The event to watch
     */
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onWorldInit(WorldInitEvent event) {
        World world = event.getWorld();

        if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || plugin == null) {
            return;
        }

        plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");

        BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
        converter.run();
        converters.add(converter);
    }

    /**
     * Monitor WorldUnload events.
     *
{'fraction_non_alphanumeric': 0.10684161199625117, 'fraction_numerical': 0.0028116213683223993, 'mean_word_length': 3.2647352647352648, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5449871', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1238, 'n_words': 253}