leyofg

Tameable rabbits mod

Kodari AI
KodariMay 22 at 9:57 pm 9,218 (v2)

I’ll create a plugin that allows players to tame and manage rabbits as pets.

TameableRabbits
A plugin that enables players to tame wild rabbits and keep them as loyal companions. Players can tame rabbits by feeding them carrots, and tamed rabbits will follow their owners, teleport when too far away, and can be named. Features include configurable taming chances, health regeneration for tamed rabbits, persistent data storage across server restarts, and customizable items for taming. Includes admin commands to manage tamed rabbits and view ownership information.

Now I’ll create the complete plugin structure:

Now I need to add the missing method to the main class for creating NamespacedKeys:


TameableRabbits plugin created!

The plugin allows players to tame rabbits by feeding them carrots. Features include:

  • Configurable taming chance and max rabbits per player

  • Tamed rabbits follow and teleport to their owner

  • Health regeneration for tamed rabbits

  • Persistent data storage across restarts

  • Commands to view, list, and release tamed rabbits

  • Protection against damaging your own rabbits

Players use carrots to tame wild rabbits, which will then follow them and teleport when too far away. Use /tamedrabbits (or /tr) to manage your tamed rabbits.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
11 687
src/main/java/com/example/tameablerabbits/TameableRabbits.java
package com.example.tameablerabbits;

import com.example.tameablerabbits.commands.RabbitCommand;
import com.example.tameablerabbits.listeners.RabbitListener;
import com.example.tameablerabbits.managers.ConfigManager;
import com.example.tameablerabbits.managers.RabbitManager;
import lombok.Getter;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class TameableRabbits extends JavaPlugin {
    
    private ConfigManager configManager;
    private RabbitManager rabbitManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.rabbitManager = new RabbitManager(this);
        
        getServer().getPluginManager().registerEvents(new RabbitListener(this), this);
        getCommand("tamedrabbits").setExecutor(new RabbitCommand(this));
        
        rabbitManager.startTeleportTask();
        rabbitManager.startHealthRegenTask();
        
        getLogger().info("TameableRabbits has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (rabbitManager != null) {
            rabbitManager.saveAllData();
        }
        getLogger().info("TameableRabbits has been disabled!");
    }
    
    public NamespacedKey getKey(String key) {
        return new NamespacedKey(this, key);
    }
}