Someone just needs to compile it. Code:java @EventHandlerpublic void onDrink(PlayerInteractEvent event) { if(event.getAction() == Action.RIGHT_CLICK || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if(event.getPlayer().getInventory().getItemInHand.getType() == Material.MILK_BUCKET) { event.setCancelled(true); } }}
Yeah ill compile and test it for you After a test the code didn't work. Ill have a little play and see if i can get it to i used this code; package uk.co.blogspot.zigenzag; import java.util.logging.Logger; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class main extends JavaPlugin{ public final Logger log = Logger.getLogger("Minecraft"); public String prefix = "[Anti-Milk] "; public final Drink drink = new Drink(); @Override public void onEnable(){ this.log.info(prefix + "Has been enabled!"); PluginManager pm = getServer().getPluginManager(); pm.registerEvents(this.drink, this); this.log.info(prefix + "Milk can't be drunk anymore!"); } @Override public void onDisable(){ this.log.info(prefix + "Has been disabled!"); this.log.info(prefix + "Milk can be drunk once more!"); } } and for Drink i used; package uk.co.blogspot.zigenzag; import java.util.logging.Logger; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; public class Drink implements Listener { public final Logger log = Logger.getLogger("Minecraft"); @EventHandler public void onDrink(PlayerInteractEvent event) { if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if(event.getPlayer().getInventory().getItemInHand().getType() == Material.MILK_BUCKET) { event.setCancelled(true); log.info("Milk drinking stopped!"); } } } } I deoped my self was in survival and nothing EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Zigenzag Use the [syntax=java]code here[/syntax] tags. Also, sorry, but you did things really weirdly. You can make it a lot better and in only 1 class. Code:java package me.gomeow.noMilk; import org.bukkit.Material;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.Action;import org.bukkit.event.player.PlayerInteractEvent;import org.bukkit.plugin.java.JavaPlugin; public class noMilk extends JavaPlugin implements Listener { public void onEnable() { this.getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void onDrinkMilk(PlayerInteractEvent event) { Action a = event.getAction(); if(a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) { if(event.getPlayer().getInventory().getItemInHand().getType() == Material.MILK_BUCKET) { if(event.getPlayer().isOp()) return; event.setCancelled(true); } } }} Here is the download: https://www.dropbox.com/s/kxpj0c3j1gfq9b4/noMilk.jar And lastly, please give me credit where it is due, obviously I supplied the code.
because there is not much code you should put it into one class. I don't think i matters, this will make it so players can't interact with the milk bucket, and p.setUseItemInHand(false); 1. I'm not even sure if that exists and 2. I think it is pretty much the same thing. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Done http://dl.dropbox.com/u/104060836/NoMilkDrink.jar (For 1.4.5) It doesn't block the animation since that is client side.
Both plugins don't help. Player after drink milk is cured from every negative effects. EDIT 1 Both plugins makes errors. [SEVERE] Error occurred while enabling NoMilkDrink v1.0 (Is it up to date?) java.lang.NoClassDefFoundError: net/minecraft/server/v1_4_5/Item at me.cybermaxke.nomilkdrink.NoMilkDrink.onEnable(NoMilkDrink.java:13) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:374) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:270) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:252) at net.minecraft.server.MinecraftServer.j(MinecraftServer.java:320) at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:299) at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:258) at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:147) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:398) at net.minecraft.server.ThreadServerApplication.run(SourceFile:856) Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_4_5.Item at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:34) at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 12 more
I would just install Skript and then create a skript itself that says when a player tries to drink milk, cancel the event. Take you all of about 1min to install Skript, and a further 5mins to create the necessary skript to do this.
I will compile it for 1.4.5-R0.2 http://dl.dropbox.com/u/104060836/NoMilkDrink1.4.5-R0.2.jar EDIT by Moderator: merged posts, please use the edit button instead of double posting.