Solved Nothing happens ingame

Discussion in 'Plugin Development' started by Epixel, Sep 10, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Epixel

    I'm working on a remake of the mcpvp salvaging plugin. What I want in the code is that if you're holding a diamond helmet, and rightclick a diamondblock with a furnace to it, you will get 5 diamonds. No errors are on the console, but nothing happens when I rightclick the diamondblock

    Main:
    Code:
    package com.epixel.salvaging;
    
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.epixel.salvaging.diamond.DHelmet;
    
    public class Main extends JavaPlugin {
    
        public void onEnable() {
            getLogger().info("Salvaging has been enabled!");
    
        }
    
        public void registerEvents() {
            PluginManager pm = getServer().getPluginManager();
    
            pm.registerEvents(new DHelmet(), this);
        }
    
        public void onDisable() {
            getLogger().info("Salvaging has been disabled!");
    
        }
    
    }
    
    DHelmet:
    
    package com.epixel.salvaging.diamond;
    
    import org.bukkit.Material;
    import org.bukkit.block.BlockFace;
    import org.bukkit.entity.Player;
    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.inventory.ItemStack;
    
    public class DHelmet implements Listener {
    
        @EventHandler
        public void onSalvage(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if (event.getClickedBlock().getType() == Material.DIAMOND_BLOCK
                        && event.getClickedBlock().getRelative(BlockFace.DOWN).getType() == Material.FURNACE
                        || event.getClickedBlock().getRelative(BlockFace.SOUTH).getType() == Material.FURNACE
                        || event.getClickedBlock().getRelative(BlockFace.UP).getType() == Material.FURNACE
                        || event.getClickedBlock().getRelative(BlockFace.NORTH).getType() == Material.FURNACE
                        || event.getClickedBlock().getRelative(BlockFace.WEST).getType() == Material.FURNACE
                        || event.getClickedBlock().getRelative(BlockFace.EAST).getType() == Material.FURNACE) {
                    if (player.getItemInHand().getType() == Material.DIAMOND_HELMET) {
                        ItemStack diamond5 = new ItemStack(Material.DIAMOND, 5);
                        player.getInventory().remove(player.getItemInHand());
                        player.getWorld().dropItem(player.getLocation(), diamond5);
                    }
                }
            }
        }
    }
     
  2. @Epixel
    Well, you create a "registerEvents" (which by the way is quite unnecessary) but you never call it.
     
  3. Offline

    Epixel

    Thank you haha Im retarded.
     
Thread Status:
Not open for further replies.

Share This Page