x_pika_chu

When any player kills a cow, the plugin must immediately:

Instantly kill the player (set their health to 0).

Kick the player from the server.

Display the exact kick message: "Killing cows is not allowed in this SMP"

Requirements:

This must apply to ALL players without exception.

Operators (OP), admins, and players with any permissions must NOT be exempt.

No permission node should bypass this rule.

The trigger should activate only when a player directly kills a cow (EntityType.COW).

The system should detect the killer properly using EntityDeathEvent.

The plugin must be lightweight and optimized.

Include a proper plugin.yml file.

Provide full source code in Java.

Compatible with the latest Minecraft version.

Optional (if possible):

Log the incident in console with the player’s name.

Prevent conflicts with other plugins.

Return:

Main Java class

plugin.yml

Any necessary explanations briefly.

Kodari AI
KodariFeb 25 at 12:50 pm 6,949 (v2)

I’ll create a lightweight plugin that kills and kicks any player who kills a cow, with no exceptions.

CowProtector
A strict enforcement plugin that immediately kills and kicks any player who kills a cow entity. No permission bypasses exist - all players including operators are subject to this rule. The plugin logs each violation to console and displays a clear kick message explaining the infraction.

Plan:

  • Main plugin class to register the listener

  • Event listener for EntityDeathEvent to detect cow kills

  • Check if killer is a player, kill them instantly, and kick with message

  • Log violations to console

Plugin complete! CowProtector instantly kills and kicks any player who kills a cow - no exceptions, no bypasses, no permissions. Console logs every violation with the player’s name.

All files have been generated! The plugin is complete and ready to use.

Summary:

  • CowProtector.java: Main plugin class that registers the event listener

  • CowKillListener.java: Detects cow kills, instantly kills the player (sets health to 0), kicks them with the exact message, and logs to console

  • plugin.yml: Plugin metadata with api-version 1.13+ for latest compatibility

  • build.gradle: Build configuration with Spigot API 1.21.4

The plugin works by listening to EntityDeathEvent at HIGHEST priority, checking if the entity is a Cow and if there’s a player killer, then immediately executing the punishment with no permission checks or bypasses.

x_pika_chu

And if a player kills a cow and gets kicked, make an announcement in the server that "(player) has killed a cow and has been kicked, this is there last warning" and after a player is kicked, edit the message from "killing a cow is not allowed in this server" to "Killing a cow is not allowed in this server, this is your last warning", if the same player tries to kill a cow again, he will get ip-banned

Kodari AI
KodariFeb 25 at 7:00 pm 5,908 (v2)

I’ll read the existing files first to understand the current implementation, then add kick tracking, server announcements, and IP-ban for repeat offenders.

Now I’ll update the plugin to track kicked players, broadcast announcements, and IP-ban repeat offenders.

Done! I’ve updated the plugin to:

  1. Track kicked players using a HashSet in the main plugin class

  2. First offense: Player dies, gets kicked with “killing a cow is not allowed in this server”, and server broadcasts in red: “(player) has killed a cow and has been kicked, this is there last warning”

  3. Second offense: Player dies, gets IP-banned, and is kicked with the message “Killing a cow is not allowed in this server, this is your last warning”

The kicked players list persists while the server is running, so repeat offenders will be IP-banned immediately.

x_pika_chu

no, I said that if a player kills a cow for the first time, he gets kicked with the message "Killing a cow is not allowed in this server, this is your last warning" and the server broadcasts ""(player) has killed a cow and has been kicked, this is there last warning", If the player kills a cow again, he gets banned with the message, " You have been banned from the server. Reason : killed a cow even after warning", and the server broadcast as "(player) killed a cow again and has been banned

Kodari AI
KodariFeb 25 at 7:03 pm 1,890 (v2)

I’ll read the existing files first to understand the current implementation, then modify it.

I’ll modify the listener to match your exact requirements.

Modified the CowKillListener to implement the exact kick/ban messages and broadcasts you specified - first offense kicks with warning, second offense bans the player.

x_pika_chu

I want ip-ban not normal ban

Kodari AI
KodariFeb 26 at 5:50 pm 5,366 (v2)

I’ll check the current project structure to see what ban functionality exists and modify it to use IP-ban instead.

I’ll update the ban system to use IP-ban instead of username ban.

Changed the ban system from username ban to IP-ban using BanList.Type.IP and the player’s IP address.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 98
src/main/java/com/cowprotector/CowProtector.java
package com.cowprotector;

import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class CowProtector extends JavaPlugin {

    @Getter
    private final Set<UUID> kickedPlayers = new HashSet<>();

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new CowKillListener(this), this);
        getLogger().info("CowProtector has been enabled! Cows are now protected.");
    }

    @Override
    public void onDisable() {
        getLogger().info("CowProtector has been disabled.");
    }
}