Solved [Finally solved!] I really need help...

Discussion in 'Plugin Development' started by ArlenM, Nov 13, 2014.

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

    ArlenM

    I have seen this come up before for other people, but I get an error when I try to run my plugin on my server:

    http://pastebin.com/Mg3j5gZP

    I realise that this essentially means that my plugin.yml is for some reason not working with my project, however I have tried everything to get it up to specification and just do not know where I am going wrong. This is my first plugin, and I simply do not understand why it will not work.

    The main code:

    http://pastebin.com/f2bdTqhC
    (Simple I know but it is just a test)

    The plugin.yml:

    http://pastebin.com/EsScPLn8

    The file is called Arrows, the main class is called Arrows, I just don't get it. Any help would be great: rewriting it, telling me if I am missing something stupidly obvious, anything.
     
  2. Offline

    mine-care

    The problem is that in your plugin.yml you set main to ... .arrows.Arrows
    The hint is that arrows should be with capital a
    Chmage it to main: me.ProShadow123.Arrows.Arrows
    It should work.

    Also, don't use getLogger"Minecraft"); use just getLogger(); and you don't need to print enable and disable messages since bukkit does it by itself.
    And at the heck is this!!??
    public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    public void onInteract(PlayerInteractEvent e)
    {
    if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR)
    e.getPlayer().launchProjectile(Arrow.class);
    }
    }
    }
    }
    }}
    Whthfk? Two events in one?

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

    ArlenM

    Nope… This problem is fiendish and nothing seems to slay it ):

    http://pastebin.com/KaVJ2XRH

    It is my first code so there will be inefficiencies, but I do not believe that there is anything in the code that could prevent it from working.

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

    Skionz

    ArlenM Keep your package name lowercase, its good practice but I doubt thats the issue. Also stop watching thebcbros
     
  5. Offline

    ArlenM

    Cut down the code a bit to this:

    http://pastebin.com/DMvCv9Pf

    Still doesn't work...

    Why stop watching thebcbros? Starting out with bukkit, their tutorial was really useful? All I needed was to get a feel for bukkit-ing and it seemed pretty good...

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

    drpk

    ArlenM I don't know how to fix the main class problem but...
    You forgot to use the EventHandler annotation
    It's good practice to put the Override annotation on your onEnable and onDisable methods.
    You forgot to implement Listener
    public static Arrows plugin; is never used

    and lastly, you have a method in a method
     
  7. Offline

    ArlenM

    Yeah there are problems, but like I said I'm new to bukkit, although from previous coding experience, I'm guessing that those improvements you listed are just nice to have and not essential, so they won't cause me any problems - The main problem is that I still want to fix this error lol

    Sooo….
    Can anyone actually answer my problem rather than just tell me that my code is inefficient?
    If anyone wants the actual eclipse files I can email them or whatever, if you need more information then just say, but I really just want to get on with learning bukkit and I can't do that unless I eliminate this ridiculous error… By the way I am using a mac if that makes some sort of difference to anything.

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

    mythbusterma

    ArlenM

    The simplest fix for every future problem you're going to have is to stop watching BCBlowz, they are atrocious and the sole reason so many people come on here with code like yours going "wai don work?!?!?!" Learn Java, then try coming back to Bukkit.

    This is not a matter of "efficency," this is a matter of how many times you're going to come crawling back to this forum begging for our help because BCBlowz is just awful.

    https://docs.oracle.com/javase/tutorial/java/
     
    mine-care likes this.
  9. Offline

    ArlenM

    Ok, I'm not begging for help simply asking nicely, I'm good with C+ and not bad with java I'm just new to bukkit, and this is the first post I have ever made on any online help site, because I would only ever do this as a last resort and quite honestly there is no solution that works for me anywhere on the internet. I was looking for somebody helpful to give me advice, not for somebody like you to tell me I have bad code (Which I realise as I coded this in under ten minutes and it is my first time using the software and developing for the platform) and ask me not to come crawling back when all I wanted was a little help...
     
  10. Offline

    Th3Br1x

    Well, these are basicly essential "optimizations".

    Doesn't that tell the interface/Bukkit, that the following method should be triggered on that event?


    Your class needs to implement Listener, otherwise you can't listen to events. You also need to register the Listener, so that it'll work.

    You should read through this article on the Bukkit Wiki, that will solve most of your problems:
    http://wiki.bukkit.org/Plugin_Tutorial
     
  11. Offline

    ArlenM

    As a little thing for future, please only reply to this thread if you can help me in some way and not just to tell me I'm inferior so that I can get this solved as soon as possible.

    I'm tired now, if there are so many errors in my code could someone just rewrite it for me editing in fixes with annotations for where I went wrong, same message again: I am reasonably new to java, completely new to bukkit and just wanted to give it a try. All that I have here are people posting without fixes, speaking a language I don't understand (Java) and a few getting annoyed with me.

    The real question/focus is:

    Why will it not work? Because I see no rational explanation.

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

    Th3Br1x

    Well, i'm trying to help you. But to be honest, read through that article, and i think, your problems will be solved :)
    The best way to help is, to show somebody what's behind a snippet of code, rather than just telling him "that's doing what you want, so just use it" (my opinion).

    I'll just read through your code again and tell you, if I find a mistake. But please, don't expect me to post a working code. I'll show you, what you have to correct.

    Edit: So, yeah, the reason for your error (called stacktrace) is, that the path to your main class (the one extending JavaPlugin, Arrows.java) is wrong. You see that first line of code in your Arrows.java starting with "package"? The whole line after the space is your package. And that has to be in your plugin.yml in addition with the name of your main class, in your case "Arrows" (since the filename is "Arrows.java").

    Example:
    If your package is named "me.name.project" and your main class is called "Main.java", you'll have to put "me.name.project.Main" after the "main: " in your plugin.yml

    Do you understand that? :)
     
  13. Offline

    ArlenM

    Ok thanks
     
  14. Offline

    Th3Br1x

    ArlenM So, yeah, watch at the Edit of my post :)
     
  15. Offline

    ArlenM

  16. Offline

    Skionz

  17. Offline

    ArlenM

  18. Offline

    Googlelover1234

    ArlenM
    If you really want to understand this, using the Bukkit API as your sole foundation of the Java language isn't smart. You should really learn the language you'll be programming in, it really helps :)
     
  19. Offline

    ArlenM

    I suppose I probably should have a better grasp of java before trying to do this. If only one could code bukkit in C+ lol

    I just realised - I have been tackling this tiny error for over 2 hours. That is sad. I'm going to go now, but if anyone can give me anything more to help (Although I have had great help already nothing has fixed the original problem) that would be great.

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

    drpk

    ArlenM the main class is me.ProShadow123.Arrows.arrows
    Also, you're trying to put a method in a method inside of a class inside of a class :eek:
     
  21. Offline

    ZanderMan9

    ArlenM
    The issue I see is that Arrows is in a package called Arrows. Make that package lower-cased, arrows. Then leave your main in your plugin.yml as me.ProShadowWhatever.arrow.Arrow
    Oh also, your class needs to be capitalized. Your packages don't. That's how we do it in Java, and to me it doesn't make all that much sense (nor does the rest of Java), me being primarily a C# dev.
     
  22. Offline

    xize

    I would recommend to refactor your package and rename it, all of those letters in the package should be lowercase, you main class should start with a uppercase.

    then in your main you do: me.proshadow123.arrows.Arrows <- where Arrows with a capital A is your main class.

    then as follows I also would recommend to other plugins you made or maybe per acidentally overwritten files which now have the same sort package to refactor it or to delete it.

    for example you cannot have 2 plugins with a package name like: me.proshadow123.Arrows and a other with like me.proshadow123.Essentials, now lets say you have in both plugins Configuration.java this will start conflicting, however I think this is not your case though but in case you know it, if 2 main classes have the same name it will throw a exception at startup if the package name is the same.
     
  23. Offline

    Rocoty

    ArlenM You shouldn't run erroneous code and expect it to work properly. You should fix all your compiler errors first. Then, and only then should you look into fixing runtime issues. Chances are fixing the compiler error will also fix the runtime error.
     
  24. Offline

    Dragonphase


    Several reasons:

    • Almost every tutorial video for Bukkit plugin creation shows use of bad programming practices, such as the incorrect use of statics, the incorrect use of Logger and minimal presentation of an object-oriented approach (by creating a 1-class plugin.)
    • A large majority of the videos are made by people with minimal knowledge of Java and/or the Bukkit API.
    • Very few of the videos encourage or require you to have knowledge of Java before proceeding to watch them. I point this out because the Plugin Tutorial Wiki Page (which should be the first place anyone looks when wanting to begin creating Bukkit plugins) advises you to have an understanding of Java before proceeding.
    • Almost everyone who watches tutorial videos made by these people end up copying their coding standards.
    What you should really do before even considering to develop a Bukkit plugin is:
    • Pick up a Java book. There is literally nowhere on Earth you won't find one (well, there is, but you get the idea.) Read through it and learn about Java.
    • While you're at it, learn about the principles of Object Oriented Programming. Chances are you'll learn about this in a Java book, but if not, do some browsing.
    • Make some simple programs. One of the best ways to learn is to start coding something. Assuming you understand Java and the principles of OOP, create a Hello World program, then a calculator, then a text editor, and so on. Don't just copy a full program's code from the internet, you will not learn anything.
    • Make some mistakes and learn from them. Making mistakes is the best thing you can do in programming, because it encourages you to think about what went wrong and understand how to fix it. If you can't find out what's wrong with your program, seek help online, chances are StackOverflow has the answer.
    • Learn to read Stack traces. You will encounter bugs in your programs. The stack traces will help you trace where the bugs occurred and provide you with information as to what went wrong. If you understand the error, fix it. If you don't, seek help online.
    • Do some rubber duck debugging. This might sound silly, but it's really useful in helping you understand your program by speaking out loud the steps that your program takes or should take in order to work properly.
    • Don't worry if you think your program isn't as efficient as it could be. You should focus on making it work before making it work efficiently. After a while, you'll adapt to a more efficient way of development and it'll be more of a second nature to use the more suitable programming practices.
    This post isn't intended to make you feel inferior in any way. I'm just offering you some solid advice if you want to make Bukkit plugins. Nobody in this forum will write your plugin for you, but we will help in whatever seems to be the most suitable way, so there's my two cents.
     
    teej107, mythbusterma and Skionz like this.
  25. Offline

    ArlenM

    Ok.
    So I went away annoyed, and spent today learning how to java. Thanks to people who posted good tutorials and the like, I have actually found them very useful. So I came back today with my new knowledge and understood why people said my code was so bad, I now see that it was even worse than I thought lol.
    Anyway, a day dedicated to java has really helped me, and I have rewritten new code in a new file that now works! I hope to move on to making actual useful plugins now, thanks to anyone who helped!
    *SOLVED*
     
    Th3Br1x likes this.
Thread Status:
Not open for further replies.

Share This Page