Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
SayNoToBonemeal bukkit mod
name: SayNoToBonemeal
main: com.github.kksym.saynotobonemeal.SayNoToBonemeal
version: 1.0.0
package com.github.kksym.saynotobonemeal;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
public class SayNoToBonemeal extends JavaPlugin {
private PluginDescriptionFile description;
private class PlayerInteractListener implements Listener {
// Disables Bone Meal for growing trees
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
// Get the item involved in the event
ItemStack item = event.getItem();
// Check if the item is an Ink Sack with data as 15 (Bone Meal)
if (item.getType() == Material.INK_SACK
&& item.getData().getData() == 15) {
// When the event has a block and it's a sapling of some
// sort, cancel the event
if (event.hasBlock()
&& event.getClickedBlock().getType() == Material.SAPLING) {
public void onEnable() {
description = getDescription();
PluginManager manager = getServer().getPluginManager();
manager.registerEvents(new PlayerInteractListener(), this);
getLogger().info(description.getName() + " v" + description.getVersion() + " enabled!");
public void onDisable() {
getLogger().info(description.getName() + " v" + description.getVersion() + " disabled!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.