<commit_before>
package io.github.satoshinm.WebSandboxMC;

import io.github.satoshinm.WebSandboxMC.bridge.BlockBridge;
import io.github.satoshinm.WebSandboxMC.bridge.PlayersBridge;
import io.github.satoshinm.WebSandboxMC.bridge.WebPlayerBridge;
import io.github.satoshinm.WebSandboxMC.bukkit.BlockListener;
import io.github.satoshinm.WebSandboxMC.bukkit.EntityListener;
import io.github.satoshinm.WebSandboxMC.bukkit.PlayersListener;
import io.github.satoshinm.WebSandboxMC.bukkit.WsCommand;
import io.github.satoshinm.WebSandboxMC.ws.WebSocketServerThread;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

/**
 * Bukkit plugin class for WebSandboxMC
 *
 * Based on: https://github.com/bukkit/SamplePlugin/
 *
 * Sample plugin for Bukkit
 *
 * @author Dinnerbone
 */
public class WebSandboxPlugin extends JavaPlugin {
    private WebSocketServerThread webSocketServerThread;

    private int httpPort = 4081;
    private boolean takeover = false;
    private String unbindMethod = "console.getServerConnection.b";

    private boolean debug = false;
    private String entityClassName = "Sheep";
    private boolean setCustomNames = true;
    private boolean disableGravity = true;
    private boolean disableAI = true;
    private boolean entityMoveSandbox = true;
    private boolean entityDieDisconnect = false;

    // Send blocks around this area in the Bukkit world
    private String world = "";
    private int x_center = 0;
    private int y_center = 75;
    private int z_center = 0;

    // of this radius, +/-
    private int radius = 16;

    // raised this amount in the web world, so it is clearly distinguished from the client-generated terrain
    private int y_offset = 20;

    private boolean allowBreakPlaceBlocks = true;
    private boolean allowSigns = true;
    private boolean allowChatting = true;
    private boolean seeChat = true;
    private boolean seePlayers = true;

    private Map<String, Object> blocksToWeb = new HashMap<String, Object>();
    private boolean warnMissing = true;

    @Override
    public void onDisable() {
        webSocketServerThread.webPlayerBridge.deleteAllEntities();

        webSocketServerThread.interrupt();
    }

    @Override
    public void onEnable() {
        // Configuration
        final FileConfiguration config = getConfig();
        config.options().copyDefaults(true);

        config.addDefault("http.port", httpPort);
        config.addDefault("http.takeover", takeover);
        config.addDefault("http.unbind_method", unbindMethod);

        config.addDefault("mc.debug", debug);
        config.addDefault("mc.entity", entityClassName);
        config.addDefault("mc.entity_custom_names", setCustomNames);
        config.addDefault("mc.entity_disable_gravity", disableGravity);
        config.addDefault("mc.entity_disable_ai", disableAI);
        config.addDefault("mc.entity_move_sandbox", entityMoveSandbox);
        config.addDefault("mc.entity_die_disconnect", entityDieDisconnect);
        config.addDefault("mc.world", world);
        config.addDefault("mc.x_center", x_center);
        config.addDefault("mc.y_center", y_center);
        config.addDefault("mc.z_center", z_center);
        config.addDefault("mc.radius", radius);

        config.addDefault("nc.y_offset", y_offset);
        config.addDefault("nc.allow_break_place_blocks", allowBreakPlaceBlocks);
        config.addDefault("nc.allow_signs", allowSigns);
        config.addDefault("nc.allow_chatting", allowChatting);
        config.addDefault("nc.see_chat", seeChat);
        config.addDefault("nc.see_players", seePlayers);
        blocksToWeb.put("missing", 16); // unknown/unsupported becomes cloud
        blocksToWeb.put("AIR", 0);
        blocksToWeb.put("GRASS", 1);
        blocksToWeb.put("SAND", 2);
        blocksToWeb.put("SMOOTH_BRICK", 3);
        blocksToWeb.put("BRICK", 4);
        blocksToWeb.put("LOG", 5);
        blocksToWeb.put("LOG_2", 5); // wood
        // TODO: ores, for now, showing as stone
        blocksToWeb.put("COAL_ORE", 6);
        blocksToWeb.put("IRON_ORE", 6);
        blocksToWeb.put("DIAMOND_ORE", 6);
        blocksToWeb.put("EMERALD_ORE", 6);
        blocksToWeb.put("REDSTONE_ORE", 6);
        blocksToWeb.put("GLOWING_REDSTONE_ORE", 6);
        blocksToWeb.put("LAPIS_ORE", 6);
        blocksToWeb.put("QUARTZ_ORE", 6);
        blocksToWeb.put("GOLD_ORE", 6);
        blocksToWeb.put("STONE", 6); // cement, close enough

        blocksToWeb.put("GRAVEL", 7);
        blocksToWeb.put("DIRT", 7);

        blocksToWeb.put("WOOD", 8); // plank

        blocksToWeb.put("SNOW", 9);
        blocksToWeb.put("SNOW_BLOCK", 9);

        blocksToWeb.put("GLASS", 10);
        blocksToWeb.put("COBBLESTONE", 11);
        // TODO",  light stone (12));
        // TODO",  dark stone (13));
        blocksToWeb.put("CHEST", 14);
        blocksToWeb.put("LEAVES", 15);
        blocksToWeb.put("LEAVES_2", 15);
        // TODO",  cloud (16));
        blocksToWeb.put("DOUBLE_PLANT", 17);  // TODO: other double plants, but a lot look like longer long grass
        blocksToWeb.put("LONG_GRASS", 17); // tall grass
        blocksToWeb.put("YELLOW_FLOWER", 18);
        blocksToWeb.put("RED_ROSE", 19);
        blocksToWeb.put("CHORUS_FLOWER", 20);
        // TODO",  sunflower (21));
        // TODO",  white flower (22));
        // TODO",  blue flower (23));

        blocksToWeb.put("WOOL", 61); // note: special case

        blocksToWeb.put("WALL_SIGN", 0); // air, since text is written on block behind it
        blocksToWeb.put("SIGN_POST", 8); // plank TODO",  sign post model<commit_msg>Add ores: gold, iron, coal, lapis<commit_after>
package io.github.satoshinm.WebSandboxMC;

import io.github.satoshinm.WebSandboxMC.bridge.BlockBridge;
import io.github.satoshinm.WebSandboxMC.bridge.PlayersBridge;
import io.github.satoshinm.WebSandboxMC.bridge.WebPlayerBridge;
import io.github.satoshinm.WebSandboxMC.bukkit.BlockListener;
import io.github.satoshinm.WebSandboxMC.bukkit.EntityListener;
import io.github.satoshinm.WebSandboxMC.bukkit.PlayersListener;
import io.github.satoshinm.WebSandboxMC.bukkit.WsCommand;
import io.github.satoshinm.WebSandboxMC.ws.WebSocketServerThread;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

/**
 * Bukkit plugin class for WebSandboxMC
 *
 * Based on: https://github.com/bukkit/SamplePlugin/
 *
 * Sample plugin for Bukkit
 *
 * @author Dinnerbone
 */
public class WebSandboxPlugin extends JavaPlugin {
    private WebSocketServerThread webSocketServerThread;

    private int httpPort = 4081;
    private boolean takeover = false;
    private String unbindMethod = "console.getServerConnection.b";

    private boolean debug = false;
    private String entityClassName = "Sheep";
    private boolean setCustomNames = true;
    private boolean disableGravity = true;
    private boolean disableAI = true;
    private boolean entityMoveSandbox = true;
    private boolean entityDieDisconnect = false;

    // Send blocks around this area in the Bukkit world
    private String world = "";
    private int x_center = 0;
    private int y_center = 75;
    private int z_center = 0;

    // of this radius, +/-
    private int radius = 16;

    // raised this amount in the web world, so it is clearly distinguished from the client-generated terrain
    private int y_offset = 20;

    private boolean allowBreakPlaceBlocks = true;
    private boolean allowSigns = true;
    private boolean allowChatting = true;
    private boolean seeChat = true;
    private boolean seePlayers = true;

    private Map<String, Object> blocksToWeb = new HashMap<String, Object>();
    private boolean warnMissing = true;

    @Override
    public void onDisable() {
        webSocketServerThread.webPlayerBridge.deleteAllEntities();

        webSocketServerThread.interrupt();
    }

    @Override
    public void onEnable() {
        // Configuration
        final FileConfiguration config = getConfig();
        config.options().copyDefaults(true);

        config.addDefault("http.port", httpPort);
        config.addDefault("http.takeover", takeover);
        config.addDefault("http.unbind_method", unbindMethod);

        config.addDefault("mc.debug", debug);
        config.addDefault("mc.entity", entityClassName);
        config.addDefault("mc.entity_custom_names", setCustomNames);
        config.addDefault("mc.entity_disable_gravity", disableGravity);
        config.addDefault("mc.entity_disable_ai", disableAI);
        config.addDefault("mc.entity_move_sandbox", entityMoveSandbox);
        config.addDefault("mc.entity_die_disconnect", entityDieDisconnect);
        config.addDefault("mc.world", world);
        config.addDefault("mc.x_center", x_center);
        config.addDefault("mc.y_center", y_center);
        config.addDefault("mc.z_center", z_center);
        config.addDefault("mc.radius", radius);

        config.addDefault("nc.y_offset", y_offset);
        config.addDefault("nc.allow_break_place_blocks", allowBreakPlaceBlocks);
        config.addDefault("nc.allow_signs", allowSigns);
        config.addDefault("nc.allow_chatting", allowChatting);
        config.addDefault("nc.see_chat", seeChat);
        config.addDefault("nc.see_players", seePlayers);
        blocksToWeb.put("missing", 16); // unknown/unsupported becomes cloud
        blocksToWeb.put("AIR", 0);
        blocksToWeb.put("GRASS", 1);
        blocksToWeb.put("SAND", 2);
        blocksToWeb.put("SMOOTH_BRICK", 3);
        blocksToWeb.put("BRICK", 4);
        blocksToWeb.put("LOG", 5);
        blocksToWeb.put("LOG_2", 5); // wood

        blocksToWeb.put("GOLD_ORE", 70);
        blocksToWeb.put("IRON_ORE", 71);
        blocksToWeb.put("COAL_ORE", 72);
        blocksToWeb.put("LAPIS_ORE", 73);
        blocksToWeb.put("LAPIS_BLOCK", 74);
        // TODO: more ores, for now, showing as stone
        blocksToWeb.put("DIAMOND_ORE", 6);
        blocksToWeb.put("EMERALD_ORE", 6);
        blocksToWeb.put("REDSTONE_ORE", 6);
        blocksToWeb.put("GLOWING_REDSTONE_ORE", 6);
        blocksToWeb.put("QUARTZ_ORE", 6);
        blocksToWeb.put("STONE", 6); // cement, close enough

        blocksToWeb.put("GRAVEL", 7);
        blocksToWeb.put("DIRT", 7);

        blocksToWeb.put("WOOD", 8); // plank

        blocksToWeb.put("SNOW", 9);
        blocksToWeb.put("SNOW_BLOCK", 9);

        blocksToWeb.put("GLASS", 10);
        blocksToWeb.put("COBBLESTONE", 11);
        // TODO",  light stone (12));
        // TODO",  dark stone (13));
        blocksToWeb.put("CHEST", 14);
        blocksToWeb.put("LEAVES", 15);
        blocksToWeb.put("LEAVES_2", 15);
        // TODO",  cloud (16));
        blocksToWeb.put("DOUBLE_PLANT", 17);  // TODO: other double plants, but a lot look like longer long grass
        blocksToWeb.put("LONG_GRASS", 17); // tall grass
        blocksToWeb.put("YELLOW_FLOWER", 18);
        blocksToWeb.put("RED_ROSE", 19);
        blocksToWeb.put("CHORUS_FLOWER", 20);
        // TODO",  sunflower (21));
        // TODO",  white flower (22));
        // TODO",  blue flower (23));

        blocksToWeb.put("WOOL", 61); // note: special case

        blocksToWeb.put("WALL_SIGN", 0); // air, since text is written on block behind it
        blocksToWeb.put("SIGN_POST", 8); // plank TODO",  sign post model
{'fraction_non_alphanumeric': 0.12165709598031173, 'fraction_numerical': 0.012633305988515177, 'mean_word_length': 3.3711007529580495, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '6079496', 'n_tokens_mistral': 3948, 'n_tokens_neox': 3664, 'n_words': 785}