Multiple Class's

Discussion in 'Plugin Development' started by KoolzSkillz, Jun 22, 2014.

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

    KoolzSkillz

    i had this one big class that had 16 commands in it then i decided to Make them into one command each class. they are in different packages as well. he is my codng for my main package. No Errors or anything

    Code:
    package me.BasicCommands.kyle;
     
    import java.util.logging.Logger;
     
    import org.bukkit.event.Listener;
    import org.bukkit.permissions.Permission;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Icommands
      extends JavaPlugin
      implements Listener
    {
      public static Icommands plugin;
      public Permission playerPermission1 = new Permission("BSC.kill");
      public final Logger logger = Logger.getLogger("Minecraft");
      public int number = 3;
     
      public void onDisable()
      {
        PluginDescriptionFile p = getDescription();
        this.logger.info(p.getName() + " V" + p.getVersion() +
          " Has been enabled!");
      }
     
      public void onEnable()
      {
        //Check For Config File (leave at top)
          CheckFiles fileCheck = new CheckFiles(this);
          fileCheck.checkConfig("config.yml");
        PluginDescriptionFile p = getDescription();
        this.logger.info(p.getName() + " V" + p.getVersion() +
          " Has been enabled!");
     
        @SuppressWarnings("unused")
        PluginManager pm = getServer().getPluginManager();
      }
    }
     
    

    And here is ONE of my Command Class's They Are all basically the same just changed the perms and stuff
    Code:
    package Commands;
     
    import me.BasicCommands.kyle.Icommands;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    public class DonateCommand extends Icommands implements CommandExecutor  {
          public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
          {
            Player player = (Player)sender;
            if (commandLabel.equalsIgnoreCase("donate")) {
            if (player.hasPermission("Icommand.donate"))
                player.sendMessage(ChatColor.GREEN + "[Donate]: " + ChatColor.GOLD +
                        getConfig().getString("donateinfo"));
            } else {
                player.sendMessage(ChatColor.RED + "You Have No Permission To Do /Donate");
            }
            return false;
    }
    }
    
     
  2. Offline

    ReggieMOL

  3. Offline

    KoolzSkillz

    K thx

    Can someone explain why this isnt working it worked in one file but i moved it to diffrent and it broke
    Code:
    package Commands;
     
    import me.BasicCommands.kyle.Icommands;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    public class DonateCommand implements CommandExecutor  {
          public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
          {
            Player player = (Player)sender;
            if (commandLabel.equalsIgnoreCase("donate")) {
            if (player.hasPermission("Icommand.donate"))
                player.sendMessage(ChatColor.GREEN + "[Donate]: " + ChatColor.GOLD +
                        getConfig().getString("donateinfo"));
            } else {
                player.sendMessage(ChatColor.RED + "You Have No Permission To Do /Donate");
            }
            return false;
    }
        }
    
    The Error is in player.sendMessage(ChatColor.GREEN + "[Donate]: " + ChatColor.GOLD +
    getConfig().getString("donateinfo"));

    getConfig()

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

    Drew1080

    KoolzSkillz
    It is giving you an error due to getConfig not being a method within that class.
    To use it make a constructor, then use your main class instance to use that method in your DonateCommand class.
     
  5. Offline

    Rocoty

    KoolzSkillz Messier, yes. Easier...yes, immediately. But in the long run, no. Not at all.
     
Thread Status:
Not open for further replies.

Share This Page