Algerian Rubiks

Can you make a functional minecr1ft whiteboard that you can write in it using the red or blue or green or black whiteboard with thier wiper to erase the writing things in the whiteboard with thier crafting recipes

Kodari AI
KodariTue at 7:09 pm 2
WhiteboardCraft
A Minecraft plugin that adds functional whiteboards with colored markers (red, blue, green, black) and erasers. Players can place whiteboards on walls, write text on them using markers, and erase content with wipers. Includes custom crafting recipes for all items. Markers have durability and can be refilled. Whiteboards support multiple lines of text with color coding. Erasers clear entire boards or selective lines. All items are fully configurable with permissions and world-guard support.

I’ll build placeable whiteboard tiles, four craftable pens, and an eraser. Writing will work one tile at a time, so you can assemble a board of any size.

Built a tile-based whiteboard: place tiles together, then right-click them with a pen to color them or an eraser to clear them. Boards persist across restarts.

Recipes

  • 8 tiles: surround paper with 8 white concrete.

  • Pen: combine a stick with red, blue, green, or black dye.

  • Eraser: combine a stick with a sponge.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 172
src/main/java/com/kodari/whiteboard/WhiteboardPlugin.java
package com.kodari.whiteboard;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public final class WhiteboardPlugin extends JavaPlugin implements Listener {
    private final Set<String> boards = new HashSet<>();
    private NamespacedKey itemKey;
    private File boardsFile;

    @Override
    public void onEnable() {
        itemKey = new NamespacedKey(this, "whiteboard_item");
        boardsFile = new File(getDataFolder(), "boards.yml");
        boards.addAll(YamlConfiguration.loadConfiguration(boardsFile).getStringList("boards"));
        registerRecipes();
        getServer().getPluginManager().registerEvents(this, this);
    }

    private Material material(String name) {
        return XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial)
                .orElseThrow(() -> new IllegalStateException("Missing material: " + name));
    }

    private ItemStack item(String type, String materialName, String name, int amount) {
        ItemStack item = new ItemStack(material(materialName), amount);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(name);
        meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, type);
        item.setItemMeta(meta);
        return item;
    }

    private String type(ItemStack item) {
        if (item == null || !item.hasItemMeta()) return null;
        return item.getItemMeta().getPersistentDataContainer().get(itemKey, PersistentDataType.STRING);
    }

    private void registerRecipes() {
        ShapedRecipe board = new ShapedRecipe(new NamespacedKey(this, "board"),
                item("board", "WHITE_CONCRETE", "§fWhiteboard Tile", 8));
        board.shape("CCC", "CPC", "CCC");
        board.setIngredient('C', material("WHITE_CONCRETE"));
        board.setIngredient('P', material("PAPER"));
        getServer().addRecipe(board);

        for (String color : Arrays.asList("RED", "BLUE", "GREEN", "BLACK")) {
            String id = color.toLowerCase(java.util.Locale.ROOT);
            ShapelessRecipe pen = new ShapelessRecipe(new NamespacedKey(this, id + "_pen"),
                    item(id, color + "_DYE", "§f" + Character.toUpperCase(id.charAt(0)) + id.substring(1) + " Whiteboard Pen", 1));
            pen.addIngredient(material(color + "_DYE"));
            pen.addIngredient(material("STICK"));
            getServer().addRecipe(pen);
        }
        ShapelessRecipe eraser = new ShapelessRecipe(new NamespacedKey(this, "eraser"),
                item("eraser", "SPONGE", "§fWhiteboard Eraser", 1));
        eraser.addIngredient(material("SPONGE"));
        eraser.addIngredient(material("STICK"));
        getServer().addRecipe(eraser);
    }

    private String key(Block block) {
        return block.getWorld().getUID() + ":" + block.getX() + ":" + block.getY() + ":" + block.getZ();
    }

    private void saveBoards() {
        if (!getDataFolder().exists() && !getDataFolder().mkdirs()) {
            getLogger().warning("Could not create the plugin data directory.");
            return;
        }
        YamlConfiguration data = new YamlConfiguration();
        data.set("boards", new java.util.ArrayList<>(boards));
        try {
            data.save(boardsFile);
        } catch (IOException e) {
            getLogger().severe("Could not save whiteboards: " + e.getMessage());
        }
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlace(BlockPlaceEvent event) {
        if ("board".equals(type(event.getItemInHand()))) {
            boards.add(key(event.getBlockPlaced()));
            saveBoards();
        }
    }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onBreak(BlockBreakEvent event) {
        if (boards.contains(key(event.getBlock()))) event.setDropItems(false);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onBroken(BlockBreakEvent event) {
        Block block = event.getBlock();
        if (!boards.remove(key(block))) return;
        saveBoards();
        if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
            block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5),
                    item("board", "WHITE_CONCRETE", "§fWhiteboard Tile", 1));
        }
    }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onInteract(PlayerInteractEvent event) {
        if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getHand() != EquipmentSlot.HAND) return;
        Block block = event.getClickedBlock();
        if (block == null || !boards.contains(key(block))) return;
        String pen = type(event.getItem());
        if (pen == null) return;
        String color;
        switch (pen) {
            case "red": color = "RED_CONCRETE"; break;
            case "blue": color = "BLUE_CONCRETE"; break;
            case "green": color = "GREEN_CONCRETE"; break;
            case "black": color = "BLACK_CONCRETE"; break;
            case "eraser": color = "WHITE_CONCRETE"; break;
            default: return;
        }
        event.setCancelled(true);
        block.setType(material(color), false);
    }
}