Roicho
📎 1 file 3,288 chars
📄
pasted-code-1789666989706.txt
txt 73 lines
▶
Create a lightweight Paper plugin for Minecraft Java 1.21.11 using Java 21.

The plugin should implement the following gameplay restrictions:

1. SPEAR LUNGE NERF

* Add a 3-second cooldown to the Spear's Lunge enchantment.
* The cooldown must be per-player.
* Prevent Lunge spam through item swapping, hotbar swapping, attribute swapping, or any other method of bypassing the cooldown.
* Detect actual Lunge activation rather than normal spear attacks.
* If Lunge is attempted while on cooldown, prevent the Lunge.
* Do not change any other spear mechanics.
* Players without Lunge should be completely unaffected.

2. TOTEM LIMIT

* A player must never be able to have more than 6 Totems of Undying in their inventory.
* Count Totems across the entire player inventory, including the offhand.
* If a player attempts to pick up, receive, move, or otherwise obtain a Totem that would put them above 6, prevent the excess Totem from entering their inventory.
* Handle common inventory-transfer and item-manipulation methods where reasonably possible.
* Do not unnecessarily delete legitimate Totems.
* The maximum of 6 must be configurable in config.yml.

3. TOTEM USE COOLDOWN

* Add a 30-second cooldown after a Totem of Undying successfully activates.
* The cooldown must be per-player.
* While the cooldown is active, another Totem must NOT be able to activate for that player.
* The 30-second cooldown must be configurable in config.yml.
* Prevent bypassing the cooldown by swapping Totems between the main hand, offhand, hotbar, or inventory.
* Only start the cooldown when the Totem actually activates, not when the player merely holds or equips it.
* Do not interfere with normal Totem behavior when the player is not on cooldown.

4. COMPLETELY DISABLE CART PVP

* Disable Minecarts being used for PvP.
* Prevent Minecarts from intentionally dealing collision/impact damage to players.
* Normal Minecart transportation and railway systems should continue working.
* Do not unnecessarily break normal Minecart mechanics.

5. COMPLETELY DISABLE CRYSTAL PVP

* Disable End Crystal PvP.
* End Crystals must not be able to damage players.
* Prevent players from using End Crystals as a PvP weapon.
* Ensure crystal explosions cannot bypass the restriction through alternate damage/explosion events.
* Avoid breaking unrelated End Crystal functionality where possible.

6. GENERAL REQUIREMENTS

* Paper 1.21.11.
* Java 21.
* No client-side mods required.
* Efficient event-based implementation.
* Avoid unnecessary repeating tasks.
* All important values must be configurable in config.yml.
* Include plugin.yml.
* Use modern Paper APIs appropriate for 1.21.11.
* Avoid deprecated APIs where possible.
* Do not modify unrelated vanilla mechanics.
* Provide complete source code.
* Provide exact Gradle or Maven build instructions.
* The final result must compile into a single ready-to-drop .jar for the plugins folder.

Default config:
lunge-cooldown: 3 seconds
totem-max-count: 6
totem-cooldown: 30 seconds
cart-pvp: disabled
crystal-pvp: disabled

Prioritize reliable exploit prevention, especially item swapping and inventory manipulation, while keeping the plugin lightweight and suitable for a survival SMP.
Kodari AI
KodariSep 17 at 5:52 pm 2
CombatRestrictions
Lightweight Paper plugin enforcing survival SMP combat rules. Implements a per-player 3-second cooldown on the Spear Lunge enchantment, preventing bypass through item or hotbar swapping while leaving normal spear attacks untouched. Enforces a configurable maximum of 6 Totems of Undying per player inventory, blocking excess totems from entering via pickup, transfer, or inventory manipulation. Adds a configurable 30-second per-player cooldown after a Totem successfully activates, preventing another activation during the cooldown regardless of totem swapping. Completely disables Minecart and End Crystal PvP by cancelling collision and explosion damage to players while preserving transportation and unrelated functionality. All values configurable in config.yml, event-based, no repeating tasks.
  1. Create the Gradle/Paper project metadata and default configuration.

  2. Add per-player cooldown handling and actual Lunge/Totem activation listeners.

  3. Add inventory-wide Totem limiting with pickup, transfer, click, and drag protection.

  4. Add configurable minecart and End Crystal PvP damage/explosion restrictions.

  5. Include exact build and installation instructions.

Created the complete Paper 1.21.11 / Java 21 plugin.

Implemented:

  • Per-player 3-second Spear Lunge cooldown using actual PlayerLungeEvent.

  • Configurable six-Totem inventory limit, including offhand.

  • Totem protection for pickups, hopper transfers, inventory clicks, hotbar swaps, and drags.

  • Per-player 30-second cooldown after successful Totem activation.

  • Minecart and TNT minecart PvP damage restrictions.

  • End Crystal player-damage and explosion restrictions.

  • Event-based implementation with no repeating tasks.

  • plugin.yml, config.yml, Gradle build files, source code, and README.

Build with:

Shell
gradle clean build

The resulting JAR is:

Plain Text
build/libs/smp-restrictions-1.0.0.jar

Configuration is located at:

Plain Text
plugins/SmpRestrictions/config.yml
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
10 398
src/main/java/com/kodari/smprestrictions/SmpRestrictionsPlugin.java
package com.kodari.smprestrictions;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class SmpRestrictionsPlugin extends JavaPlugin {

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

        long lungeCooldownSeconds = Math.max(0L, getConfig().getLong("lunge-cooldown-seconds", 3L));
        long totemCooldownSeconds = Math.max(0L, getConfig().getLong("totem-cooldown-seconds", 30L));
        int totemMaxCount = Math.max(0, getConfig().getInt("totem-max-count", 6));
        boolean cartPvpEnabled = getConfig().getBoolean("cart-pvp-enabled", false);
        boolean crystalPvpEnabled = getConfig().getBoolean("crystal-pvp-enabled", false);

        CooldownManager lungeCooldowns = new CooldownManager(lungeCooldownSeconds);
        CooldownManager totemCooldowns = new CooldownManager(totemCooldownSeconds);

        Bukkit.getPluginManager().registerEvents(
                new GameplayRestrictionListener(lungeCooldowns, totemCooldowns, cartPvpEnabled, crystalPvpEnabled),
                this
        );
        Bukkit.getPluginManager().registerEvents(new TotemLimitListener(totemMaxCount), this);
    }
}