Solved What does my plugin do?!

Discussion in 'Plugin Development' started by GabeGaming11, Feb 18, 2015.

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

    GabeGaming11

    I started to make plugins only yesterday... I'm a noob!

    I have just started my plugin and i'm not sure if it will work?

    Does this do anything, if so what?
    (Class #1)
    Code:
    package me.gabegaming11.passtheparcel;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class PassTheParcel extends JavaPlugin {
    
        @Override
        public void onEnable() {
            new PlayerListener(this);
        }
       
        @Override
        public void onDisable() {
           
        }
       
    }
    (Class #2)
    Code:
    package me.gabegaming11.passtheparcel;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    
    public class PlayerListener implements Listener {
    
        public PlayerListener(PassTheParcel plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
       
        @EventHandler
        public void onRightClickPlayer(PlayerInteractEntityEvent e) {
           
            if (e instanceof Player) {
               
                Player player = e.getPlayer();
               
                if (player.getInventory().contains(Material.ENDER_CHEST)) {
                   
                    player.sendMessage(ChatColor.GREEN + "Works!");
                   
                }
               
            }
           
        }
       
    }
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    GabeGaming11

    no, i should probably do that...

    oh, it doesn't do what is supposed to do

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  4. Offline

    ChipDev

    Its because you are making a constructor not correctly - (GREAT JOB ON KNOWING WHAT ONE IS!)

    Bukkit.getPluginManager().registerEvents(this, new PlayerListener(this)); on your enable, You event will call on right/left clicking an entity (Player, creeper, etc.)
     
  5. Offline

    _Filip

    @ChipDev dude are you sick in the head? He is registering the event... In the constructor...
     
  6. Offline

    GabeGaming11

    @_Filip Actually, thanks to @ChipDev, my plugin now works, I must have been registering it wrong!
    Thanks for the help!
     
    ChipDev likes this.
Thread Status:
Not open for further replies.

Share This Page