[SOLVED] Plugin wont compile Please help =D

Discussion in 'Plugin Development' started by piringgg, Nov 4, 2011.

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

    piringgg

  2. Sorry but thats possibly one of the most terrible coding snippers ive ever seen. I suggest you delete it and start again looking at the state of that
     
  3. Offline

    piringgg

    Do you know what i did wrong?
     
  4. First of all you should read this.
    I assume you are trying to make plugins without having very much knowledge of Java, you should really watch some tutorials before trying to make more plugins.

    You closed your class after the first line, so what you code looks like is pretty much this:
    Code:java
    1. public class Zach extends JavaPlugin {
    2. Logger log = Logger.getLogger("Minecraft");
    3. }
     
  5. Offline

    piringgg

    OH ok thanks! =D and yea I do need to read more about java thanks =D

    ok well i changed that and it still wont work i was able to clean it up to only 2 errors but im stuck now heres what it looks like now:
    http://pastebin.com/zteEuZcH

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  6. Offline

    TheUnnamedDude

    I think your mainclass should be more like this:
    Code:
    package me.scherer.Zach;
    import java.util.logging.Logger;
    
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Zach extends JavaPlugin  {
    
        private final ZachBlockListener playerListener = new ZachBlockListener(this);
        Logger log = Logger.getLogger("Minecraft");
        public void onEnable(){
            log.info("Your plugin has been enabled.");
            PluginManager pm = this.getServer().getPluginManager();}
            pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Event.Priority.Normal, this);
        }
        public void onDisable(){
            log.info("Plugin Disabled!");
        }
    }
     
  7. Offline

    piringgg

    ok i did that heres what it looks like now: http://pastebin.com/0bP4Si35
    The following errors occurred:
    Exported with compile errors: Zach/me/scherer/Zach/Zach.java
    Exported with compile errors: Zach/me/scherer/Zach/ZachBlockListener.java

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  8. Offline

    mindless728

    learn java before even attempting to program plugins so you don't run into errors like this that anyone with basic java knowledge would either not do or could easily fix it themselves
     
  9. Offline

    piringgg

    I did what you said still didnt work

    I intend to learn more but I would like to know what I did wrong i plan to look as this plugin as a reference to help me learn java better, but yes I do see your point

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  10. Offline

    mindless728

    no, learn java first then when you have actual plugin programming issues come back, the problem you had was an issue that anyone with a very basic knowledge of java would have been able to point out

    the plugin development section is to get help with plugin development not java help, not trying to be rude but it takes time away from people that have plugin issues not java issues
     
  11. Offline

    piringgg

    was it a java problem?, im wondering what problem i had with this i find it easier to understand what im reading after trying it first
     
  12. Offline

    mindless728

    what you did was essentially this
    Code:java
    1.  
    2. public class MyClass {
    3. } //oops you ended your clas prematurely
    4. public void functionsDontGoHere() {
    5. }
    6.  


    ie a basic java syntax problem
     
  13. Offline

    TheUnnamedDude

    Here.
    i Think this is what you want:
    Mainclass:
    Code:
    package me.scherer.Zach;
    import java.util.logging.Logger;
    
    import org.bukkit.event.Event;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Zach extends JavaPlugin  {
    
        private ZachBlockListener blockListener = new ZachBlockListener(this);
        Logger log = Logger.getLogger("Minecraft");
        @Override
        public void onEnable(){
            log.info("Your plugin has been enabled.");
            PluginManager ps = this.getServer().getPluginManager();
            ps.registerEvent(Event.Type.BLOCK_BREAK, (Listener) blockListener, Event.Priority.Normal, this);
        }
        @Override
        public void onDisable(){
            log.info("Plugin Disabled!");
        }
    }
    
    blocklistener:
    Code:
    package me.scherer.Zach;
      
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.BlockListener;
    import org.bukkit.inventory.ItemStack;
     
    public class ZachBlockListener extends BlockListener{
        private Zach plugin;
        public ZachBlockListener(Zach instance){
            this.plugin = instance;
        }
      
        public void onBlockBreak(BlockBreakEvent event){
             Block block;
             block = event.getBlock();
             if(block.getType() == Material.LEAVES){
                 if(Math.random() * 100 <= 50){
                     block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.APPLE, 1));
             }
         }
    }
    } 
     
  14. Offline

    piringgg

    Thanks ill try that =D

    OK heres what i got now:
    http://pastebin.com/siKuzhPn

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  15. Your plugin.yml is wrong too. main: should be me.scherer.Zach.Zach
     
  16. Offline

    piringgg

  17. Offline

    Epicnameous

    In your block listener class
    Code:
    package me.scherer.Zach;

    should look like
    Code:
    package me.scherer.Zach.ZachBlockListener;


    My mistake!!!
     
  18. Why would he put ZachBlockListener in a package called ZachBlockListener ?
     
  19. Offline

    Epicnameous

    Oh wow your right I am wrong sorry, getting tired, don't listen to that!
     
    r3Fuze likes this.
  20. Offline

    piringgg

  21. Offline

    Lolmewn

    What are the errors?
     
  22. Offline

    piringgg

    it says that the jar does not contain the plugin.yml

    please help

    Any suggestions?: http://pastebin.com/72BqFhkf

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  23. Offline

    TheUnnamedDude

    where is your plugin.yml?
     
  24. Offline

    Lolmewn

    Well then, add a plugin.yml ;)
    That really is basic. A plugin.yml looks like this:
    Code:
    name: Apply
    version: 1.0
    main: nl.lolmen.apply.Main
    author: Lolmewn
    commands:
      apply:
        usage: /<command>
        description: Apply now!
     
  25. Offline

    piringgg

    Ok i did that and it STILL wont work =(

    I did that and it STILL wont work please help

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  26. Offline

    Icelaunche

    where did you put the plugin.yml?
     
  27. Offline

    leuchtfluegel

    Well, and whats the content of your plugin.yml?
    I hope you didn't just copy & paste it from the example :p
     
  28. Offline

    Mmarz11

    You did put the plugin.yml into the .jar right...?
     
  29. Offline

    piringgg

    yes i did and no i didnt paste and copy it
     
Thread Status:
Not open for further replies.

Share This Page