Solved getConfig in Another Class and Plugin Desc File?

Discussion in 'Plugin Development' started by LandonTheGeek, Nov 3, 2013.

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

    LandonTheGeek

    Hello, I am very new to creating commands in different classes, and I am getting errors. I have the general idea of with they are, but... I don't know how to fix them.

    So apparently here are my two issues. I add a (Config Reloader) command into a new class, and my "reloadConfig();" method is red. How do I get the config in my other class without overwriting it from my first?

    Second: I am using "PluginDescriptionFile pdfFile = getDescription();" and "getDescription();" is red. I don't seem to see the issue here. I picture is below of the two errors that are more visible for you to see. Thanks!
    [​IMG]
     
  2. Offline

    AlexHH251997

    Try this:
    Code:java
    1. package me.xXThe3B3astXxify.EasyBroadcast;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.command.ConsoleCommandSender;
    8. import org.bukkit.plugin.PluginDescriptionFile;
    9.  
    10. public class Reload implements CommandExecutor
    11. {
    12.  
    13. public static (MainClassName) plugin;
    14.  
    15. public Reload(Main main)
    16. {
    17. plugin = main;
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    21. {
    22. PluginDescriptionFile pdfFile = plugin.getDesciption();
    23. if((sender.hasPermission("easybroadcast.reload")) || ((Sender instanceof ConsoleCommandSender))) {
    24. plugin.reloadConfig();
    25. sender.sendMessage(ChatColor.LIGHT_PURPLE + "The default configuration for, " + pdfFile.getName() + ", v" + pdfFile.getVersion() + ".");
    26. return true;
    27. } else {
    28. sender.sendMessage(ChatColor.LIGHT_PURPLE + "You don't have permission!");
    29. }
    30. }
    31. }
    32. }

    You needed to import the Main class that would normally use for example "getExample()" on its own and add "plugin" infront of it.
     
  3. Offline

    LandonTheGeek

    Update:

    I have also tried to add:

    Code:
        Main plugin;
       
        public Reload(Main instance) {
        plugin = instance;
        }
     
    /* I know I did that wrong, so please correct me*/
    Still no luck for the reloadConfig() part of it.
    Thanks ~Beast

    @AlexHH251997

    Thanks for the response, I will try this.

    AlexHH251997

    Alright Update:

    I am still getting plenty of errors. Uggh! A picture is below. I also included (In the WorkBench) the extra plugin information so you can see the mains, classes, pkgs, everything.

    Thanks!

    [​IMG]

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

    AlexHH251997

    HelpfulBeast

    You want to remove the brackets from "(Main)" that was just for me too show you.
     
  5. Offline

    LandonTheGeek

    AlexHH251997

    OH boy. :p Well am I stupid. Anyways, works perfect! Thanks. By the way, do you know how to get my Plugin Description File from the same class? That appears to be red also. (I probably forgot to add something as usual)

    [​IMG]
     
  6. Offline

    AlexHH251997

    Code:java
    1. PluginDescriptionFile pdfFile = plugin.getDesciption();

    I said that in the code before.
     
  7. Offline

    LandonTheGeek

    AlexHH251997

    Oh, I am sorry. And since I am still learned, after I added everything, in my main class flies in an error. Dangit.
    (Gets the command from the class)

    [​IMG]
     
  8. Offline

    AlexHH251997

    HelpfulBeast

    Try this in your main class
    Code:java
    1. getCommand("ebreload").setExecutor(this);
     
  9. Offline

    LandonTheGeek

    AlexHH251997

    So here is what happened:
    The code works! It is error free :), but the thing is, when I try to /ebreload in the console, it doesn't return. I feel as though the:

    Code:
    getCommand("ebreload").setExecutor(this);
    Needs to get the class? Because of my understanding, there is no where in the Main class where it gets Reload.java. It just gets the command.

    Edit: The command gives back no output at all.
     
  10. Offline

    AlexHH251997

  11. Offline

    viper_monster

    HelpfulBeast likes this.
  12. Offline

    LandonTheGeek

    spoljo666 likes this.
  13. Offline

    AlexHH251997

    HelpfulBeast likes this.
Thread Status:
Not open for further replies.

Share This Page