.kingdomdc.
📎 1 file 12,643 chars
📄
pasted-code-1795330467562.txt
txt 406 lines
▶
# Minecraft Plugin Development: High-Quality Image Billboards

I want you to develop a complete, production-ready Minecraft plugin that allows server administrators to display high-quality images in the Minecraft world as customizable billboards.

The plugin should be professionally engineered, highly optimized, user-friendly, and designed for large Minecraft servers.

This is not a basic proof of concept. I want a polished, fully functional plugin that prioritizes image quality, performance, reliability, and ease of use.

**Most importantly: I need you to actually develop the plugin, compile it, test it, and provide a downloadable `.jar` file that I can upload directly to my server. Do not just give me source code or instructions.**

## 1. Server Compatibility

Develop the plugin with the following environment in mind:

- Server software: Purpur / Paper.
- Target version: Minecraft 1.21.11+ and newer compatible versions where possible.
- Java: Java 25.
- Build system: Gradle or Maven.
- Plugin language: Java.
- Must support Paper and Purpur.
- Must be compatible with common server environments and plugin configurations.
- Avoid unnecessary dependencies.
- Use modern Minecraft APIs wherever possible.

Design the plugin so that it can be maintained and updated without requiring a complete rewrite for future Minecraft versions.

## 2. Image Display System

The primary purpose of this plugin is to display images in the Minecraft world as large, high-quality billboards.

Administrators should be able to upload images into a dedicated folder through their hosting panel.

Plugin directory:

`/plugins/ImageBillboards/images/`

Supported image formats:
- PNG
- JPG / JPEG
- WEBP if a reliable decoder is available.

The plugin should automatically detect images placed inside this directory.

Requirements:

- Automatically load images when the plugin starts.
- Support manually reloading images without restarting the server.
- Allow multiple images to be displayed simultaneously.
- Support large billboard dimensions.
- Preserve original aspect ratios unless an administrator explicitly chooses to stretch an image.
- Avoid unnecessary image compression and quality degradation.
- Support transparent PNG images wherever the Minecraft rendering system permits it.
- Automatically scale images to the appropriate display resolution.
- Provide smooth and accurate image rendering.
- Prevent distorted, stretched, or incorrectly aligned images.

### Image quality is extremely important.

I want the highest practical image quality possible within Minecraft's rendering limitations.

Do not simply shrink an entire image into one Minecraft map.

Instead, investigate and implement a tiled rendering system that divides larger images across multiple map textures or other suitable Minecraft rendering mechanisms.

Each tile should align perfectly with neighboring tiles to create one seamless image.

The plugin should:
- Maintain accurate colors.
- Minimize color banding.
- Use high-quality image resampling.
- Support configurable scaling algorithms.
- Avoid visible seams between image tiles.
- Preserve as much detail as Minecraft's client rendering system allows.

Be aware that Minecraft's standard map rendering has a 128 × 128 pixel resolution per map. Design around this limitation rather than promising unlimited native resolution.

Investigate the best available implementation for the target Minecraft versions, including map-based rendering, display entities, and packet-based approaches where appropriate.

## 3. Interactive Billboard Editing Tool

I want an in-game editing system that makes placing and resizing billboards extremely easy.

Administrators should receive a special editing tool through a command.

For example:

`/billboard tool`

The tool should allow administrators to:

1. Select an image from the available image folder.
2. Place the image in the Minecraft world.
3. Adjust its overall size.
4. Change its orientation.
5. Move it around.
6. Fine-tune its positioning.
7. Preview changes before saving.
8. Save the billboard permanently.

### Resizing functionality

This is one of the most important features.

I want to be able to resize billboards using an intuitive in-game tool rather than manually editing configuration files.

Implement a practical resizing interface with options such as:

- Increase width.
- Decrease width.
- Increase height.
- Decrease height.
- Increase both dimensions proportionally.
- Decrease both dimensions proportionally.
- Reset to original aspect ratio.
- Set exact dimensions.

Where possible, provide visual feedback while resizing.

For example, clicking with different mouse buttons or using a selection interface should adjust the billboard's dimensions.

Make the controls intuitive and document them clearly.

### Placement controls

The editing tool should support:

- Wall-mounted billboards.
- Freestanding billboards.
- Different horizontal and vertical orientations.
- Precise placement.
- Adjustable spacing between image tiles.
- Multiple billboards in the same area.

Billboards should be able to face different directions and should not be restricted to one orientation.

## 4. Image Management

Create a clean image management system.

Administrators should be able to:

- Upload images through the hosting panel.
- View available images.
- Select an image to display.
- Replace an image.
- Remove an image.
- Reload the image directory.
- See image dimensions and file information.

Images should be loaded from disk and cached efficiently.

Do not require administrators to upload images through an external website or use URLs.

The folder-based approach is essential because I want to manage everything through Pterodactyl.

Example:

`/plugins/ImageBillboards/images/advertisement.png`

I should be able to upload a new image into this folder, run a reload command, and immediately use it in-game.

If an image is replaced, the plugin should provide a way to refresh existing billboards displaying that image.

## 5. Performance and Optimization

Performance is extremely important.

This plugin will run on a multiplayer Minecraft server with many other plugins.

I want it engineered for minimal performance impact.

Requirements:

- No unnecessary synchronous image processing on the main server thread.
- Perform image decoding, resizing, and preprocessing asynchronously.
- Avoid repeatedly decoding the same image.
- Cache processed image tiles.
- Minimize unnecessary packet transmission.
- Avoid excessive entity creation.
- Avoid unnecessary scheduled tasks.
- Clean up resources when billboards are removed.
- Prevent memory leaks.
- Properly manage image caches.
- Avoid excessive disk operations.
- Avoid loading images that are not needed.
- Handle large images safely without crashing the server.

Do not introduce unnecessary ticking tasks for static billboards.

Static images should be rendered once and remain visible without continuously updating them.

Use efficient packet handling and caching where appropriate.

Ensure that multiple players viewing the same billboard do not cause redundant image processing.

Provide configurable limits for:
- Maximum image dimensions.
- Maximum image file size.
- Maximum billboard dimensions.
- Maximum cached image data.
- Maximum active billboards.

Make sure these limits are configurable rather than hardcoded.

## 6. Commands

Implement a complete command system.

Suggested commands:

`/billboard`
- Display the main help menu.

`/billboard tool`
- Give the administrator the editing tool.

`/billboard create `
- Start creating a billboard using an image.

`/billboard list`
- List all existing billboards.

`/billboard remove `
- Remove a billboard.

`/billboard reload`
- Reload image files and configuration.

`/billboard resize `
- Open the resizing interface.

`/billboard info `
- Display information about a billboard.

`/billboard move `
- Enter editing mode to reposition a billboard.

`/billboard deleteall`
- Remove all billboards after confirmation.

Include tab completion and useful error messages.

## 7. Permissions

Implement permission-based access.

Suggested permissions:

- `imagebillboards.admin` — Full administrative access.
- `imagebillboards.create` — Create billboards.
- `imagebillboards.edit` — Edit and resize billboards.
- `imagebillboards.remove` — Remove billboards.
- `imagebillboards.reload` — Reload images and configuration.

Integrate with LuckPerms through standard Bukkit permissions.

Only authorized users should be able to modify billboards.

The editing tool must not allow ordinary players to create or modify billboards.

## 8. Persistence and Reliability

All billboard placements must persist across server restarts.

Store:
- Billboard IDs.
- Image filenames.
- World names.
- Coordinates.
- Orientation.
- Width and height.
- Rendering settings.
- Other necessary placement information.

Use a reliable storage format such as YAML or JSON.

Requirements:
- Automatically save changes.
- Restore billboards after restart.
- Handle missing image files gracefully.
- Handle unloaded chunks.
- Avoid duplicate billboards after reloads.
- Handle deleted worlds safely.
- Provide useful console errors when something goes wrong.

Never allow a malformed image or configuration file to crash the entire server.

## 9. User Interface and Polish

I want this plugin to feel like a premium, professionally developed Minecraft plugin.

The editing process should be straightforward.

Provide:
- Clear command feedback.
- Helpful error messages.
- Visual editing feedback.
- Informative action bar messages where appropriate.
- Configurable messages.
- Clean configuration files.
- Professional documentation.

Do not make the editing process unnecessarily complicated.

Prioritize usability for server administrators who are not developers.

## 10. Configuration

Create a well-organized configuration file.

Include settings for:
- Image loading.
- Image processing.
- Rendering quality.
- Billboard size limits.
- Maximum image file size.
- Cache settings.
- Performance settings.
- Permissions where appropriate.
- Messages.
- Debug logging.

Include comments explaining every important setting.

Use sensible defaults so the plugin works immediately after installation.

## 11. Development and Testing Requirements

I want an actual finished plugin, not a theoretical implementation.

Before considering the project complete:

1. Create the entire project structure.
2. Implement every core feature.
3. Compile the plugin successfully.
4. Resolve all compilation errors.
5. Test image loading.
6. Test image resizing.
7. Test billboard placement.
8. Test billboard persistence after restarting.
9. Test multiple simultaneous billboards.
10. Test permissions.
11. Test image replacement and reloading.
12. Test error handling for invalid images.
13. Review performance and memory usage.
14. Ensure there are no obvious resource leaks.

Do not claim that something was tested if it was not actually tested.

If a feature cannot be fully implemented because of Minecraft API limitations, explain the limitation and implement the best practical alternative.

## 12. Final Deliverables

I expect the following:

**1. Downloadable plugin JAR**

The most important deliverable.

Provide a compiled `.jar` file that I can download and upload directly into:

`/plugins/`

**2. Complete source code**

Provide the entire project source code, not just selected classes.

**3. Default configuration**

Provide a working default configuration.

**4. README**

Include:
- Installation instructions.
- Supported Minecraft versions.
- Commands.
- Permissions.
- Image upload instructions.
- Billboard editing instructions.
- Troubleshooting.

**5. Build instructions**

Explain how to compile the plugin independently.

## 13. Final Instructions

Work independently and make reasonable engineering decisions.

Do not stop after creating a project outline or explaining how the plugin could work.

Actually build the plugin.

Prioritize these features in this order:

1. Highest practical image quality.
2. Reliable billboard placement and rendering.
3. Intuitive in-game resizing and editing.
4. Folder-based image management.
5. Excellent performance and memory efficiency.
6. Long-term compatibility and maintainability.

I want a premium-quality Minecraft image billboard plugin that feels comparable to established commercial plugins.

**The final response must include a working downloadable JAR file and the complete source code. Do not consider the task finished until the JAR has successfully compiled.**
Kodari AI
KodariToday at 6:56 am 4
ImageBillboards
A premium Minecraft plugin for displaying high-quality images as tiled billboards in the world. Features folder-based image management with automatic loading from /plugins/ImageBillboards/images/, asynchronous image processing with caching, and seamless tiled rendering using 128x128 map textures. Includes an intuitive in-game editing tool with interactive resizing, positioning, and orientation controls. Supports wall-mounted and freestanding billboards with configurable dimensions, aspect ratio preservation, and high-quality resampling. Provides complete command system with tab completion, permission-based access, persistent YAML storage, and comprehensive configuration. Optimized for Paper/Purpur 1.21.11+ with minimal performance impact.

I’ll build the billboard system around tiled 128×128 maps, with folder-based images, persistent placements, and in-game editing. Map colors and transparency remain subject to Minecraft’s map-rendering limits.

Created the source project with tiled map rendering, image-folder management, persistent billboard data, permissions, and an in-game resizing menu.

The JAR has not been compiled or tested, so I can’t claim it is production-ready or provide a verified download yet. The current editor applies changes immediately rather than previewing them, and placement is limited to vertical, cardinal-facing billboards.

To build it in Kodari, click Compile → Compile, then download the JAR if the build succeeds. On mobile, use ⋮ → Compile Project.

.kingdomdc.

what image format do they need to be

Kodari AI
KodariToday at 7:24 am 1

Use PNG or JPG/JPEG. PNG is a good choice for sharp graphics and images with transparency.

Place the files in plugins/ImageBillboards/images/, then run /billboard reload.

WebP works only if the server’s Java installation has a compatible decoder.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
6 497
src/main/java/com/kodari/billboards/ImageBillboards.java
package com.kodari.billboards;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
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.entity.EntityDamageByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;

public final class ImageBillboards extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private final Map<String, Board> boards = new LinkedHashMap<>();
    private final Map<UUID, Session> sessions = new HashMap<>();
    private final Map<String, List<BufferedImage>> cache = new LinkedHashMap<>(16, 0.75f, true);
    private final AtomicLong generation = new AtomicLong();
    private ExecutorService worker;
    private File images;
    private File storage;
    private NamespacedKey frameKey;
    private NamespacedKey toolKey;
    private volatile List<String> imageNames = Collections.emptyList();
    private long cachedBytes;

    @Override public void onEnable() {
        saveDefaultConfig();
        images = new File(getDataFolder(), "images");
        if (!images.isDirectory() && !images.mkdirs()) getLogger().warning("Could not create images directory");
        storage = new File(getDataFolder(), "billboards.yml");
        frameKey = new NamespacedKey(this, "billboard");
        toolKey = new NamespacedKey(this, "tool");
        worker = Executors.newSingleThreadExecutor(r -> { Thread t = new Thread(r, "Billboard-image-worker"); t.setDaemon(true); return t; });
        Bukkit.getPluginManager().registerEvents(this, this);
        getCommand("billboard").setExecutor(this);
        getCommand("billboard").setTabCompleter(this);
        load();
        scan();
        for (Board board : boards.values()) render(board);
    }

    @Override public void onDisable() {
        generation.incrementAndGet();
        if (worker != null) worker.shutdownNow();
        save();
        synchronized (cache) { cache.clear(); cachedBytes = 0; }
    }

    private String color(String text) { return ChatColor.translateAlternateColorCodes('&', text); }
    private void msg(CommandSender sender, String text) { sender.sendMessage(color(getConfig().getString("messages.prefix", "&8[&bBillboards&8] &7") + text)); }
    private boolean allowed(CommandSender sender, String permission) {
        if (sender.hasPermission(permission) || sender.hasPermission("imagebillboards.admin")) return true;
        msg(sender, getConfig().getString("messages.no-permission", "&cYou do not have permission.")); return false;
    }
    private boolean viewer(CommandSender s) {
        return s.hasPermission("imagebillboards.admin") || s.hasPermission("imagebillboards.create") || s.hasPermission("imagebillboards.edit") || s.hasPermission("imagebillboards.remove") || s.hasPermission("imagebillboards.reload");
    }
    private int limit(String key, int fallback) { return Math.max(1, getConfig().getInt("limits." + key, fallback)); }
    private boolean validSize(int w, int h) {
        return w > 0 && h > 0 && w <= limit("max-width-tiles", 16) && h <= limit("max-height-tiles", 16) && (long) w * h <= limit("max-tiles-per-billboard", 128);
    }
    private static final class Board {
        String id, image, world;
        int x, y, z, width, height;
        BlockFace face;
        boolean stretch;
        long revision;
        final List<UUID> frames = new ArrayList<>();
    }
    private static final class Session {
        String image, moving;
    }
    private static final class Editor implements InventoryHolder {
        final String id;
        Inventory inventory;
        Editor(String id) { this.id = id; }
        @Override public Inventory getInventory() { return inventory; }
    }
    private void load() {
        YamlConfiguration yaml = YamlConfiguration.loadConfiguration(storage);
        ConfigurationSection root = yaml.getConfigurationSection("billboards");
        if (root == null) return;
        for (String id : root.getKeys(false)) {
            try {
                ConfigurationSection s = root.getConfigurationSection(id);
                if (s == null) continue;
                Board b = new Board(); b.id = id; b.image = s.getString("image"); b.world = s.getString("world");
                b.x = s.getInt("x"); b.y = s.getInt("y"); b.z = s.getInt("z"); b.width = s.getInt("width"); b.height = s.getInt("height");
                b.face = BlockFace.valueOf(s.getString("face", "NORTH")); b.stretch = s.getBoolean("stretch");
                if (b.image == null || b.world == null || !horizontal(b.face) || !validSize(b.width, b.height)) throw new IllegalArgumentException("invalid fields or dimensions");
                for (String uuid : s.getStringList("frames")) try { b.frames.add(UUID.fromString(uuid)); } catch (IllegalArgumentException ignored) { }
                boards.put(id, b);
            } catch (RuntimeException ex) { getLogger().warning("Skipping billboard " + id + ": " + ex.getMessage()); }
        }
    }
    private void save() {
        YamlConfiguration yaml = new YamlConfiguration();
        for (Board b : boards.values()) {
            String p = "billboards." + b.id + ".";
            yaml.set(p + "image", b.image); yaml.set(p + "world", b.world); yaml.set(p + "x", b.x); yaml.set(p + "y", b.y); yaml.set(p + "z", b.z);
            yaml.set(p + "width", b.width); yaml.set(p + "height", b.height); yaml.set(p + "face", b.face.name()); yaml.set(p + "stretch", b.stretch);
            List<String> ids = new ArrayList<>(); for (UUID uuid : b.frames) ids.add(uuid.toString()); yaml.set(p + "frames", ids);
        }
        try { yaml.save(storage); } catch (IOException ex) { getLogger().severe("Could not save billboards: " + ex.getMessage()); }
    }
    private void scan() {
        worker.execute(() -> {
            File[] files = images.listFiles(f -> f.isFile() && supported(f.getName()));
            List<String> names = new ArrayList<>();
            if (files != null) for (File f : files) names.add(f.getName());
            names.sort(String.CASE_INSENSITIVE_ORDER); imageNames = Collections.unmodifiableList(names);
        });
    }
    private boolean supported(String name) {
        String n = name.toLowerCase(Locale.ROOT); return n.endsWith(".png") || n.endsWith(".jpg") || n.endsWith(".jpeg") || n.endsWith(".webp");
    }
    private File imageFile(String name) throws IOException {
        File file = new File(images, name).getCanonicalFile();
        if (!file.getParentFile().equals(images.getCanonicalFile()) || !supported(name) || !file.isFile()) throw new IOException("Image not found: " + name);
        return file;
    }
    private List<BufferedImage> process(String name, int w, int h, boolean stretch, int maxW, int maxH, long maxPixels, long maxBytes, String scaling, long cacheLimit) throws IOException {
        File file = imageFile(name);
        long fileSize = Files.size(file.toPath());
        if (fileSize > maxBytes) throw new IOException("Image exceeds file-size limit");
        String key = name + "|" + file.lastModified() + "|" + fileSize + "|" + w + "|" + h + "|" + stretch + "|" + scaling;
        synchronized (cache) { List<BufferedImage> hit = cache.get(key); if (hit != null) return hit; }
        BufferedImage source;
        try (ImageInputStream in = ImageIO.createImageInputStream(file)) {
            if (in == null) throw new IOException("Cannot open image");
            Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
            if (!readers.hasNext()) throw new IOException("No decoder for this image format");
            ImageReader reader = readers.next();
            try {
                reader.setInput(in, true, true);
                int iw = reader.getWidth(0), ih = reader.getHeight(0);
                if (iw <= 0 || ih <= 0 || iw > maxW || ih > maxH || (long) iw * ih > maxPixels) throw new IOException("Image exceeds dimension or pixel limits");
                source = reader.read(0);
            } finally { reader.dispose(); }
        }
        if (source == null) throw new IOException("Image decode failed");
        int tw = w * 128, th = h * 128;
        int dw = tw, dh = th;
        if (!stretch) { double factor = Math.min((double) tw / source.getWidth(), (double) th / source.getHeight()); dw = Math.max(1, (int) Math.round(source.getWidth() * factor)); dh = Math.max(1, (int) Math.round(source.getHeight() * factor)); }
        BufferedImage scaled = new BufferedImage(tw, th, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = scaled.createGraphics();
        Object interpolation = scaling.equalsIgnoreCase("NEAREST") ? RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR : scaling.equalsIgnoreCase("BILINEAR") ? RenderingHints.VALUE_INTERPOLATION_BILINEAR : RenderingHints.VALUE_INTERPOLATION_BICUBIC;
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolation); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);