Solved Got a Bug that I Can Not Find

Discussion in 'Plugin Development' started by Gabezter4, Jul 24, 2013.

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

    Gabezter4

    Hey guys I seem to have a bug I can not find. I have tried to find it by stack-tracing, but I somehow messed up the onEnable(). So it won't enable to report the error.

    This is my Main Class.
    Code:java
    1. package com.gmail.gabezter4.faction_warning;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7.  
    8. public class Faction_warning extends JavaPlugin {
    9.  
    10. @Override
    11. public void onEnable() {
    12. // TODO Insert logic to be performed when the plugin is enabled
    13. }
    14.  
    15. @Override
    16. public void onDisable() {
    17. // TODO Insert logic to be performed when the plugin is disabled
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    21. if(cmd.getName().equalsIgnoreCase("fw")){ //If the player typed /fw then do the following...
    22. // Send message
    23.  
    24. if(sender.hasPermission("fw")) {
    25. sender.sendMessage("This is the Main Command. Do /fwhelp for the help page.");
    26. }
    27. return true;
    28. }
    29.  
    30. if (cmd.getName().equalsIgnoreCase("fwhelp")){ //If the player typed /fwhelp then do the following...
    31. // Display the help menu
    32. return true;
    33. }
    34. return false;
    35. }
    36. }


    The next few codes are my command classes.
    Code:java
    1. package com.gmail.gabezter4.faction_warning.commands;
    2.  
    3. import java.io.File;
    4. import java.io.FileWriter;
    5. import java.io.IOException;
    6. import java.io.PrintWriter;
    7.  
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import com.gmail.gabezter4.faction_warning.Faction_warning;
    11.  
    12.  
    13. public class Warn_Command extends Faction_warning {
    14.  
    15.  
    16.  
    17. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    18. if(cmd.getName().equalsIgnoreCase("fwarn")){ //If the player typed /fwwarn then do the following...
    19. if (args.length > 2) {
    20. sender.sendMessage("Too many arguments!");
    21. return false;
    22. }
    23. if (args.length < 2) {
    24. sender.sendMessage("Not enough arguments!!");
    25. return false;
    26. }
    27. return true;
    28. }
    29.  
    30. return false;
    31. }
    32. public void logToFile(String warning)
    33.  
    34. {
    35.  
    36. try
    37. {
    38.  
    39. File dataFolder = getDataFolder();
    40. if(!dataFolder.exists())
    41. {
    42. dataFolder.mkdir();
    43. }
    44.  
    45. File saveTo = new File(getDataFolder(), "warnings.yml");
    46. if(!saveTo.exists());
    47. {
    48. saveTo.createNewFile();
    49. }
    50.  
    51.  
    52. FileWriter fw = new FileWriter(saveTo, true);
    53.  
    54. PrintWriter pw = new PrintWriter(fw);
    55.  
    56. pw.println(warning);
    57.  
    58. pw.flush();
    59.  
    60. pw.close();
    61.  
    62. } catch (IOException e)
    63. {
    64.  
    65. e.printStackTrace();
    66.  
    67. logToFile(warning);
    68. }
    69.  
    70. }
    71. }

    Code:java
    1. package com.gmail.gabezter4.faction_warning.commands;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import com.gmail.gabezter4.faction_warning.Faction_warning;
    6.  
    7.  
    8. public class UnWarn_Command extends Faction_warning {
    9.  
    10.  
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    13. if(cmd.getName().equalsIgnoreCase("fwunwarn")){ //If the player typed /fwunwarn then do the following...
    14. // Erasing a value
    15. this.getConfig().set("warnings.yml", null);
    16.  
    17. if (args.length > 2) {
    18. sender.sendMessage("Too many arguments!");
    19. return false;
    20. }
    21. if (args.length < 1) {
    22. sender.sendMessage("Not enough arguments!!");
    23. return false;
    24. }
    25. return true;
    26. }
    27. return false;
    28. }
    29. }

    Code:java
    1. package com.gmail.gabezter4.faction_warning.commands;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import com.gmail.gabezter4.faction_warning.Faction_warning;
    6.  
    7.  
    8. public class Save_Command extends Faction_warning {
    9.  
    10.  
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    13. if(cmd.getName().equalsIgnoreCase("fwsave")){ //If the player typed /fwsave then do the following...
    14. // save config.yml
    15. this.saveConfig();
    16. return true;
    17.  
    18.  
    19. }
    20. return false;
    21. }
    22. }

    Code:java
    1. package com.gmail.gabezter4.faction_warning.commands;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import com.gmail.gabezter4.faction_warning.Faction_warning;
    6.  
    7.  
    8. public class Reload_Command extends Faction_warning {
    9.  
    10.  
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    13. if(cmd.getName().equalsIgnoreCase("fwreload")){ //If the player typed /fwreload then do the following...
    14. // reload config.yml
    15. this.reloadConfig();
    16. return true;
    17.  
    18.  
    19. }
    20. return false;
    21. }
    22. }

    Code:java
    1. package com.gmail.gabezter4.faction_warning.commands;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import com.gmail.gabezter4.faction_warning.Faction_warning;
    6.  
    7.  
    8. public class Config_Command extends Faction_warning {
    9.  
    10.  
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    13. if (cmd.getName().equalsIgnoreCase("fwconfig")){ //If the player typed /fwconfig limit # then do the following...
    14. // setting a String
    15. String stringValue = "Warninglimit";
    16. this.getConfig().set("config.yml", stringValue);
    17. return true;
    18. }
    19. return false;
    20. }
    21. }

    Code:java
    1. package com.gmail.gabezter4.faction_warning.commands;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import com.gmail.gabezter4.faction_warning.Faction_warning;
    6.  
    7.  
    8. public class Check_Command extends Faction_warning {
    9.  
    10.  
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    13. if(cmd.getName().equalsIgnoreCase("fwcheck")){ //If the player typed /fwcheck then do the following...
    14. if (args.length > 1) {
    15. sender.sendMessage("Too many arguments!");
    16. return false;
    17. }
    18. if (args.length < 1) {
    19. sender.sendMessage("Not enough arguments!!");
    20. return false;
    21. }
    22. return true;
    23. }
    24. return false;
    25. }
    26. }



    Thank You if you solve this bug. I will make you a contributor to the project if you want me too.
    I really want to blow up this bug.
    [tnt][tnt][tnt]
    [tnt][spider][tnt]
    [tnt][tnt][tnt]
     
  2. Offline

    Tirelessly

    Well, technically, each of those classes extends JavaPlugin, which is a no-no. You need to make them implement CommandExecutor instead and use getCommand("x").setExecutor(new CommandExecutorClass())
     
  3. Offline

    Gabezter4

    Like what do you mean?
     
  4. Offline

    fanaticmw2

    No idea why you are extending your main class in each class there isn't any methods in it you need to overide. Just implement CommandExecutor.
     
  5. Offline

    Gabezter4

    Ok thank you I have no idea why I was. I will change it once I can get back to my computer
     
  6. Offline

    Gabezter4

    The plugin still won't enable.
     
  7. Offline

    microgeek

    Pasting the error message and/or the stacktrace helps.
     
  8. Offline

    Gabezter4

    The server I use it on has so many plugins that I can't find the stack-trace.
    Forgot to say, but I have my code up at https://github.com/Gabezter/Faction-Warning I did a little updating at 8 p.m. - 9 p.m. Mid-west USA time, but forgot to push it to github. Is it is not totally up to date. Will do that tomorrow if I remember :).
     
  9. Offline

    Gabezter4

    microgeek
    Here it is. The version is 2.1.5 which is not released yet. I will post my plugin.yml later when I get a chance and also if needed I will post a picture of where my plugin.yml is found( or where it should be). image.jpg
     
  10. Offline

    jayfella

    you dont have a plugin.yml file in your plugin.
     
  11. Offline

    Gabezter4

    When I export the plugin I make sure I include the plugin.yml

    Code:
    name: Faction Warning
    main: com.gmail.gabezter4.faction_warning.Faction_warning
    version: 2.1.5
    commands:
      fw:
        description: This is the main command.
        permission: fw
        permission-message: You are not allowed this command.
        usage: /fw
      fwhelp:
        description: This is the help command.
        permission: fw.help
        permission-message: You don't have access to this command.
        usage: /fwhelp
      fwcheck:
        description: This is the command to check a faction's number of warnings.
        permission: fw.check
        permission-message: You don't have access to this command.
        usage: /fwcheck [faction name]
      fwarn:
        description: This is the command to warn a faction.
        permission: fw.warn
        permission-message: You don't have access to this command.
        usage: /fwarn [faction name] [reason]
      fwunwarn:
        description: This command takes away a warn from a faction.
        permission: fw.unwarn
        permission-message: You don't have access to this command.
        usgae: /fwunwarn [faction name] [reason]
      fwconfig:
        description: This is the command to change the limit of warnings.
        permission: fw.config
        permission-message: You don't have access to this command.
        usage: /fwconfig limit [number]
      fwreload:
        description: This command reloads the config file.
        permission: fw.reload
        permission-message: You don't have access to this command.
        usage: /fwreload
      fwsave:
        description: This command saves the config file.
        permission: fw.save
        permission-message: You don't have access to this command.
        usage: /fwsave
    Permissions:
      fw
        description: Main command
        default: not op
      fw.help:
        description: The help command.
        default: op
      fw.warn:
        description: Warns the faction.
        default: op
      fw.check:
        description: Checks the warns of a faction.
        default: not op
      fw.unwarn:
        description: Unwarns the faction.
        default: op
      fw.config:
        description: Changes the warn limit.
        default: op
      fw.admin:
        description: All commands for Faction Warning.
        default: op
        children:
            fw.help: true
            fw.warn: true
            fw.check: true
            fw.unwarn: true
            fw.config: true
            fw.save: true
            fw.reload: true
      fw.default:
        default: true
        children:
            fw.help: true
            fw.warn: false
            fw.check: true
            fw.unwarn: false
            fw.config: false
            fw.save: false
            fw.reload: false
     
  12. Offline

    jayfella

    It says it right there in plain english at the bottom of the stacktrace. Try cleaning and re-building.

    [​IMG]
     
  13. Offline

    Gabezter4

    Is there a way to put the plugin.yml file in the jar file after export using 7zip or winrar?
     
  14. Offline

    TheLunarFrog

    Yes, just right-click, Open with... and find 7Zip
     
  15. Offline

    Gabezter4

    A specific place? Like in the main jar(the place right out front before u go in to the folders) or a different place?
     
  16. Offline

    curlyfries1999

    Just put it in the root of the jar
     
  17. Offline

    Gabezter4

  18. Offline

    curlyfries1999

    When you open the jar with winrar or 7zip, right there - don't open any folders, just as soon as you open the jar
     
  19. Offline

    Gabezter4

  20. Offline

    Gabezter4

    Me adding it there did not work. I think I might have something wrong.
    Code:
    main: com.yahoo.gabezter4.faction_warning.Faction_warning
    name: Faction Warning
    version: 2.1.5
    Got it solved had to put it in the src folder.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page