<commit_before>package org.dynmap.regions;

import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.bukkit.World;
import org.bukkit.util.config.Configuration;
import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapPlugin;
import org.dynmap.Log;
import org.dynmap.utils.TileFlags;

public class TownyConfigHandler {
    private int townblocksize;  /* Size of each block - default is 16x16 */
    
    public TownyConfigHandler(ConfigurationNode cfg) {
        /* Find path to Towny base configuration */
        File cfgfile = new File("plugins/Towny/settings/config.yml");
        if(cfgfile.canRead() == false) {    /* Can't read config */
            Log.severe("Cannot find Towny file - " + cfgfile.getPath());
            return;
        }
        Configuration tcfg = new Configuration(cfgfile);
        tcfg.load();
        townblocksize = tcfg.getInt("town_block_size", 16); /* Get block size */        
    }
    /**
     * Get map of attributes for given world
     */
    public Map<String, Object> getRegionData(String wname) {
        Map<String, Object> rslt = new HashMap<String, Object>();
        Properties p = new Properties();
        FileInputStream fis = null;
        /* Read world data for this world */
        try {
            fis = new FileInputStream("plugins/Towny/data/worlds/" + wname + ".txt");    /* Open and load file */
            p.load(fis);
        } catch (IOException iox) {
            Log.severe("Error loading Towny world file " + wname + ".txt");
        } finally {
            if(fis != null) {
                try { fis.close(); } catch (IOException iox) {}
            }
        }
        /* Get towns list for our world */
        String t = p.getProperty("towns", "");
        String towns[] = t.split(",");	/* Split on commas */
        /* List towns directory - process all towns there */
        for(String town : towns) {
        	town = town.trim();
        	if(town.length() == 0) continue;<commit_msg>Fix handling of non-standard town_block_size values<commit_after>package org.dynmap.regions;

import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.bukkit.World;
import org.bukkit.util.config.Configuration;
import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapPlugin;
import org.dynmap.Log;
import org.dynmap.utils.TileFlags;

public class TownyConfigHandler {
    private int townblocksize;  /* Size of each block - default is 16x16 */
    
    public TownyConfigHandler(ConfigurationNode cfg) {
        /* Find path to Towny base configuration */
        File cfgfile = new File("plugins/Towny/settings/config.yml");
        if(cfgfile.canRead() == false) {    /* Can't read config */
            Log.severe("Cannot find Towny file - " + cfgfile.getPath());
            return;
        }
        Configuration tcfg = new Configuration(cfgfile);
        tcfg.load();
        String tbsize = tcfg.getNode("town").getString("town_block_size", "16");
        try {
            townblocksize = Integer.valueOf(tbsize);
        } catch (NumberFormatException nfx) {
            townblocksize = 16;
        }
    }
    /**
     * Get map of attributes for given world
     */
    public Map<String, Object> getRegionData(String wname) {
        Map<String, Object> rslt = new HashMap<String, Object>();
        Properties p = new Properties();
        FileInputStream fis = null;
        /* Read world data for this world */
        try {
            fis = new FileInputStream("plugins/Towny/data/worlds/" + wname + ".txt");    /* Open and load file */
            p.load(fis);
        } catch (IOException iox) {
            Log.severe("Error loading Towny world file " + wname + ".txt");
        } finally {
            if(fis != null) {
                try { fis.close(); } catch (IOException iox) {}
            }
        }
        /* Get towns list for our world */
        String t = p.getProperty("towns", "");
        String towns[] = t.split(",");	/* Split on commas */
        /* List towns directory - process all towns there */
        for(String town : towns) {
        	town = town.trim();
        	if(town.length() == 0) continue;
{'fraction_non_alphanumeric': 0.12121862261317314, 'fraction_numerical': 0.0034327397554172923, 'mean_word_length': 2.4054054054054053, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3629480', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1325, 'n_words': 362}