I need Help

Discussion in 'Plugin Development' started by newUser, Dec 20, 2021.

  1. Offline

    newUser

    I need help with a problem and I'm just getting started with programming mincraft. As soon as I started I have this problem and I just can't find a solution.
    import org.bukkit.plugin.java.JavaPlugin;public class HalloWeltPlugin extends JavaPlugin {
    public void onEnable() {
    this.getLogger().info("Hallo Welt!");}
    public void onDisable() {
    }
    }
    then I get the following error message
    C:\Server\plugins\HalloWeltPlugin>javac HalloWeltPlugin.java -cp C:\Server\craftbukkit-1.18.1.jar
    HalloWeltPlugin.java:1: error: cannot find symbol
    import org.bukkit.plugin.java.JavaPlugin;
    ^
    symbol: class JavaPlugin
    location: package org.bukkit.plugin.java
    HalloWeltPlugin.java:3: error: cannot find symbol
    public class HalloWeltPlugin extends JavaPlugin {
    ^
    symbol: class JavaPlugin
    HalloWeltPlugin.java:5: error: cannot find symbol
    this.getLogger().info("Hallo Welt!");
    ^
    symbol: method getLogger()
    3 errors
     

    Attached Files:

  2. Offline

    timtower Administrator Administrator Moderator

    @newUser Why are you using eclipse but compiling manually?
     
  3. Offline

    newUser

    how else should I compile
     
  4. Offline

    timtower Administrator Administrator Moderator

    Strahan likes this.
  5. Offline

    Strahan

    Yea, gotta say, that's one of the weirdest requests I've seen in awhile. Did someone prank you by telling you that you must do it manually? heh

    Code:
    public void onEnable() {
      this.getLogger().info("Hallo Welt!");
    }
    The this keyboard is not necessary in this usage. It's used to refer to the current class, and invoking a class method of the class you are in doesn't require this. Another time it's handy is if you have a conflict of scope... like
    Code:
    class SomethingOrOther {
      private int widgets = 0;
    
      public SomethingOrOther(int widgets) {
      }
    }
    In that class, in the constructor, if you used widgets how does the system know if you mean the class widgets variable or the one passed? That's where this is useful, as you would set the class var to the method var via this.widgets = widgets; for example.

    Code:
    public void onDisable() {
    }
    There is no need to have empty methods in your class; if it has no code, there is no sense in having this.
     
  6. Offline

    newUser

    I have a book that unfortunately describes it like this -.-
    i'm absolutely new to the whole topic. in the meantime i have dealt a little more with the idea. Now compile there and understand why you thought I was kidding you that was pretty stupid: D Unfortunately I still don't get the error fixed
     
    Last edited: Dec 21, 2021
  7. Offline

    timtower Administrator Administrator Moderator

    @newUser From how many decades ago is that book?
     
  8. Offline

    newUser

    from 2020 and the author works at the tu Munich I really expected more. isbn 978-3-7475-0260-0
     
  9. Offline

    timtower Administrator Administrator Moderator

    @newUser How is python even involved :eek:
    My suggestion is to follow the compilation methods that your IDE uses.
    Which is Intelij from the looks of it in your case.
    Then your build path (the -cp) is handled by the IDE, compile errors show up in the code.
     
  10. Offline

    newUser

    all right, I'll do it that way. In the meantime I have been able to achieve small successes by fixing the integration of bukkit, which was not yet in the project itself.
     
  11. Offline

    timtower Administrator Administrator Moderator

    Which will make it a lot easier to write the correct code.
     

Share This Page