Majed

make a plugin so like i can create a area, when i fish there it has a 1% chance of giving 1 fish crate, command key give %player% fish 1, add a config.yml where i can change all the messages, add support for custom #FFC24A color code such as that. and make everything including fish chance, the command everything to be confirgurable in config file

Kodari AI
KodariMon at 9:16 pm 3
FishCrateSystem
Creates a configurable fishing crate plugin for Minecraft. Players can define a fishing area via command, and fishing within that area grants a 1% chance (configurable) to receive a fish crate item. Includes a /fishcrate give command to award crates to players, a fully customizable config.yml for all messages, chances, crate item details, and area settings. Supports hex color codes like #FFC24A for message formatting, allowing server admins to style all plugin messages with custom colors. All values including drop chance, crate material, command permissions, and area dimensions are configurable.
  • Add commands to select and manage fishing areas.

  • Make the reward chance, console command, and all plugin messages configurable, with hex-color support.

Created the fishing-area plugin.

  • Stand at opposite corners and use /fisharea pos1 and /fisharea pos2, then /fisharea create <name>. The fishing hook must be inside the selected area.

  • Configure the chance, console reward command, and messages in config.yml. Messages support & codes and hex colors like #FFC24A.

  • Use /fisharea reload after changing the config. The default reward requires a plugin that provides /key give.

Majed

attribute Luck also amplifies this chance btw alr? also add a small celebration not in chat, only to the player like lauch a firework or some small paricles

Kodari AI
KodariMon at 9:26 pm 1
  • Apply the player’s Luck attribute to the reward chance, with the bonus configurable.

  • Show a private particle celebration instead of a chat message.

Luck now increases the reward chance by 1 percentage point per Luck point by default. You can change that in config.yml.

Winners see private particles instead of a chat message. The particles can also be configured or disabled.

Majed

only in the fishing zone theres a custyom loot pool, i can edit it with /fishpool and it opens a menu where i can add any item i want with rarity 0.04% - Mythic 0.12% - Legendary 0.5% - Epic 1.5% - Rare 17% - Uncommon 80.84% - Common

additionaly i want the item i put in the /fishpool to copy all of the items attreibutes, data, lore ect..

Kodari AI
KodariWed at 1:15 pm 4
  • Add a /fishpool editor with a separate item list for each rarity.

  • Replace catches inside fishing zones with configured pool items, while keeping the existing crate roll.

  • Preserve complete item data and make rarity chances configurable.

Added /fishpool for editing fishing-zone loot. Choose a rarity, pick up an item from your inventory, and left-click a slot to copy it; right-click an entry to remove it. Copies retain the item’s data, attributes, and lore.

Rarity chances are configurable in config.yml. If the selected rarity has no items, the catch remains vanilla. The existing crate roll remains separate.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 523
src/main/java/com/kodari/fishareas/FishAreasPlugin.java
package com.kodari.fishareas;

import com.cryptomorin.xseries.XAttribute;
import com.cryptomorin.xseries.particles.XParticle;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class FishAreasPlugin extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private static final Pattern HEX = Pattern.compile("#[a-fA-F0-9]{6}");
    private final Map<String, Area> areas = new LinkedHashMap<>();
    private final Map<UUID, Location[]> selections = new java.util.HashMap<>();
    private File areasFile;
    private YamlConfiguration areasConfig;
    private FishPool fishPool;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        areasFile = new File(getDataFolder(), "areas.yml");
        loadAreas();
        fishPool = new FishPool(this);
        getServer().getPluginManager().registerEvents(this, this);
        getServer().getPluginManager().registerEvents(fishPool, this);
        getCommand("fisharea").setExecutor(this);
        getCommand("fisharea").setTabCompleter(this);
        getCommand("fishpool").setExecutor(fishPool);
    }

    private void loadAreas() {
        areas.clear();
        areasConfig = YamlConfiguration.loadConfiguration(areasFile);
        ConfigurationSection section = areasConfig.getConfigurationSection("areas");
        if (section == null) return;
        for (String name : section.getKeys(false)) {
            ConfigurationSection entry = section.getConfigurationSection(name);
            if (entry == null || entry.getString("world") == null) continue;
            areas.put(name.toLowerCase(Locale.ROOT), new Area(entry.getString("world"),
                    entry.getInt("min-x"), entry.getInt("min-y"), entry.getInt("min-z"),
                    entry.getInt("max-x"), entry.getInt("max-y"), entry.getInt("max-z")));
        }
    }

    private boolean saveAreas() {
        try {
            areasConfig.save(areasFile);
            return true;
        } catch (IOException e) {
            getLogger().severe("Could not save areas.yml: " + e.getMessage());
            return false;
        }
    }

    private String color(String text) {
        Matcher matcher = HEX.matcher(text);
        StringBuffer result = new StringBuffer();
        while (matcher.find()) matcher.appendReplacement(result, Matcher.quoteReplacement(ChatColor.of(matcher.group()).toString()));
        matcher.appendTail(result);
        return org.bukkit.ChatColor.translateAlternateColorCodes('&', result.toString());
    }

    private void message(CommandSender sender, String key, String... replacements) {
        String text = getConfig().getString("messages." + key, "");
        if (text == null || text.isEmpty()) return;
        for (int i = 0; i + 1 < replacements.length; i += 2) text = text.replace(replacements[i], replacements[i + 1]);
        sender.sendMessage(color(getConfig().getString("messages.prefix", "") + text));
    }

    @EventHandler(ignoreCancelled = true)
    public void onFish(PlayerFishEvent event) {
        if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return;
        Player player = event.getPlayer();
        Location location = event.getHook().getLocation();
        if (areas.values().stream().noneMatch(area -> area.contains(location))) return;
        if (event.getCaught() instanceof Item) fishPool.replaceCatch((Item) event.getCaught());
        double luck = XAttribute.of("luck")
                .map(attribute -> player.getAttribute(attribute.get()))
                .map(AttributeInstance::getValue).orElse(0.0);
        double chance = Math.max(0.0, Math.min(100.0, getConfig().getDouble("fish-chance", 1.0)
                + luck * getConfig().getDouble("luck-chance-per-point", 1.0)));
        if (ThreadLocalRandom.current().nextDouble(100.0) >= chance) return;
        String command = getConfig().getString("reward-command", "key give %player% fish 1").replace("%player%", player.getName());
        if (command.startsWith("/")) command = command.substring(1);
        if (!command.isBlank()) Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
        if (getConfig().getBoolean("celebration.enabled", true)) {
            XParticle.of(getConfig().getString("celebration.particle", "HAPPY_VILLAGER"))
                    .ifPresent(particle -> player.spawnParticle(particle.get(), player.getLocation().add(0, 1, 0),
                            Math.max(0, getConfig().getInt("celebration.count", 20)), 0.5, 0.5, 0.5, 0.0));
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!sender.hasPermission("fishareas.admin")) {
            message(sender, "no-permission");
            return true;
        }
        if (args.length == 0) {
            message(sender, "usage");
            return true;
        }
        String action = args[0].toLowerCase(Locale.ROOT);
        if ((action.equals("pos1") || action.equals("pos2")) && args.length == 1) {
            if (!(sender instanceof Player)) {
                message(sender, "players-only");
                return true;
            }
            Player player = (Player) sender;
            Location pos = player.getLocation().getBlock().getLocation();
            selections.computeIfAbsent(player.getUniqueId(), id -> new Location[2])[action.equals("pos1") ? 0 : 1] = pos;
            message(sender, action, "%x%", String.valueOf(pos.getBlockX()), "%y%", String.valueOf(pos.getBlockY()),
                    "%z%", String.valueOf(pos.getBlockZ()), "%world%", pos.getWorld().getName());
        } else if (action.equals("create") && args.length == 2) {
            if (!(sender instanceof Player)) {
                message(sender, "players-only");
                return true;
            }
            String name = args[1].toLowerCase(Locale.ROOT);
            if (!name.matches("[a-z0-9_-]+")) {
                message(sender, "invalid-name");
                return true;
            }
            if (areas.containsKey(name)) {
                message(sender, "already-exists", "%area%", name);
                return true;
            }
            Location[] selected = selections.get(((Player) sender).getUniqueId());
            if (selected == null || selected[0] == null || selected[1] == null) {
                message(sender, "selection-required");
                return true;
            }
            Location a = selected[0], b = selected[1];
            if (!a.getWorld().getUID().equals(b.getWorld().getUID())) {
                message(sender, "different-worlds");
                return true;
            }
            Area area = new Area(a.getWorld().getName(), Math.min(a.getBlockX(), b.getBlockX()),
                    Math.min(a.getBlockY(), b.getBlockY()), Math.min(a.getBlockZ(), b.getBlockZ()),
                    Math.max(a.getBlockX(), b.getBlockX()), Math.max(a.getBlockY(), b.getBlockY()),
                    Math.max(a.getBlockZ(), b.getBlockZ()));
            String path = "areas." + name + ".";
            areasConfig.set(path + "world", area.world);
            areasConfig.set(path + "min-x", area.minX);
            areasConfig.set(path + "min-y", area.minY);
            areasConfig.set(path + "min-z", area.minZ);
            areasConfig.set(path + "max-x", area.maxX);
            areasConfig.set(path + "max-y", area.maxY);
            areasConfig.set(path + "max-z", area.maxZ);
            if (!saveAreas()) {
                areasConfig.set("areas." + name, null);
                message(sender, "save-failed");
                return true;
            }
            areas.put(name, area);
            message(sender, "created", "%area%", name);
        } else if (action.equals("delete") && args.length == 2) {
            String name = args[1].toLowerCase(Locale.ROOT);
            if (!areas.containsKey(name)) {
                message(sender, "not-found", "%area%", name);
                return true;
            }
            Object old = areasConfig.get("areas." + name);
            areasConfig.set("areas." + name, null);
            if (!saveAreas()) {
                areasConfig.set("areas." + name, old);
                message(sender, "save-failed");
                return true;
            }
            areas.remove(name);
            message(sender, "deleted", "%area%", name);
        } else if (action.equals("list") && args.length == 1) {
            if (areas.isEmpty()) message(sender, "list-empty");
            else message(sender, "list", "%areas%", String.join(", ", areas.keySet()));