Anvil result stuck?

Discussion in 'Spigot Plugin Development' started by dbsps, May 21, 2017.

  1. Trying to learn some basic plugin stuff, I'm as green as they come this is literally my first attempt at learning. I put together this simple little plugin just to try and wrap my mind around some core concepts. The idea is if a player puts dirt into both slots of the anvil, it'll give em a diamond block (OP I know I'm not leaving it this way just learning). It sorta works but you can't remove the diamond block from the anvil.

    Here is the code:
    Code (Text):
    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.PrepareAnvilEvent;
    import org.bukkit.inventory.ItemStack;

    public class DirtyAnvil implements Listener {

        public void onPrepareAnvil(PrepareAnvilEvent e){
            if(e.getInventory().getItem(0) != null && e.getInventory().getItem(1) != null){
                ItemStack result = new ItemStack(Material.DIAMOND_BLOCK);
                if(e.getInventory().getItem(0).getType() == Material.DIRT && e.getInventory().getItem(1).getType() == Material.DIRT) {

    What am I doing wrong?
  2. What happens when you try to remove the diamond block from the anvil inventory?
  3. nothing, it's not clickable. I can see it but I can not pick it up.