Studioköleleri
📎 1 file 4,853 chars
📄
pasted-code-1794085079102.txt
txt 143 lines
▶
Create a complete Minecraft plugin named **HexAFK** for **Paper 26.3 Beta**, using **Java 25**.

The plugin must be fully functional, properly compiled, and ready to install as a `.jar` file. Also provide the complete source code and project files in a `.zip` archive.

**Plugin information**
- Plugin name: HexAFK
- Main class: `com.hexsmp.hexafk.HexAFK`
- Server: Paper 26.3 Beta
- Java: 25
- Minecraft server name: HEX SMP

### 1. Commands
Implement these commands:

- `/afk` — Opens the AFK GUI.
- `/afk create` — Creates/sets the AFK arena center at the player's current location.
- `/afk set` — Sets the AFK teleport location at the player's current location.
- `/setafk` — Alternative command for setting the AFK teleport location.
- `/afk enter` — Teleports the player to the AFK area.
- `/afk leave` — Takes the player out of the AFK area.
- `/afk remove` — Removes/disables the AFK arena.
- `/afk reload` — Reloads the configuration.

### 2. AFK Arena
- The AFK arena must have a configurable radius.
- Default radius: 18 blocks.
- Use a configurable Y-range to detect players inside the arena.
- Default Y-range: 12 blocks.
- Detect players entering and leaving the AFK arena automatically.
- When a player enters the arena, start the reward countdown.
- When a player leaves the arena, immediately stop their countdown.
- Do not reward players who are outside the AFK arena.

### 3. Reward System
- Default reward interval: 60 seconds.
- Default reward amount: 10 points.
- Integrate with **SKPoints** to give points.
- Use the correct SKPoints API or dependency. Do not use Vault or regular economy money for these rewards.
- Every 60 seconds, give the player 10 points.
- Make the reward interval and amount configurable in `config.yml`.
- Prevent players from receiving rewards more than once per interval.
- If SKPoints cannot be integrated without an API dependency, clearly report the missing dependency instead of creating a fake integration.

### 4. Titles and Countdown
When a player enters the AFK arena, display a centered title:

Main title:
`⚡ AFK ARENA ⚡`

Subtitle:
`⏳ 60s until next reward +10 POINTS`

The countdown must update every second:
- 60s
- 59s
- 58s
- Continue until 1s.

When the player receives the reward, show a reward title:

`+10 POINTS`

Then restart the countdown at 60 seconds.

All title texts and colors must be configurable in `config.yml`.

### 5. AFK GUI
When a player uses `/afk`, open a custom inventory GUI.

- GUI title: `⚡ HEX SMP | AFK`
- Add attractive Minecraft item icons.
- Include an item/button to enter the AFK arena.
- Include an item/button showing AFK rewards.
- Include an item/button showing the player's AFK status.
- Clicking the enter button must teleport the player to the configured AFK location.
- All GUI names, descriptions, materials and slots must be configurable.
- Prevent players from taking or moving GUI items.

### 6. Configuration
Create a complete `config.yml` with all settings editable.

Use these default values:

```yaml
arena:
  radius: 18.0
  y-range: 12.0
  world: afk
  x: 22.512764062218853
  y: -30.0
  z: 17.500330427895683

reward:
  interval-seconds: 60
  amount: 10

gui:
  title: 'eA2C⚡ HEX SMP | AFK'

title:
  main: '7FFFF⚡ AFK ARENA ⚡'
  subtitle: '&f⏳ &e%time%s &7until next reward &a+%amount% POINTS'

messages:
  reward-title: '7FF55+%amount% POINTS'

spawn:
  world: afk
  x: 22.25574637924643
  y: -30.0
  z: 17.463279595341202
  yaw: 89.9984
  pitch: -16.050005
```

Do not change the coordinates or default values.

### 7. Permissions
- `hexafk.admin` — Access to administrative commands.
- Default players can use `/afk`, enter the AFK area and receive rewards.
- Only administrators with `hexafk.admin` can use create, set, remove and reload commands.
- OP players should have admin permission by default.

### 8. Technical Requirements
- Use efficient task scheduling.
- Do not create a separate repeating task for every second if a more efficient shared scheduler can be used.
- Correctly handle player disconnects and server shutdowns.
- Prevent duplicate rewards and countdowns.
- Save arena and spawn settings to `config.yml`.
- Support HEX SMP's existing plugins without conflicts.
- Do not overwrite or delete other plugin files or data.
- No unnecessary dependencies.
- Make sure the plugin works on Java 25 and Paper 26.3 Beta.

### 9. Deliverables
Provide:
1. A fully compiled `HexAFK.jar`.
2. A ZIP containing the complete source code and project files.
3. A `config.yml`.
4. A `plugin.yml`.
5. Installation instructions.

Do not provide incomplete example code or a fake JAR. Compile the actual project and verify that the resulting JAR can load on Paper 26.3 with Java 25.
Kodari AI
KodariNov 7 at 9:03 pm 1
HexAFK
HexAFK is a Minecraft Paper plugin that creates a configurable AFK arena with automatic player detection, timed reward distribution via SKPoints integration, and an interactive GUI. Players enter the arena via commands or GUI buttons, triggering a real-time countdown title display that updates every second until rewards are granted. The plugin features configurable arena radius, Y-range detection, reward intervals and amounts, fully customizable GUI items with locked slots, admin commands for arena management, and efficient shared task scheduling to prevent duplicate countdowns. All settings including titles, messages, coordinates, and GUI layouts are stored in config.yml with reload support.
  1. Confirm whether SKPoints has a documented integration/API.

  2. Create HexAFK’s Paper plugin, configuration, commands, GUI, arena tracking, and reward/countdown handling.

  3. State the build and packaging limits honestly; no placeholder JAR or unverified ZIP.

Created the HexAFK project files with the arena commands, configurable locked GUI, arena tracking, and shared one-second countdown task.

SKPoints payouts are not implemented. The available documentation has no SKPoints API reference, so the plugin explicitly reports that payouts are unavailable instead of pretending to grant points. The project is not complete for live rewards until the correct SKPoints API dependency and its usage are available.

I haven’t produced a verified JAR or source ZIP. To try compiling in Kodari, click Compile in the top bar (on phone: ⋮ → Compile Project), then click Compile in the window. If successful, download the JAR there; install it by placing it in the server’s plugins folder and restarting.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 482
src/main/java/com/hexsmp/hexafk/HexAFK.java
package com.hexsmp.hexafk;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class HexAFK extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private static final Pattern HEX_COLOR = Pattern.compile("&#([A-Fa-f0-9]{6})");
    private final Map<UUID, Integer> countdowns = new HashMap<>();
    private final Map<UUID, Location> returnLocations = new HashMap<>();
    private BukkitTask arenaTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("afk").setExecutor(this);
        getCommand("afk").setTabCompleter(this);
        getCommand("setafk").setExecutor(this);
        getCommand("setafk").setTabCompleter(this);
        arenaTask = Bukkit.getScheduler().runTaskTimer(this, this::updatePlayers, 20L, 20L);
        getLogger().warning("SKPoints API integration is unavailable; AFK point payouts are disabled until its API dependency is provided.");
    }

    @Override
    public void onDisable() {
        if (arenaTask != null) {
            arenaTask.cancel();
        }
        countdowns.clear();
        returnLocations.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            send(sender, "messages.players-only");
            return true;
        }

        if (command.getName().equalsIgnoreCase("setafk")) {
            if (!isAdmin(player)) {
                send(player, "messages.no-permission");
                return true;
            }
            setSpawn(player.getLocation());
            send(player, "messages.spawn-set");
            return true;
        }

        if (args.length == 0) {
            openMenu(player);
            return true;
        }

        switch (args[0].toLowerCase(Locale.ROOT)) {
            case "enter" -> enterArena(player);
            case "leave" -> leaveArena(player);
            case "create" -> {
                if (requireAdmin(player)) {
                    setArenaCenter(player.getLocation());
                    send(player, "messages.arena-created");
                }
            }
            case "set" -> {
                if (requireAdmin(player)) {
                    setSpawn(player.getLocation());
                    send(player, "messages.spawn-set");
                }
            }
            case "remove" -> {
                if (requireAdmin(player)) {
                    getConfig().set("arena.enabled", false);
                    saveConfig();
                    countdowns.clear();
                    send(player, "messages.arena-removed");
                }
            }
            case "reload" -> {
                if (requireAdmin(player)) {
                    reloadConfig();
                    countdowns.clear();
                    send(player, "messages.reloaded");
                }
            }
            default -> send(player, "&cUsage: /afk [create|set|enter|leave|remove|reload]");
        }
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (command.getName().equalsIgnoreCase("setafk")) {
            return List.of();
        }
        if (args.length != 1) {
            return List.of();
        }
        List<String> choices = new ArrayList<>(List.of("enter", "leave"));
        if (sender.hasPermission("hexafk.admin")) {
            choices.addAll(List.of("create", "set", "remove", "reload"));
        }
        String prefix = args[0].toLowerCase(Locale.ROOT);
        return choices.stream().filter(choice -> choice.startsWith(prefix)).toList();
    }

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        if (!(event.getView().getTopInventory().getHolder() instanceof AFKMenuHolder)) {
            return;
        }
        event.setCancelled(true);
        if (!(event.getWhoClicked() instanceof Player player) || event.getClickedInventory() != event.getView().getTopInventory()) {
            return;
        }
        int enterSlot = getConfig().getInt("gui.enter.slot", 11);
        if (event.getSlot() == enterSlot) {
            player.closeInventory();
            enterArena(player);
        }
    }

    @EventHandler
    public void onInventoryDrag(InventoryDragEvent event) {
        if (event.getView().getTopInventory().getHolder() instanceof AFKMenuHolder) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        UUID id = event.getPlayer().getUniqueId();
        countdowns.remove(id);
        returnLocations.remove(id);
    }

    private boolean requireAdmin(Player player) {
        if (isAdmin(player)) {
            return true;
        }
        send(player, "messages.no-permission");
        return false;
    }

    private boolean isAdmin(Player player) {
        return player.hasPermission("hexafk.admin");
    }

    private void enterArena(Player player) {
        if (!getConfig().getBoolean("arena.enabled", true)) {
            send(player, "messages.arena-disabled");
            return;
        }
        Location destination = configuredLocation("spawn", true);
        if (destination == null) {
            send(player, "messages.location-unavailable");
            return;
        }
        returnLocations.putIfAbsent(player.getUniqueId(), player.getLocation().clone());
        player.teleport(destination);
        send(player, "messages.entered");
    }

    private void leaveArena(Player player) {
        countdowns.remove(player.getUniqueId());
        Location destination = returnLocations.remove(player.getUniqueId());
        if (destination == null || destination.getWorld() == null) {
            destination = player.getWorld().getSpawnLocation();
        }
        player.teleport(destination);
        send(player, "messages.left");
    }

    private void updatePlayers() {
        if (!getConfig().getBoolean("arena.enabled", true)) {