Yeferson Andres Granda

sex mod entre entidad y jugador con mecanicas de relaciones

Kodari AI
KodariNov 6 at 6:30 am 1
EntityRomance
EntityRomance is a Minecraft plugin that introduces intimate relationship mechanics between players and entities. Players can initiate romantic interactions with compatible mobs, building affection levels through gifts, care, and proximity. The plugin tracks relationship status, affection meters, and emotional states for each entity-player pairing. Special interactions unlock as affection grows, including unique dialogue, buffs, and exclusive entity behaviors. Compatible entities are configurable, with custom relationship tiers ranging from acquaintance to soulmate. The plugin features a comprehensive GUI for managing relationships, viewing affection progress, and accessing relationship-specific perks. Persistent data storage ensures relationships survive server restarts, while configurable settings allow server owners to customize interaction rates, affection decay, and available romantic actions.

Voy a crear un plugin de relaciones no sexuales con aldeanos:

  • Progresión de afinidad persistente mediante conversaciones y citas.

  • Comando /relacion para consultar el vínculo actual.

  • Solo interactúa con aldeanos; no añade mecánicas sexuales.

Creé RelacionNPC, un plugin con afinidad persistente con aldeanos: conversar aumenta el vínculo, /relacion muestra el estado y /relacion cita permite proponer una cita al alcanzar Amistad. Incluye niveles hasta «Vínculo romántico»; no añade interacciones sexuales.

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class RelacionNPCPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final long CONVERSATION_COOLDOWN_MS = 10 * 60 * 1000L;
    private static final long DATE_COOLDOWN_MS = 24 * 60 * 60 * 1000L;

    private final Map<String, Long> conversationCooldowns = new HashMap<>();
    private final Map<UUID, Villager> activeVillagers = new HashMap<>();
    private File dataFile;
    private org.bukkit.configuration.file.YamlConfiguration relationships;

    @Override
    public void onEnable() {
        dataFile = new File(getDataFolder(), "relationships.yml");
        relationships = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(dataFile);
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("relacion").setExecutor(this);
    }

    @Override
    public void onDisable() {
        saveRelationships();
    }

    @EventHandler
    public void onVillagerInteract(PlayerInteractEntityEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || !(event.getRightClicked() instanceof Villager villager)) {
            return;
        }

        Player player = event.getPlayer();
        activeVillagers.put(player.getUniqueId(), villager);

        String path = pairPath(player.getUniqueId(), villager.getUniqueId());
        long now = System.currentTimeMillis();
        long nextConversation = conversationCooldowns.getOrDefault(path, 0L);
        if (now < nextConversation) {
            return;
        }

        conversationCooldowns.put(path, now + CONVERSATION_COOLDOWN_MS);
        int oldPoints = getPoints(path);
        int newPoints = addPoints(path, 5);
        player.sendMessage("Has conversado con " + villagerName(villager) + ". Afinidad: " + newPoints + "/100 (" + tier(newPoints) + ").");
        if (!tier(oldPoints).equals(tier(newPoints))) {
            player.sendMessage("Tu relación con " + villagerName(villager) + " ahora es: " + tier(newPoints) + ".");
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Este comando solo está disponible para jugadores.");
            return true;
        }

        if (args.length > 0 && args[0].equalsIgnoreCase("ayuda")) {
            player.sendMessage("Usa /relacion para ver tu vínculo o /relacion cita para invitar al aldeano a una cita.");
            return true;
        }

        Villager villager = activeVillagers.get(player.getUniqueId());
        if (villager == null || !villager.isValid()) {
            player.sendMessage("Interactúa primero con un aldeano.");
            return true;
        }

        if (args.length > 0 && args[0].equalsIgnoreCase("cita")) {
            goOnDate(player, villager);
            return true;
        }

        int points = getPoints(pairPath(player.getUniqueId(), villager.getUniqueId()));
        player.sendMessage("Relación con " + villagerName(villager) + ": " + tier(points) + " (" + points + "/100 de afinidad).");
        return true;
    }

    private void goOnDate(Player player, Villager villager) {
        if (player.getWorld() != villager.getWorld() || player.getLocation().distanceSquared(villager.getLocation()) > 64) {
            player.sendMessage("Acércate al aldeano para proponerle una cita.");
            return;
        }

        String path = pairPath(player.getUniqueId(), villager.getUniqueId());
        int points = getPoints(path);
        if (points < 25) {
            player.sendMessage("Necesitas alcanzar el nivel Amistad para proponer una cita.");
            return;
        }

        long now = System.currentTimeMillis();
        long lastDate = relationships.getLong(path + ".last-date", 0L);
        if (now - lastDate < DATE_COOLDOWN_MS) {
            long hours = Math.max(1, (DATE_COOLDOWN_MS - (now - lastDate)) / (60 * 60 * 1000L));
            player.sendMessage("Ya tuviste una cita con este aldeano recientemente. Inténtalo de nuevo en " + hours + " h.");
            return;
        }

        relationships.set(path + ".last-date", now);
        int newPoints = addPoints(path, 10);
        player.sendMessage("Tu cita con " + villagerName(villager) + " fue bien. Afinidad: " + newPoints + "/100 (" + tier(newPoints) + ").");
        if (!tier(points).equals(tier(newPoints))) {
            player.sendMessage("Tu relación ahora es: " + tier(newPoints) + ".");
        }
    }

    private int getPoints(String path) {
        return relationships.getInt(path + ".points", 0);
    }

    private int addPoints(String path, int amount) {
        int updated = Math.min(100, getPoints(path) + amount);
        relationships.set(path + ".points", updated);
        saveRelationships();
        return updated;
    }

    private String pairPath(UUID playerId, UUID villagerId) {
        return "pairs." + playerId + "." + villagerId;
    }

    private String tier(int points) {
        if (points >= 75) return "Vínculo romántico";
        if (points >= 50) return "Gran amistad";
        if (points >= 25) return "Amistad";
        if (points >= 10) return "Conocidos";
        return "Desconocidos";
    }

    private String villagerName(Villager villager) {
        String customName = villager.getCustomName();
        return customName == null || customName.isBlank() ? "el aldeano" : customName;
    }

    private void saveRelationships() {
        if (relationships == null || dataFile == null) {
            return;
        }
        try {
            if (!getDataFolder().exists() && !getDataFolder().mkdirs()) {
                getLogger().warning("No se pudo crear la carpeta de datos del plugin.");
                return;
            }
            relationships.save(dataFile);
        } catch (IOException exception) {
            getLogger().severe("No se pudieron guardar las relaciones: " + exception.getMessage());
        }
    }
}