one last error?

Discussion in 'Plugin Development' started by fury, Oct 19, 2011.

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

    fury

    I developed my plugin, fixed all error, then it compiled. so, I installed it for testing, and it broke the server. But I can't figure out how to get the error on here. I can't copy and paste it from the command line, and I can't find a file that it writes to. If somebody could tell me how to do that, then I could get it on here, and it could be fixed. Or I could just send you the source file, and you will probably get the same error. It won't finish loading the server basically. I need this up for tomorrow.
     
  2. Delete your server.log so it's empty. Now run your server and make the error appear in the console. Then the error should be in your server.log
     
  3. Offline

    AinSophAur

    Are you using Eclipse to code the plugins? Just because there isn't a logic or syntax error doesn't mean that something in the code can't go wrong. You should post your code on here so people can look at it.
     
  4. Offline

    fury

    Yes, I'm using Eclipse. Here's my code:


    import java.util.logging.Logger;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;


    public class plugin extends JavaPlugin {
    protected static FileConfiguration CONFIG;
    Logger log = Logger.getLogger("Minecraft");

    public void onEnable() {
    CONFIG = getConfig();
    CONFIG.set("your boolean property", true);
    CONFIG.set("your string property, "yes"");
    CONFIG.set("your int property", 22);
    boolean bProp = CONFIG.getBoolean("your boolean property", false);
    String sProp = CONFIG.getString("your string property", "no");
    int iProp = CONFIG.getInt("your int property", 0);
    log.info("Your plugin has been enabled.");
    }
    public void onDisable() {
    log.info("Your plugin has been disabled.");
    }
    }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(cmd.getName().equalsIgnoreCase("ignite")){
    Player s = (Player)sender;
    Player target = s.getWorld().getPlayer(args[0]);
    target.setFireTicks(100);
    return true;
    }
    return false;
    }

    and here's my error:

    2011-10-19 20:06:33 [INFO] Starting minecraft server version Beta 1.8.1
    2011-10-19 20:06:33 [INFO] Loading properties
    2011-10-19 20:06:33 [INFO] Starting Minecraft server on *:25565
    2011-10-19 20:06:33 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-1126-g35eac7a-b1317jnks (MC: 1.8.1)
    2011-10-19 20:06:33 [SEVERE] java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
    2011-10-19 20:06:33 [SEVERE] at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:36)
    2011-10-19 20:06:33 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:71)
    2011-10-19 20:06:33 [SEVERE] at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
    2011-10-19 20:06:33 [SEVERE] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
    2011-10-19 20:06:33 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:136)
    2011-10-19 20:06:33 [SEVERE] at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:112)
    2011-10-19 20:06:33 [SEVERE] at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
    2011-10-19 20:06:33 [SEVERE] at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:136)
    2011-10-19 20:06:33 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:348)
    2011-10-19 20:06:33 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
    2011-10-19 20:06:33 [SEVERE] Unexpected exception
    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
    at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:36)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:71)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:136)
    at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:112)
    at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:136)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:348)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)

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

    AinSophAur

    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map

    probably means:

    Player s = (Player)sender;

    is most likely wrong. CommandSender is not same as Player.
     
  6. Offline

    Windwaker

    Please ... I refuse to read code unless you put it between

    Code:
    [syntax=java][/syntax]
    KTHNX
     
  7. Offline

    fury

    Code:java
    1. [SIZE=15px][FONT=Georgia]import java.util.logging.Logger;[/FONT][/SIZE]
    Code:java
    1.  
    2. import org.bukkit.command.Command;
    3. import org.bukkit.command.CommandSender;
    4. import org.bukkit.configuration.file.FileConfiguration;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8.  
    9. public class plugin extends JavaPlugin {
    10. protected static FileConfiguration CONFIG;
    11. Logger log = Logger.getLogger("Minecraft");
    12.  
    13. public void onEnable() {
    14. CONFIG = getConfig();
    15. CONFIG.set("your boolean property", true);
    16. CONFIG.set("your string property, "yes"");
    17. CONFIG.set("your int property", 22);
    18. boolean bProp = CONFIG.getBoolean("your boolean property", false);
    19. String sProp = CONFIG.getString("your string property", "no");
    20. int iProp = CONFIG.getInt("your int property", 0);
    21. log.info("Your plugin has been enabled.");
    22. }
    23. public void onDisable() {
    24. log.info("Your plugin has been disabled.");
    25. }
    26. }
    27.  
    28. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    29. if(cmd.getName().equalsIgnoreCase("ignite")){
    30. Player s = (Player)sender;
    31. Player target = s.getWorld().getPlayer(args[0]);
    32. target.setFireTicks(100);
    33. return true;
    34. }
    35. return false;
    36.  
    37. [FONT=Consolas][SIZE=15px][FONT=Georgia]}[/FONT][/SIZE][/FONT]

    there, happy?

    so, what your saying, is I have something wrong with the Player s = (Player)sender; line?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  8. Offline

    Sagacious_Zed Bukkit Docs

    actually, post your plugin.yml too.
     
  9. Offline

    AinSophAur

    Yes there is something wrong with your casting.
     
  10. Offline

    nisovin

    A Player is a CommandSender, but a CommandSender is not always a player. You should check to make sure it's a Player before casting by doing if(sender instanceof Player). However, that is not your problem here. Your problem is in your plugin.yml file.
     
  11. Offline

    fury

    Code:java
    1.  
    2. import java.util.logging.Logger;
    3.  
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.configuration.file.FileConfiguration;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10.  
    11. public class plugin extends JavaPlugin {
    12. protected static FileConfiguration CONFIG;
    13.  
    14. Logger log = Logger.getLogger("Minecraft");
    15.  
    16. public void onEnable() {
    17. CONFIG = getConfig();
    18. CONFIG.set("your boolean property", true);
    19. CONFIG.set("your string property, "yes"");
    20. CONFIG.set("your int property", 22);
    21.  
    22. boolean bProp = CONFIG.getBoolean("your boolean property", false);
    23. String sProp = CONFIG.getString("your string property", "no");
    24. int iProp = CONFIG.getInt("your int property", 0);
    25.  
    26. log.info("Your plugin has been enabled.");
    27. }
    28.  
    29. public void onDisable() {
    30.  
    31. log.info("Your plugin has been disabled.");
    32. }
    33. }
    34.  
    35. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    36. if (cmd.getName().equalsIgnoreCase("portal") {
    37. if (sender instanceOf Player) {
    38. Player player = (Player) sender;
    39. // ignite player here
    40. } else {
    41. sender.sendMessage("You dun goofed");
    42. }
    43. return true;
    44. }
    45. return false;
    46. }
    47.  


    This is my plugin.yml file. Anything wrong?
    *EDIT*:
    Ah ha! I found something! In the lines:
    Code:java
    1.  
    2. commandLabel, String[] args) {
    3. if (cmd.getName().equalsIgnoreCase("portal") {
    4. if (sender instanceOf Player) {
    5.  

    there are three {'s!
    is this my error?
    *EDIT*:
    wait, no, I found why it's right. sorry.
     
  12. That is correct, except instanceOf should be instanceof
    Your error is here:
    CONFIG.set("your string property, "yes"");

    Should be

    CONFIG.set("your string property
    ", "yes");
     
  13. Offline

    fury

    updated to this:

    Code:java
    1.  
    2.  
    3.  
    4. import java.util.logging.Logger;
    5.  
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.configuration.file.FileConfiguration;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12.  
    13. public class plugin extends JavaPlugin {
    14. protected static FileConfiguration CONFIG;
    15.  
    16. Logger log = Logger.getLogger("Minecraft");
    17.  
    18. public void onEnable() {
    19. CONFIG = getConfig();
    20. CONFIG.set("your boolean property", true);
    21. CONFIG.set("your string property","yes");
    22. CONFIG.set("your int property", 22);
    23.  
    24. boolean bProp = CONFIG.getBoolean("your boolean property", false);
    25. String sProp = CONFIG.getString("your string property", "no");
    26. int iProp = CONFIG.getInt("your int property", 0);
    27.  
    28. log.info("Your plugin has been enabled.");
    29. }
    30.  
    31. public void onDisable() {
    32.  
    33. log.info("Your plugin has been disabled.");
    34. }
    35. }
    36.  
    37. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    38. if (cmd.getName().equalsIgnoreCase("portal") {
    39. if (sender instanceof Player) {
    40. Player player = (Player) sender;
    41. // ignite player here
    42. } else {
    43. sender.sendMessage("You dun goofed");
    44. }
    45. return true;
    46. }
    47. return false;
    48. }
    49. [syntax]
    50. and it still doesn't work. I fixed all of the errors Eclipse reported.
    51.  
    52. now wait:
    53. /*
    54. this would be
    55. a note,
    56. right?
    57. */
    58.  
    59. I have verified that the error is here:
    60. [syntax=java]
    61. import java.util.logging.Logger;
    62.  
    63. import org.bukkit.command.Command;
    64. import org.bukkit.command.CommandSender;
    65. import org.bukkit.configuration.file.FileConfiguration;
    66. import org.bukkit.entity.Player;
    67. import org.bukkit.plugin.java.JavaPlugin;
    68.  
    69.  
    70. public class plugin extends JavaPlugin {
    71. protected static FileConfiguration CONFIG;
    72.  
    73. Logger log = Logger.getLogger("Minecraft");
    74.  
    75. public void onEnable() {
    76. CONFIG = getConfig();
    77. CONFIG.set("your boolean property", true);
    78. CONFIG.set("your string property","yes");
    79. CONFIG.set("your int property", 22);
    80.  
    81. boolean bProp = CONFIG.getBoolean("your boolean property", false);
    82. String sProp = CONFIG.getString("your string property", "no");
    83. int iProp = CONFIG.getInt("your int property", 0);
    84.  
    85. log.info("Your plugin has been enabled.");
    86. }
    87.  
    88. public void onDisable() {
    89.  
    90. log.info("Your plugin has been disabled.");
    91. }
    92. }
    93. [syntax]
    94. why is this broken?
    95.  
    96. I reduced my plugin to simply saying in the command line that it started, and my server still crashes because of it. here's my code:
    97. [syntax=java]
    98. package me.fury.plugin
    99.  
    100. import java.util.logging.Logger;
    101.  
    102. import org.bukkit.command.Command;
    103. import org.bukkit.command.CommandSender;
    104. import org.bukkit.configuration.file.FileConfiguration;
    105. import org.bukkit.entity.Player;
    106. import org.bukkit.plugin.java.JavaPlugin;
    107.  
    108.  
    109. public class plugin extends JavaPlugin {
    110. protected static FileConfiguration CONFIG;
    111. Logger log = Logger.getLogger("Minecraft");
    112. }
    113. public void onEnable() {
    114. log.info("Your plugin has been enabled.");
    115. }
    116. public void onDisable() {
    117. log.info("Your plugin has been disabled.");
    118. }
    119. }
    120. [syntax]
    121.  
    122. I just can't simply figure out what's wrong with it. can somebody please help me?
    123.  
    124. EDIT by Moderator: merged posts, please use the edit button instead of double posting.[/syntax]
     
    Last edited by a moderator: May 20, 2016
Thread Status:
Not open for further replies.

Share This Page