Plugin Help

Discussion in 'Spigot Plugin Help' started by JaboyPeter, May 27, 2016.

  1. Hi sorry for posting the code here but I was wondering if anyone could help me with this code it is set to when you left click on a player head it will say their head to you.

    I dont know if im missing anything , as far as the plugin no errors in console and loads perfectly could be something with the listener idk.

    Thanks in advance guys!


    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.SkullType;
    import org.bukkit.block.Skull;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;

    public class Plugin extends JavaPlugin implements Listener {

    public void onEnable() {
    Bukkit.getServer().getLogger().info("PlayerInteractPlugin Enabled!");


    public void onDisable() {
    Bukkit.getServer().getLogger().info("PlayerInteractPlugin Enabled!");

    public void onPlayerInteract(PlayerInteractEvent e) {
    //check if the player clicked a block, either left or right click
    if(e.getAction() != Action.LEFT_CLICK_BLOCK
    && e.getAction() != Action.RIGHT_CLICK_BLOCK) {
    //check if player clicked a skull
    if(e.getClickedBlock().getType() == Material.SKULL) {
    Skull sk = (Skull) e.getClickedBlock().getState();
    if(sk.getSkullType() == SkullType.PLAYER) {
    e.getPlayer().sendMessage("Head Of ");

  2. You package name might be used if you get an error- It might be a common name - for example for my plugins I use me.ScenicJaguar101.pluginname
  3. Sw4p


    you need to register you listener class with this code in you onEnable() method:
    Code (Text):
    this.getServer().getPluginManager().registerListener(this, this);
  4. Code (Text):
    public void onEnable() {
    this.getServer().getPluginManager().registerListener(this, this);
  5. You have to put this in the plugin development part :)
    • Agree Agree x 2