Solved Getting plugin version returns me IllegalStateException

Discussion in 'Plugin Development' started by _TheTechGuy_, Sep 1, 2021.

  1. Offline


    So I was developing a plugin using SpigotAPI, and I wanted to include a command to view the version of the plugin. However, while doing so, the command is throwing a IllegalStateException: Initital initialization

    2. public class GetVersion implements CommandExecutor {
    3. @Override
    4. public boolean onCommand(CommandSender player, Command command, String s, String[] args) {
    5. PluginDescriptionFile descriptionFile = new Main().getDescription();
    6. if (command.getName().equalsIgnoreCase("btversion")){
    7. player.sendMessage(ChatColor.YELLOW + "You are running [Plugin name here] " + ChatColor.GREEN + descriptionFile.getVersion());
    8. return true;
    9. }else{
    10. return false;
    11. }
    12. }
    13. }

    What is wrong with the code?
    Last edited: Sep 1, 2021
  2. Offline

    timtower Administrator Administrator Moderator

    @_TheTechGuy_ Can't do new Main()
    Need to get the original instance.
    Use a constructor to pass it along.
  3. Offline


    Thanks a lot! It helped!

Share This Page