I dont see why my code is failing

Discussion in 'Plugin Development' started by ferrybig, Oct 23, 2012.

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

    ferrybig

    I have my code that runs into an schedular, but the coede is halveway the task stopped or something
    code (open)
    Code:java
    1.  
    2. /*
    3.  * To change this template, choose Tools | Templates
    4.  * and open the template in the editor.
    5.  */
    6. package addesk.mc.console.server;
    7.  
    8. import addesk.mc.console.Statics;
    9. import addesk.mc.console.utils.PluginInformationPacket;
    10. import addesk.mc.console.utils.StreamWriter;
    11. import java.util.concurrent.Callable;
    12. import org.bukkit.Bukkit;
    13. import org.bukkit.plugin.Plugin;
    14. import org.bukkit.plugin.PluginDescriptionFile;
    15. import org.bukkit.plugin.PluginManager;
    16.  
    17. /**
    18.  *
    19.  * @author Fernando
    20.  */
    21. class PluginInformationTask implements Callable<Object>
    22. {
    23. private final String name;
    24. private final StreamWriter outputStream;
    25. private final int requestId;
    26.  
    27. public PluginInformationTask(String name, StreamWriter toCon, int requestId)
    28. {
    29. this.name = name;
    30. this.outputStream = toCon;
    31. this.requestId = requestId;
    32. }
    33.  
    34. @Override
    35. public Object call() throws Exception
    36. {
    37. final String pluginName, authors[], description, commands[], website;
    38. PluginManager pm = Bukkit.getPluginManager();
    39. String temp = null;
    40. System.out.println("Getting information about: "+name);
    41. final Plugin plugin = pm.getPlugin(this.name);
    42.  
    43. final boolean recordFound = true;
    44. if (plugin == null)
    45. {
    46.  
    47. pluginName = "Plugin not found!";
    48. authors = new String[]
    49. {
    50. "None"
    51. };
    52. description = "We weren't able to find the plugin you specifid!";
    53. commands = Statics.EMPTY_STRING_ARRAY;
    54. website = "";
    55. }
    56. else
    57. {
    58. System.out.println("1");
    59. PluginDescriptionFile pluginDescription = plugin.getDescription();
    60. pluginName = this.name;
    61. authors = pluginDescription.getAuthors().toArray(Statics.EMPTY_STRING_ARRAY);
    62. temp = pluginDescription.getDescription();
    63. description = temp == null ? "" : temp;
    64. System.out.println("2");
    65. temp = pluginDescription.getWebsite();
    66. System.out.println("3");
    67. website = temp == null ? "" : temp;
    68. System.out.println("4");
    69. commands = pluginDescription.getCommands().keySet().toArray(Statics.EMPTY_STRING_ARRAY);
    70. System.out.println("5");
    71. }
    72. outputStream.sendData(new PluginInformationPacket(this.requestId, pluginName, description, authors, website, commands, recordFound), 1);
    73. System.out.println("Got al we needed!");
    74. return null;
    75. }
    76. }
    77.  

    the problem is that sometimes, it works as excepted, but when submitting other plugin names, it outputs:
    Code:
    00:54:02 [INFO] Getting information about: CommandBook
    00:54:02 [INFO] 1
    00:54:02 [INFO] 2
    
    but when trying another plugin
    Code:
    00:54:35 [INFO] Getting information about: MultiWorld
    00:54:35 [INFO] 1
    00:54:35 [INFO] 2
    00:54:35 [INFO] 3
    00:54:35 [INFO] Got al we needed!
    I dont see why its doing that

    its not lagg, because I ran the second 1 after the first, and they are both run on the main server thread
    Code:java
    1.  
    2. bukkitSchedular.callSyncMethod(AddeskMcConsole.pluginInstance, new PluginInformationTask(info.getName(),toCon,info.getRequestId()));
    3.  

    for the guys saying I am doing weird stuff, I am making my own remote admin plugin, but this problem is driving me worse this evening, I am unable to find it out!
     
Thread Status:
Not open for further replies.

Share This Page