Help creating my plugin

Discussion in 'Plugin Development' started by DanTDM2727, Sep 13, 2015.

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

    DanTDM2727

  2. Online

    timtower Administrator Administrator Moderator

    Moved to plugin development
    @DanTDM2727 Server log?
    And I am amazed that you can even export it as you register 2 eventhandlers but neither of them implement listener
     
  3. Offline

    DanTDM2727

    what do you mean
     
  4. Online

    timtower Administrator Administrator Moderator

    @DanTDM2727 That both of your classes need to implement Listener
     
  5. Offline

    DanTDM2727

    show me a code plz
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    DanTDM2727

    copy my code and put the listener in i dont no where it go's and who taught you how to make plugins
     
  8. Offline

    Zombie_Striker

    1. No need for a 'Menu' instance
    2. A NEW MAIN!! This will create an infinite loop of mains.
    3. What is 'i' in the playerinteractevent. That should cause a LOT of errors in your IDE (if you
    4. re using one)
    5. You did not implement listener
    I'm just going to stop here. I see there is alot more in the other class too, so I'm just going to tell you to LEARN JAVA FIRST (My Signature)..Everything will make sense after you do that.
     
  9. Online

    timtower Administrator Administrator Moderator

    @DanTDM2727 I won't do that.
    And I am self taught.
     
  10. Offline

    DanTDM2727

    does it go here @timtower


    package me.YouTubeDanTDM.menuinv;

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Menu extends JavaPlugin {

    public final class LoginListener implements Listener {
    @EventHandler
    public void normalLogin(PlayerLoginEvent event) {

    private Menu menu;

    public void onEnable() {
    menu = new Menu (this);
    Bukkit.getServer().getPluginManager().registerEvent(this, this);
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
    if (i(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    menu.show(e.getPlayer());
    }
    }
     
  11. Online

    timtower Administrator Administrator Moderator

    @DanTDM2727 No, please check the examples on the link.
    And make sure to don't use code that you don't need
     
  12. Offline

    DanTDM2727

    Where does it go

    and what code
     
  13. Online

    timtower Administrator Administrator Moderator

    @DanTDM2727 After the extends JavaPlugin,
    And the place where you create a new instance of Menu every time, that won't work.
     
  14. Offline

    DanTDM2727

    just tell me what code and where to put it i really want to create my first plugin
    @timtower
     
  15. Online

    timtower Administrator Administrator Moderator

  16. Offline

    boomboompower

    Im tired of this, the way you add Listener
    Code:
    public class Classname extends JavaPlugin implements Listener
    This is one of the most basic things to do in a plugin, if you can't do that, don't try making a plugin with EventHandler.
    Sorry @timtower for spoonfeeding. But I don't want him making another thread like this.
     
    oceantheskatr likes this.
  17. Offline

    DanTDM2727

    just tell me where i put it

    Code:
    package me.YouTubeDanTDM.menuinv;
    
    import org.bukkit.Bukkit;
    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.plugin.java.JavaPlugin;
    
    public class Menu extends JavaPlugin {
       
       public class Classname extends JavaPlugin implements Listener
       
       private Menu menu;
       
       public void onEnable() {
         menu = new Menu (this);
         Bukkit.getServer().getPluginManager().registerEvent(this, this);
       }
    
       @EventHandler
       public void onPlayerInteract(PlayerInteractEvent e) {
         if (i(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
         menu.show(e.getPlayer());
       }
    }

    @boomboompower and @timtower is this correct
     
    Last edited by a moderator: Sep 14, 2015
  18. Online

    timtower Administrator Administrator Moderator

    He just did!
    And no, that is not correct, you don't copy paste it literally, you replace things like "Classname" into the actual name of the class.
     
  19. Offline

    DanTDM2727

    so do i make a new class
     
  20. Online

    timtower Administrator Administrator Moderator

    Did we say that you needed to do that?
     
  21. Offline

    DanTDM2727

    i did this

    Code:
    package me.YouTubeDanTDM.menuinv;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    
    import net.md_5.bungee.api.ChatColor;
    
    public class PlayerListener implements Listener {
       
       public PlayerListener(EventHandle plugin) {
         plugin.getServer().getPluginManager().registerEvent(this, plugin);
       }
    
       @EventHandler
       public void Death(PlayerDeathEvent event) {
         
         Player player = event.getPlayer();
         
         player.sendMessage(ChatColor.AQUA + "No death");
         player.kickPlayer("Do not kill people");
       }
       
    }
     
    Last edited by a moderator: Sep 14, 2015
  22. Online

    timtower Administrator Administrator Moderator

    @DanTDM2727 Now you are getting somewhere, besides the fact that you are kicking the one that dies.
    Please build on the Bukkit jar instead of the jar that contains bungee
     
  23. Offline

    DanTDM2727

    @timtower do you have a video about this that i can learn from

    so do i put import net.md_5.bukkit.api.ChatColor;

    EDIT by Timtower: merged posts, please use the edit button instead of double posting.
     
  24. Online

    timtower Administrator Administrator Moderator

    Nope, I learned from javadocs and trying.
    I am telling you not to use that one.
     
  25. Offline

    DanTDM2727

    then what do i use
     
  26. Online

    timtower Administrator Administrator Moderator

    The ChatColor that has Bukkit in its import
     
  27. Offline

    DanTDM2727

    then this


    package me.YouTubeDanTDM.menuinv;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;



    public class PlayerListener implements Listener {

    public PlayerListener(EventHandle plugin) {
    plugin.getServer().getPluginManager().registerEvent(this, plugin);
    }

    @EventHandler
    public void Death(PlayerDeathEvent event) {

    Player player = event.getPlayer();

    player.sendMessage(ChatColor.GREEN + "No death");
    player.kickPlayer("Do not kill people");
    }

    }
     
  28. Online

    timtower Administrator Administrator Moderator

  29. Offline

    DanTDM2727

  30. Online

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page