Leo Flanagan

make a plugin where the posion effect doesnt work

Kodari AI
KodariOct 31 at 11:28 pm 1
PoisonNullifier
A Minecraft plugin that completely disables the poison effect for all players. It intercepts poison application events, cancels poison damage, removes active poison effects on join, and prevents new poison applications from any source including mobs, potions, and environmental hazards. The plugin provides configurable options to toggle the feature globally or per-world, with a simple reload command for administrators. It ensures players never suffer from poison status effects, making gameplay more forgiving in PvE and PvP scenarios.

I’ll create a plugin that removes existing potion effects and blocks new potion and lingering-cloud effects.

Created NoPotionEffects. It clears active potion effects when enabled and blocks new effects, splash potions, and lingering-cloud applications.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 70
src/main/java/com/kodari/nopotioneffects/NoPotionEffectsPlugin.java
package com.kodari.nopotioneffects;

import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.plugin.java.JavaPlugin;

public final class NoPotionEffectsPlugin extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
        Bukkit.getWorlds().forEach(world -> world.getLivingEntities().forEach(this::removeActiveEffects));
    }

    @EventHandler
    public void onPotionEffectChange(EntityPotionEffectEvent event) {
        if (event.getAction() == EntityPotionEffectEvent.Action.ADDED
                || event.getAction() == EntityPotionEffectEvent.Action.CHANGED) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onPotionSplash(PotionSplashEvent event) {
        event.getAffectedEntities().forEach(entity -> event.setIntensity(entity, 0.0));
    }

    @EventHandler
    public void onAreaEffectCloudApply(AreaEffectCloudApplyEvent event) {
        event.setCancelled(true);
    }

    private void removeActiveEffects(LivingEntity entity) {
        for (PotionEffect effect : entity.getActivePotionEffects()) {
            entity.removePotionEffect(effect.getType());
        }
    }
}