NestO

make sure hit doesnt ghost it should work use 1.20.4 video or shield stun clips to make it accurate make sure it works for 26.2

๐Ÿ“Ž 1 file 2,181 chars
๐Ÿ“„
pasted-code-1789207115224.txt
txt 69 lines
โ–ถ
# Shield Stun Plugin - AI Generation Prompt

You are creating a PaperMC plugin for version 1.21 / 26.2. Create a complete, functional plugin called "ShieldStun" that implements a double-click shield mechanic.

## Requirements

### Core Mechanic
- Detect when a player right-clicks while holding a shield twice within 0.5 seconds
- When triggered, stun all players within 8 blocks of the attacker
- Apply vertical knockback (upward velocity boost) to stunned players
- Apply horizontal knockback away from the attacker
- 30-tick stun duration (1.5 seconds) - player cannot move during this time
- 2-second cooldown between stuns per player

### Configuration (config.yml)
```yaml
shield-stun:
  enabled: true
  double-click-delay: 500  # milliseconds to detect double click
  stun-radius: 8  # blocks
  stun-duration: 30  # ticks
  cooldown: 2  # seconds
  vertical-knockback: 1.2
  horizontal-knockback: 0.8
  require-permission: false
  cooldown-message: "&cShield stun on cooldown for &a%cooldown%s"
  stun-message: "&eYou were stunned!"
```

### Features
- Cooldown system (per-player, configurable)
- Configurable knockback values
- Configurable stun duration and radius
- Permission support (`shieldstun.use`)
- Reload command: `/shieldstun reload`
- Status command: `/shieldstun status`
- Sound effects when stun triggers
- Particle effects (explosion particles at stun location)

### Plugin Metadata
- Name: ShieldStun
- Main Class: com.shieldstun.ShieldStun
- Version: 1.0
- API Version: 1.21
- Description: "Double-click shield to stun nearby players with knockback"
- Author: YourName
- Load: POSTWORLD

### Code Structure
- Main plugin class
- Event listener for PlayerInteractEvent
- Cooldown manager (HashMap with UUID tracking)
- Config handler
- Command executor
- Utility methods for knockback application

### Do NOT Include
- Database connections
- External dependencies beyond Paper API
- Console spam or excessive logging

### Must Include
- Try-catch error handling
- Null checks
- Comment explanations
- Standard Bukkit conventions

Generate the complete plugin with all files needed (main class, plugin.yml, config.yml) ready to compile with Paper API 1.21.
Kodari AI
KodariSep 12 at 10:03 am 1
ShieldStun
A Paper plugin for 1.21/26.2 that adds a double-click shield stun mechanic. Detects rapid right-clicks with a shield within 0.5 seconds, stunning all players within a configurable radius (default 8 blocks). Applies vertical and horizontal knockback away from the attacker, immobilizes victims for 30 ticks, and enforces a 2-second per-player cooldown. Features configurable settings for radius, duration, knockback values, and cooldown via config.yml. Includes permission support, reload and status commands, sound effects, and explosion particles on trigger. Uses a HashMap-based cooldown manager and event-driven architecture with proper error handling and null checks throughout.

[Generation stopped]

NestO

remove radius thing

Kodari AI
KodariSep 12 at 10:05 am 1

Removed the radius-based stun behavior.

  • No stun-radius setting

  • No area-wide player scan

  • Only the player directly hit/aimed at is stunned

  • The 4.5 block value is only the raycast reach for detecting the target, not a stun radius

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 486
src/main/java/com/shieldstun/ShieldStun.java
package com.shieldstun;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public final class ShieldStun extends JavaPlugin implements CommandExecutor, TabCompleter {
    private CooldownManager cooldownManager;
    private StunManager stunManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        cooldownManager = new CooldownManager();
        stunManager = new StunManager(this);
        getServer().getPluginManager().registerEvents(new ShieldStunListener(this), this);

        if (getCommand("shieldstun") != null) {
            getCommand("shieldstun").setExecutor(this);
            getCommand("shieldstun").setTabCompleter(this);
        }
    }

    @Override
    public void onDisable() {
        if (cooldownManager != null) {
            cooldownManager.clear();
        }
        if (stunManager != null) {
            stunManager.clear();
        }
    }

    public CooldownManager getCooldownManager() {
        return cooldownManager;
    }

    public StunManager getStunManager() {
        return stunManager;
    }

    public boolean isEnabledSetting() {
        return getConfig().getBoolean("shield-stun.enabled", true);
    }

    public long getDoubleClickDelayMillis() {
        return Math.max(50L, getConfig().getLong("shield-stun.double-click-delay", 500L));
    }

    public int getStunDurationTicks() {
        return Math.max(1, getConfig().getInt("shield-stun.stun-duration", 30));
    }

    public long getCooldownMillis() {
        return Math.max(0L, getConfig().getLong("shield-stun.cooldown", 2L) * 1000L);
    }

    public double getVerticalKnockback() {
        return getConfig().getDouble("shield-stun.vertical-knockback", 1.2D);
    }

    public double getHorizontalKnockback() {
        return getConfig().getDouble("shield-stun.horizontal-knockback", 0.8D);
    }

    public boolean requiresPermission() {
        return getConfig().getBoolean("shield-stun.require-permission", false);
    }

    public String getCooldownMessage() {
        return getConfig().getString("shield-stun.cooldown-message", "&cShield stun on cooldown for &a%cooldown%s");
    }

    public String getStunMessage() {
        return getConfig().getString("shield-stun.stun-message", "&eYou were stunned!");
    }

    public static String color(String message) {
        return ChatColor.translateAlternateColorCodes('&', message == null ? "" : message);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0 || args[0].equalsIgnoreCase("status")) {
            sender.sendMessage(color("&eShieldStun &7is " + (isEnabledSetting() ? "&aenabled" : "&cdisabled") + "&7."));
            sender.sendMessage(color("&7Double-click: &f" + getDoubleClickDelayMillis() + "ms &7| Duration: &f" + getStunDurationTicks() + " ticks"));
            sender.sendMessage(color("&7Cooldown: &f" + (getCooldownMillis() / 1000.0D) + "s &7| Knockback: &f" + getHorizontalKnockback() + " horizontal, " + getVerticalKnockback() + " vertical"));
            return true;
        }

        if (args[0].equalsIgnoreCase("reload")) {
            if (!sender.hasPermission("shieldstun.admin")) {
                sender.sendMessage(color("&cYou do not have permission to do that."));
                return true;
            }
            reloadConfig();
            sender.sendMessage(color("&aShieldStun configuration reloaded."));
            return true;
        }

        sender.sendMessage(color("&eUsage: /" + label + " <reload|status>"));
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (args.length != 1) {
            return Collections.emptyList();
        }
        List<String> suggestions = new ArrayList<>();
        if (sender.hasPermission("shieldstun.admin")) {
            suggestions.add("reload");
        }
        suggestions.add("status");
        String prefix = args[0].toLowerCase();
        suggestions.removeIf(value -> !value.startsWith(prefix));
        return suggestions;
    }
}