Saroj Goyal
📎 1 file 3,533 chars
📄
pasted-code-1794766578286.txt
txt 73 lines
▶
Recreate the actual Roblox game Steal An Egg as a fully functional Minecraft Paper plugin. Do not turn it into a generic tycoon or egg simulator.

MAP
Recreate the original T-shaped map:

Horizontal top section containing player bases in organized rows.
Long central pathway extending outward from the middle.
Multiple connected biomes along the pathway.
Each biome has unique terrain, decorations, guardian mobs, and egg locations.
Make the map resemble the Roblox original, not a square arena.
PLAYER BASES
Each player gets an individual base containing:

Pet display pens.
Egg hatching area.
Treadmill.
Trail management.
Money collection.
Base upgrades.
Expandable pet capacity.
Pets generate passive income, including offline earnings.

BIOMES
Include Forest, Lake, Desert, Jungle, Snow, Volcano, Abyss Ocean, Prehistoric, Cosmic, Cherry Blossom, and Titan Temple.

Each biome must have different eggs, guardian mobs, Speed requirements, rewards, and difficulty.

MINECRAFT MOBS
Use EXISTING VANILLA MINECRAFT MOBS for ALL pets and guardians. No custom 3D creature models.

Possible pets: Chicken, Rabbit, Wolf, Cat, Fox, Panda, Bee, Turtle, Axolotl, Frog, Parrot, Goat, Horse, Blaze, Slime, Enderman, Creeper, Warden, Sniffer, and Allay.

Possible guardians: Wolves, Ravagers, Drowned, Guardians, Husks, Spiders, Strays, Polar Bears, Blazes, Magma Cubes, Endermen, Shulkers, and Wardens.

Pets must stay inside their owner's base, have unique rarities and income values, and never despawn unexpectedly.

EGG STEALING
Eggs are guarded in biome locations. Players must:

Travel to a biome.
Find a guarded egg.
Steal it.
Escape pursuing guardians.
Carry it back to their base.
Hatch it into a pet.
Also implement stealing eligible eggs from other players.

HATCHING AND PETS
Eggs have different rarities, hatch times, possible mobs, and income values. Add hatching animations, sounds, and effects. Hatched pets generate money over time.

TREADMILLS
Recreate actual gym-style treadmills inside bases. Players train on them to generate Speed. Include animations, upgrades, costs, and visible progression.

TRAILS
Implement unlockable trails with different rarities, appearances, and Speed multipliers. Trails appear behind moving players and increase treadmill Speed gains.

TECHNICAL REQUIREMENTS
Java and Paper API.
SQLite persistent player data.
Offline income.
Multiplayer-safe mechanics.
Anti-duplication and ownership validation.
Configurable progression.
Optimized entities and particles.
PersistentDataContainer for identifying plugin entities.
Use Display Entities or ArmorStands for eggs and actual Minecraft mobs for pets and guardians.

DEVELOPMENT RULES
Inspect the existing repository before coding. Preserve working systems. Research the actual Roblox game and its map. Do not invent unrelated mechanics or create fake placeholders. Build modular systems, compile frequently, and fix errors.

FINAL GOAL

Deliver a playable Minecraft recreation of Steal An Egg, preserving its T-shaped map, bases, biome exploration, guarded egg stealing, hatching, Minecraft mob pets, passive income, treadmills, trails, upgrades, and multiplayer stealing.make this alot easier make the mobs be mc mobs the ones that get hatched from the eggs and make some admin commands for operators whoevers operator and make the guards mc mobs aswelli also want u to look at some roblox guid because the plugin is based of steal an egg from roblox to figure out how it works
Kodari AI
KodariNov 15 at 6:17 pm 4
StealAnEgg
A Minecraft Paper plugin recreating the Roblox game Steal An Egg. Features a T-shaped map with player bases, biome exploration, guarded egg stealing, hatching, and pet collection. Players travel through distinct biomes (Forest, Desert, Snow, Volcano, etc.) to steal guarded eggs and return them to their base for hatching. Hatched pets generate passive income, including offline earnings. Bases include treadmills for Speed training, trail customization, and upgrade systems. Uses vanilla Minecraft mobs for pets and guardians, SQLite for persistent data, and includes admin commands for operators to manage gameplay.

I’ll build a simplified, easier-to-play version with vanilla Minecraft pets and guardians, persistent progress, and operator commands. I can’t look up a Roblox guide without a guide URL or search access, so the map and mechanics will be an approximation rather than a verified recreation.

Created an initial playable prototype with vanilla mob pets and guardians, egg stealing and hatching, training, trails, upgrades, SQLite saves, and operator commands.

It is not yet a faithful recreation: the generated T-shaped map and biome decoration are simplified, and I couldn’t verify the Roblox mechanics against a guide. Send me a guide URL and I can use it to refine the game. The build has not been verified.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
settings.gradle
Code
6 503
src/main/java/com/kodari/stalanegg/StealAnEgg.java
package com.kodari.stalanegg;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public final class StealAnEgg extends JavaPlugin implements Listener {
    private Connection db;
    private World world;
    private NamespacedKey kindKey, ownerKey, biomeKey;
    private final Map<UUID, Profile> profiles = new HashMap<>();
    private final Map<String, Long> eggCooldowns = new HashMap<>();
    private final Map<UUID, Long> training = new HashMap<>();
    private final List<String> biomes = new ArrayList<>();

    private static final class Profile {
        UUID id;
        int base, speed, capacity = 3, treadmill = 1;
        long money, lastSeen, hatchAt;
        String trail = "leaf", unlocked = ",leaf,", carried = "", incubating = "";
    }

    @Override
    public void onEnable() {
        saveDefaultConfig();
        kindKey = new NamespacedKey(this, "kind");
        ownerKey = new NamespacedKey(this, "owner");
        biomeKey = new NamespacedKey(this, "biome");
        ConfigurationSection section = getConfig().getConfigurationSection("biomes");
        if (section == null || section.getKeys(false).isEmpty()) {
            getLogger().severe("No biomes configured.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        biomes.addAll(section.getKeys(false));
        try {
            getDataFolder().mkdirs();
            Class.forName("org.sqlite.JDBC");
            db = DriverManager.getConnection("jdbc:sqlite:" + new File(getDataFolder(), "players.db").getAbsolutePath());
            try (Statement s = db.createStatement()) {
                s.executeUpdate("CREATE TABLE IF NOT EXISTS players (id TEXT PRIMARY KEY, base INTEGER UNIQUE, speed INTEGER, money INTEGER, capacity INTEGER, treadmill INTEGER, trail TEXT, unlocked TEXT, carried TEXT, incubating TEXT, hatch_at INTEGER, last_seen INTEGER)");
                s.executeUpdate("CREATE TABLE IF NOT EXISTS pets (id INTEGER PRIMARY KEY AUTOINCREMENT, owner TEXT NOT NULL, type TEXT NOT NULL, income INTEGER NOT NULL, rarity TEXT NOT NULL)");
            }
        } catch (Exception e) {
            getLogger().severe("Unable to open SQLite database: " + e.getMessage());
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        world = Bukkit.createWorld(new WorldCreator(getConfig().getString("world", "steal_an_egg")));
        if (world == null) {
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        buildMap();
        Bukkit.getPluginManager().registerEvents(this, this);
        for (Player p : Bukkit.getOnlinePlayers()) load(p);
        Bukkit.getScheduler().runTaskTimer(this, this::tick, 20L, 20L);
    }

    @Override
    public void onDisable() {
        if (db == null) return;
        for (Profile p : profiles.values()) { p.lastSeen = System.currentTimeMillis(); save(p); }
        try { db.close(); } catch (SQLException e) { getLogger().warning(e.getMessage()); }
    }

    private org.bukkit.Material material(String name) {
        return XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial).orElseThrow(() -> new IllegalArgumentException("Unknown material " + name));
    }

    private void rectangle(int minX, int maxX, int minZ, int maxZ, int y, String type) {
        org.bukkit.Material mat = material(type);
        for (int x = minX; x <= maxX; x++) for (int z = minZ; z <= maxZ; z++) world.getBlockAt(x, y, z).setType(mat, false);
    }

    private void buildMap() {
        int spacing = Math.max(40, getConfig().getInt("biome-spacing", 70));
        rectangle(-160, 160, -12, 12, 80, "STONE_BRICKS");
        rectangle(-5, 5, 0, spacing * biomes.size() + 20, 80, "STONE_BRICKS");
        for (int i = 0; i < biomes.size(); i++) {
            String name = biomes.get(i); int z = (i + 1) * spacing;
            rectangle(-14, 14, z - 14, z + 14, 80, getConfig().getString("biomes." + name + ".ground", "GRASS_BLOCK"));
            rectangle(-2, 2, z - 2, z + 2, 81, "POLISHED_ANDESITE");
            spawnEgg(name, z);
        }
    }

    private void spawnEgg(String biome, int z) {
        Location loc = new Location(world, 0.5, 82, z + 0.5);
        for (Entity e : world.getNearbyEntities(loc, 1, 2, 1)) if ("wild_egg".equals(tag(e, kindKey))) e.remove();
        ArmorStand stand = world.spawn(loc, ArmorStand.class, a -> {
            a.setInvisible(true); a.setGravity(false); a.setInvulnerable(true); a.setMarker(false); a.setSmall(true);
            a.setCustomName(ChatColor.GOLD + pretty(biome) + " Egg"); a.setCustomNameVisible(true);
            a.getPersistentDataContainer().set(kindKey, PersistentDataType.STRING, "wild_egg");
            a.getPersistentDataContainer().set(biomeKey, PersistentDataType.STRING, biome);
            a.getEquipment().setHelmet(XMaterial.matchXMaterial("DRAGON_EGG").map(XMaterial::parseItem).orElse(null));
        });
        stand.setPersistent(true);
    }

    private Location baseLocation(int index) {
        int spacing = Math.max(26, getConfig().getInt("base-spacing", 32));
        int x = (index / 2 + 1) * spacing * (index % 2 == 0 ? 1 : -1);
        return new Location(world, x + 0.5, 81, 0.5);
    }

    private void buildBase(Profile p) {
        Location l = baseLocation(p.base); int x = l.getBlockX();
        rectangle(x - 10, x + 10, -10, 10, 80, "OAK_PLANKS");
        rectangle(x - 9, x - 5, -8, -4, 81, "BLACK_CONCRETE");
        rectangle(x + 4, x + 8, -8, -4, 81, "GOLD_BLOCK");
        for (int dx = -3; dx <= 3; dx++) { world.getBlockAt(x + dx, 81, 4).setType(material("OAK_FENCE"), false); world.getBlockAt(x + dx, 81, 9).setType(material("OAK_FENCE"), false); }
        for (int z = 4; z <= 9; z++) { world.getBlockAt(x - 3, 81, z).setType(material("OAK_FENCE"), false); world.getBlockAt(x + 3, 81, z).setType(material("OAK_FENCE"), false); }
    }

    private void load(Player player) {
        UUID id = player.getUniqueId();
        if (profiles.containsKey(id)) return;
        Profile p = new Profile(); p.id = id; p.speed = getConfig().getInt("starting-speed", 10); p.lastSeen = System.currentTimeMillis();
        try (PreparedStatement q = db.prepareStatement("SELECT * FROM players WHERE id=?")) {
            q.setString(1, id.toString());
            try (ResultSet r = q.executeQuery()) {
                if (r.next()) {
                    p.base = r.getInt("base"); p.speed = r.getInt("speed"); p.money = r.getLong("money"); p.capacity = r.getInt("capacity"); p.treadmill = r.getInt("treadmill");
                    p.trail = r.getString("trail"); p.unlocked = r.getString("unlocked"); p.carried = r.getString("carried"); p.incubating = r.getString("incubating"); p.hatchAt = r.getLong("hatch_at"); p.lastSeen = r.getLong("last_seen");
                    long seconds = Math.min(Math.max(0, (System.currentTimeMillis() - p.lastSeen) / 1000), Math.max(0, getConfig().getLong("offline-income-hours", 24)) * 3600);
                    long earnings = income(id) * seconds / 60; p.money += earnings;
                    if (earnings > 0) player.sendMessage(ChatColor.GREEN + "Offline earnings: $" + earnings);
                } else {
                    try (Statement s = db.createStatement(); ResultSet bases = s.executeQuery("SELECT COALESCE(MAX(base),-1)+1 FROM players")) { p.base = bases.next() ? bases.getInt(1) : 0; }
                }
            }
            profiles.put(id, p); p.lastSeen = System.currentTimeMillis(); save(p); buildBase(p); spawnPets(p);
        } catch (SQLException e) { getLogger().severe("Failed to load " + id + ": " + e.getMessage()); player.sendMessage(ChatColor.RED + "Could not load your data. Please contact an admin."); }
    }

    private void save(Profile p) {
        if (db == null) return;
        try (PreparedStatement s = db.prepareStatement("INSERT OR REPLACE INTO players (id,base,speed,money,capacity,treadmill,trail,unlocked,carried,incubating,hatch_at,last_seen) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")) {
            s.setString(1,p.id.toString()); s.setInt(2,p.base); s.setInt(3,p.speed); s.setLong(4,p.money); s.setInt(5,p.capacity); s.setInt(6,p.treadmill); s.setString(7,p.trail); s.setString(8,p.unlocked); s.setString(9,p.carried); s.setString(10,p.incubating); s.setLong(11,p.hatchAt); s.setLong(12,p.lastSeen); s.executeUpdate();
        } catch (SQLException e) { getLogger().severe("Failed to save " + p.id + ": " + e.getMessage()); }
    }

    private long income(UUID id) throws SQLException {
        try (PreparedStatement s = db.prepareStatement("SELECT COALESCE(SUM(income),0) FROM pets WHERE owner=?")) { s.setString(1,id.toString()); try (ResultSet r = s.executeQuery()) { return r.next() ? r.getLong(1) : 0; } }
    }

    private int petCount(UUID id) throws SQLException {
        try (PreparedStatement s = db.prepareStatement("SELECT COUNT(*) FROM pets WHERE owner=?")) { s.setString(1,id.toString()); try (ResultSet r = s.executeQuery()) { return r.next() ? r.getInt(1) : 0; } }
    }

    private void spawnPets(Profile p) {