rafixono

crate a diddy mansion

Kodari AI
KodariAug 13 at 12:00 pm 1
DiddyMansion
DiddyMansion is a Minecraft plugin that transforms any player-built structure into an interactive celebrity mansion experience. Players can construct themed mansion rooms using special blocks that trigger custom animations, sounds, and particle effects when entered. The plugin features a VIP room system where mansion owners can designate exclusive areas requiring special permissions. It includes a party system allowing players to host social gatherings with customizable music playlists, dance floor light shows, and refreshment dispensing stations that automatically refill food and potions. Mansion owners can set entry fees and manage guest lists through an intuitive command interface. NPC butlers guide visitors through the mansion, providing tours and historical facts. Security guards patrol perimeters and can ban unwanted players. The plugin tracks visitor statistics, popularity rankings, and mansion ratings, displayed on leaderboards. It includes decorative furniture crafting recipes, customizable wallpaper patterns, and hidden secret passages activated by lever combinations.
  1. Create the Gradle Bukkit plugin project and metadata.

  2. Add /diddymansion to generate a furnished, three-story mansion with a pool and cross-version material fallbacks.

Created a complete DiddyMansion Bukkit plugin.

  • /diddymansion builds a three-story mansion.

  • /diddymansion 2 builds a larger version.

  • Includes windows, entrance, balcony, lighting, interior details, and pool.

  • Materials use cross-version name fallbacks.

  • Permission: diddymansion.build (default: operators).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 240
src/main/java/com/kodari/diddymansion/DiddyMansion.java
package com.kodari.diddymansion;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class DiddyMansion extends JavaPlugin implements CommandExecutor {
    private Material foundation;
    private Material wall;
    private Material trim;
    private Material floor;
    private Material glass;
    private Material roof;
    private Material light;
    private Material door;
    private Material water;

    @Override
    public void onEnable() {
        foundation = resolve("STONE_BRICKS", "COBBLESTONE");
        wall = resolve("WHITE_CONCRETE", "QUARTZ_BLOCK");
        trim = resolve("SPRUCE_PLANKS", "OAK_PLANKS");
        floor = resolve("DARK_OAK_PLANKS", "OAK_PLANKS");
        glass = resolve("LIGHT_BLUE_STAINED_GLASS_PANE", "GLASS_PANE");
        roof = resolve("DARK_OAK_PLANKS", "OAK_PLANKS");
        light = resolve("GLOWSTONE", "TORCH");
        door = resolve("DARK_OAK_DOOR", "OAK_DOOR");
        water = resolve("WATER", "WATER");
        getCommand("diddymansion").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Only players can build a mansion.");
            return true;
        }

        Player player = (Player) sender;
        if (!player.hasPermission("diddymansion.build")) {
            player.sendMessage(ChatColor.RED + "You do not have permission to build a mansion.");
            return true;
        }

        int scale = 1;
        if (args.length > 0) {
            try {
                scale = Integer.parseInt(args[0]);
            } catch (NumberFormatException exception) {
                player.sendMessage(ChatColor.RED + "Size must be a number from 1 to 2.");
                return true;
            }
        }
        if (scale < 1 || scale > 2) {
            player.sendMessage(ChatColor.RED + "Size must be a number from 1 to 2.");
            return true;
        }

        Location origin = player.getLocation().getBlock().getLocation().add(-12 * scale, 0, 3 * scale);
        if (origin.getBlockY() + (16 * scale) >= origin.getWorld().getMaxHeight()) {
            player.sendMessage(ChatColor.RED + "There is not enough room above you for the mansion.");
            return true;
        }

        buildMansion(origin, scale);
        player.sendMessage(ChatColor.AQUA + "Your Diddy mansion has been built.");
        return true;
    }

    private void buildMansion(Location origin, int scale) {
        World world = origin.getWorld();
        int baseX = origin.getBlockX();
        int baseY = origin.getBlockY();
        int baseZ = origin.getBlockZ();
        int width = 25 * scale;
        int depth = 17 * scale;
        int floorHeight = 5 * scale;
        int top = baseY + (16 * scale);

        fill(world, baseX, baseY, baseZ, baseX + width - 1, baseY, baseZ + depth - 1, foundation);
        for (int floorNumber = 0; floorNumber < 3; floorNumber++) {
            int floorY = baseY + 1 + (floorNumber * floorHeight);
            fill(world, baseX + 1, floorY, baseZ + 1, baseX + width - 2, floorY, baseZ + depth - 2, floor);
            buildWalls(world, baseX, baseY + 1, baseZ, width, depth, floorY + floorHeight - 1);
            addWindows(world, baseX, baseZ, width, depth, floorY + scale, scale);
        }

        fill(world, baseX - scale, top, baseZ - scale, baseX + width + scale - 1, top, baseZ + depth + scale - 1, roof);
        fill(world, baseX + (4 * scale), top + scale, baseZ + (3 * scale), baseX + width - (4 * scale) - 1, top + scale, baseZ + depth - (3 * scale) - 1, roof);
        addEntrance(world, baseX, baseY, baseZ, width, scale);
        addBalcony(world, baseX, baseY, baseZ, width, scale);
        addInterior(world, baseX, baseY, baseZ, width, depth, scale);
        addPool(world, baseX + (width / 2) - (5 * scale), baseY, baseZ + depth + (3 * scale), 10 * scale, 6 * scale, scale);
    }

    private void buildWalls(World world, int baseX, int baseY, int baseZ, int width, int depth, int topY) {
        for (int y = baseY; y <= topY; y++) {
            for (int x = baseX; x < baseX + width; x++) {
                set(world, x, y, baseZ, wall);
                set(world, x, y, baseZ + depth - 1, wall);
            }
            for (int z = baseZ + 1; z < baseZ + depth - 1; z++) {
                set(world, baseX, y, z, wall);
                set(world, baseX + width - 1, y, z, wall);
            }
        }
        for (int x = baseX; x < baseX + width; x++) {
            set(world, x, topY, baseZ, trim);
            set(world, x, topY, baseZ + depth - 1, trim);
        }
    }

    private void addWindows(World world, int baseX, int baseZ, int width, int depth, int y, int scale) {
        int windowHeight = 2 * scale;
        int[] frontWindows = {3 * scale, 8 * scale, 17 * scale, 22 * scale};
        for (int offset : frontWindows) {
            fill(world, baseX + offset, y, baseZ, baseX + offset + scale, y + windowHeight - 1, baseZ, glass);
            fill(world, baseX + offset, y, baseZ + depth - 1, baseX + offset + scale, y + windowHeight - 1, baseZ + depth - 1, glass);
        }
        for (int offset = 3 * scale; offset < depth - (3 * scale); offset += 6 * scale) {
            fill(world, baseX, y, baseZ + offset, baseX, y + windowHeight - 1, baseZ + offset + scale, glass);
            fill(world, baseX + width - 1, y, baseZ + offset, baseX + width - 1, y + windowHeight - 1, baseZ + offset + scale, glass);
        }
    }

    private void addEntrance(World world, int baseX, int baseY, int baseZ, int width, int scale) {
        int center = baseX + (width / 2);
        for (int y = baseY + 1; y <= baseY + (2 * scale); y++) {
            for (int x = center; x <= center + scale; x++) {
                set(world, x, y, baseZ, door);
            }
        }
        fill(world, center - (2 * scale), baseY + 1, baseZ - (2 * scale), center + (3 * scale), baseY + 1, baseZ - 1, trim);
        fill(world, center - (2 * scale), baseY + 2, baseZ - scale, center + (3 * scale), baseY + 2, baseZ - scale, trim);
    }

    private void addBalcony(World world, int baseX, int baseY, int baseZ, int width, int scale) {
        int balconyY = baseY + (11 * scale);
        int left = baseX + (5 * scale);
        int right = baseX + width - (5 * scale) - 1;
        fill(world, left, balconyY, baseZ - (2 * scale), right, balconyY, baseZ + (2 * scale), trim);
        for (int x = left; x <= right; x++) {
            set(world, x, balconyY + scale, baseZ - (2 * scale), trim);
        }
        for (int x = left; x <= right; x += 2 * scale) {
            set(world, x, balconyY + scale, baseZ + (2 * scale), trim);
        }
    }

    private void addInterior(World world, int baseX, int baseY, int baseZ, int width, int depth, int scale) {
        int center = baseX + (width / 2);
        int firstFloor = baseY + 2;
        int secondFloor = baseY + (7 * scale);
        int thirdFloor = baseY + (12 * scale);
        set(world, center - (4 * scale), firstFloor, baseZ + (4 * scale), light);
        set(world, center + (4 * scale), firstFloor, baseZ + (4 * scale), light);
        set(world, center, secondFloor, baseZ + (depth / 2), light);
        set(world, center, thirdFloor, baseZ + (depth / 2), light);
        fill(world, baseX + (3 * scale), firstFloor, baseZ + (depth / 2), baseX + (7 * scale), firstFloor, baseZ + (depth / 2) + scale, trim);
        fill(world, baseX + width - (8 * scale), firstFloor, baseZ + (depth / 2), baseX + width - (4 * scale), firstFloor, baseZ + (depth / 2) + scale, trim);
    }

    private void addPool(World world, int x, int y, int z, int width, int depth, int scale) {
        fill(world, x, y, z, x + width, y, z + depth, trim);
        fill(world, x + scale, y + 1, z + scale, x + width - scale, y + 1, z + depth - scale, water);
        for (int i = 0; i < width; i += 2 * scale) {
            set(world, x + i, y + 1, z, light);
            set(world, x + i, y + 1, z + depth, light);
        }
    }

    private void fill(World world, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Material material) {
        for (int x = minX; x <= maxX; x++) {
            for (int y = minY; y <= maxY; y++) {
                for (int z = minZ; z <= maxZ; z++) {
                    set(world, x, y, z, material);
                }
            }
        }
    }

    private void set(World world, int x, int y, int z, Material material) {
        world.getBlockAt(x, y, z).setType(material, false);
    }

    private Material resolve(String preferred, String fallback) {
        Material material = Material.matchMaterial(preferred);
        if (material != null) {
            return material;
        }
        return Material.matchMaterial(fallback);
    }
}