Thabiso Masilo

CAMP FIRE

Kodari AI
KodariOct 28 at 7:22 am 1
CampFirePlus
CampFirePlus enhances Minecraft campfires with configurable effects, cooking bonuses, and social features. Players can place campfires to gain temporary buffs like health regeneration, increased damage, or speed when nearby. The plugin adds a cooking system that speeds up food preparation and allows custom recipes. Campfires generate warmth that protects players from cold environments and provides night vision in dark areas. Admins can configure effect durations, radius, and particle effects per campfire type. The plugin includes a command system for managing campfire zones, setting up community gathering spots, and creating permanent campfire locations with persistent effects. It supports multiple campfire tiers with escalating benefits and integrates with existing Minecraft mechanics for seamless gameplay enhancement.

I’ll create a CampFire plugin that heals players when they right-click a lit campfire, with configurable healing, cooldown, and messages. I’ll include the Gradle setup, plugin metadata, config, and listener.

Created CampFire: right-clicking a lit campfire restores configurable health, with a per-player cooldown and customizable messages. Added the plugin metadata, default config, and Gradle setup.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 117
src/main/java/com/kodari/campfire/CampFirePlugin.java
package com.kodari.campfire;

import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Campfire;
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.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class CampFirePlugin extends JavaPlugin implements Listener {
    private final Map<UUID, Long> lastUse = new HashMap<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler(ignoreCancelled = true)
    public void onPlayerInteract(PlayerInteractEvent event) {
        if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
            return;
        }

        Block block = event.getClickedBlock();
        if (block == null || !(block.getBlockData() instanceof Campfire campfire) || !campfire.isLit()) {
            return;
        }

        Player player = event.getPlayer();
        long now = System.currentTimeMillis();
        long cooldownMillis = Math.max(0L, getConfig().getLong("cooldown-seconds", 30L)) * 1000L;
        Long previousUse = lastUse.get(player.getUniqueId());
        if (previousUse != null) {
            long remainingMillis = previousUse + cooldownMillis - now;
            if (remainingMillis > 0) {
                long remainingSeconds = (remainingMillis + 999L) / 1000L;
                sendMessage(player, "messages.cooldown", "&eThe fire needs {seconds}s before it can warm you again.",
                        "{seconds}", String.valueOf(remainingSeconds));
                return;
            }
        }

        double currentHealth = player.getHealth();
        double maximumHealth = player.getMaxHealth();
        if (currentHealth >= maximumHealth) {
            sendMessage(player, "messages.full-health", "&eYou are already at full health.");
            return;
        }

        double healingAmount = Math.max(0.0, getConfig().getDouble("healing-amount", 4.0));
        double restored = Math.min(healingAmount, maximumHealth - currentHealth);
        if (restored <= 0.0) {
            return;
        }

        player.setHealth(currentHealth + restored);
        lastUse.put(player.getUniqueId(), now);
        sendMessage(player, "messages.healed", "&aYou warmed yourself by the fire and restored {amount} health.",
                "{amount}", formatAmount(restored));
    }

    private void sendMessage(Player player, String path, String fallback, String... replacements) {
        String message = getConfig().getString(path, fallback);
        for (int i = 0; i + 1 < replacements.length; i += 2) {
            message = message.replace(replacements[i], replacements[i + 1]);
        }
        player.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
    }

    private String formatAmount(double amount) {
        return amount == Math.floor(amount) ? String.valueOf((int) amount) : String.valueOf(amount);
    }
}