Solved PvP Stats Plugin

Discussion in 'Plugin Development' started by dlndcrdso, Oct 27, 2018.

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

    dlndcrdso

    Hey everyone,
    I know this isn't how I'm supposed to format a post in this section but I'm having relatively big issues with my first plugin, I will try to describe it here if anyone can help or if you think you can help me further. Basically I'm making a /stats plugin to record a player's username, kills, deaths and their balance. I believe I did everything correctly, I use eclipse because I'm on a Mac (rip) but I tried my best to look over the code to make sure I didn't miss anything out. When I run my server it gives this error in console:
    "org.bukkit.plugin.InvalidPluginException: main class `me.Champanye.Stats.Main' does not extend JavaPlugin", however if you look in my code (I can link the plugin below or you can contact me for the code) I did put "public class Main extends JavaPlugin" as well as import everything needed. I can show a screenshot of my Referenced Libraries, spigot.jar (1.8) and Vault are both there, everything vault related works, but my code seems to not acknowledge spigot.jar???? Please if you could help that would be great. Here is a photo of my referenced libraries as well as a pastebin of my Main.java, I can add anything else if you ask. Thanks in advance if anyone manages to help!

    Build Path: https://gyazo.com/363c847526ef2f13bfc4d5ead2b51e3b
    Main.java: https://pastebin.com/tWYjcBBL
    Plugin: https://www.dropbox.com/s/lg40xyyssuy0414/Stats.jar?dl=0
     
  2. @dlndcrdso
    Your code seemed fine, so I looked in your jar file. It looks like something went wrong with exporting.
    Code:
    Êþº¾   6 - me/Champanye/Stats/Main java/lang/Object instance Lorg/bukkit/plugin/Plugin; chat Lnet/milkbowl/vault/chat/Chat; econ $Lnet/milkbowl/vault/economy/Economy; <init> ()V Code java/lang/Error ‡Unresolved compilation problems:
        The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files
        The hierarchy of the type Main is inconsistent
        Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
        Type mismatch: cannot convert from Main to Plugin
        The method getCommand(String) is undefined for the type Main
        The method getCommand(String) is undefined for the type Main
        The method saveDefaultConfig() is undefined for the type Main
        The method saveConfig() is undefined for the type Main
        The method isPluginEnabled(String) from the type PluginManager refers to the missing type String
        The method hook() is undefined for the type Holder
        The method getServer() is undefined for the type Main
        The method getServer() is undefined for the type Main
        The method getServer() is undefined for the type Main
    
    (Ljava/lang/String;)V LineNumberTable LocalVariableTable this Lme/Champanye/Stats/Main; onEnable ÞUnresolved compilation problems:
        Type mismatch: cannot convert from Main to Plugin
        The method getCommand(String) is undefined for the type Main
        The method getCommand(String) is undefined for the type Main
        The method saveDefaultConfig() is undefined for the type Main
        The method saveConfig() is undefined for the type Main
        The method isPluginEnabled(String) from the type PluginManager refers to the missing type String
        The method hook() is undefined for the type Holder
         setupChat ()Z XUnresolved compilation problem:
        The method getServer() is undefined for the type Main
    setupEconomy " Unresolved compilation problems:
        The method getServer() is undefined for the type Main
        The method getServer() is undefined for the type Main
    getEconomy &()Lnet/milkbowl/vault/economy/Economy; & !Unresolved compilation problem:
    getChat  ()Lnet/milkbowl/vault/chat/Chat;
    SourceFile     Main.java InconsistentHierarchy MissingTypes !                              
      
       4   
    » Y· ¿              
      
       4   
    » Y· ¿              
      
       4   
    » Y· ¿         *      
         
       4   
    » Y!· ¿         1      
            # $
       *     
    » Y%· ¿         <            ' (
       *     
    » Y%· ¿         A       )   * +     ,   
    Your jar seems to contain very interesting compile errors. Like
    Interesting (open)

    The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files
    The hierarchy of the type Main is inconsistent
    Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
    Type mismatch: cannot convert from Main to Plugin


    Could you tell me if eclipse shows any errors and how you exported it exactly?
     
  3. Offline

    dlndcrdso

    Hey,
    Thanks for the quick reply! I exported it from Eclipse by making sure everything was saved then I right clicked the project in the sidebar and clicked "Export..." then I clicked the dropdown menu named "Java" and clicked "JAR File" and then "Next..." then made sure the .classpath, .project, config.yml and plugin.yml were all checked on the right and I exported it. It told me it exported with Compile Errors in StatsAdminCommand.java, when I checked what was wrong it looped back to my original problem, it didn't acknowledge spigot.jar was there even though I made sure to import everything needed at the top? "ChatColor", "Player", "CommandExecutor", etc... were all underlined in red even though everything was imported, I imported it all again but nothing changed? Please help.
     
  4. Offline

    caderapee

    @dlndcrdso
    If everything is underlined in red, that means your plugin dun find the path of the bukkit.jar. Did you move it ?
     
  5. Offline

    dlndcrdso

    I haven't moved it at all from what I remember
     
  6. @dlndcrdso

    Right click on your java project
    Click on 'Properties'
    Click on 'Java Build Path'
    Click on 'Libraries'

    Now tell me what you see
     
    Last edited: Oct 28, 2018
  7. Offline

    YanKnKt

    Can you send us your StatsCommand.class code?
     
  8. @YanKnKt

    You can see his .class files if you download the plug-in and open it with 7-zip or similar program.
     
  9. Offline

    dlndcrdso

  10. @dlndcrdso
    It looks like you don't have a JRE System Library.

    Try this:

    Go to your build path again (Where you made that screenshot for me)
    Click on 'Add Library...'
    Select 'JRE System Library'
    Click on 'Next >'
    Click on 'Finish'
    Click on 'Apply and Close'
     
  11. Offline

    dlndcrdso

    Ok that worked thanks so much!

    Edit: Everything in the code seemed fine, I exported it but it said it exported with compile errors and I got this error in console (sorry for being such a noob, please help):
    https://pastebin.com/DuRxb2T2
     
    Last edited: Oct 28, 2018
  12. @dlndcrdso

    The rcp variable in your setupChat() has a value of null.
    This is a programming error, so your build errors have been resolved.
     
  13. Offline

    dlndcrdso

    Ok thanks so much for all your help and sorry if I wasted too much of your time I really appreciate all of your help :)
     
Thread Status:
Not open for further replies.

Share This Page