MalformedURLException from null config list

Discussion in 'Plugin Development' started by thehutch, Feb 13, 2012.

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

    thehutch

    For some reason I am getting a null value from my config even though there is no way it should be, I must be missing something sitting infront of my face but I can't see it

    Here is my mainclass:
    Code:java
    1.  
    2. public class iSkin extends JavaPlugin {
    3.  
    4. public static Map<String, String> playerSkin = new HashMap<String, String>();
    5. public static List<String> skinList = new ArrayList<String>();
    6. private FileManager fm;
    7. public static int skinI = 0;
    8. public static String currentSkin;
    9.  
    10. @Override
    11. public void onEnable() {
    12. if(!getServer().getPluginManager().isPluginEnabled("Spout")) {
    13. System.out.println("[iSkin] Spout not enabed, disabling plugin...");
    14. getServer().getPluginManager().disablePlugin(this);
    15. }
    16. else {
    17. setupConfiguration();
    18. loadHashMap();
    19. skinList.clear();
    20. skinList = this.getConfig().getStringList("Allowed-Skins");
    21. fm = SpoutManager.getFileManager();
    22. getServer().getPluginManager().registerEvents(new iSkinListener(this), this);
    23. getCommand("iSkin").setExecutor(new iSkinCommandExecutor(this));
    24. for (String s : skinList) {
    25. if (checkURL(s)) {
    26. fm.addToPreLoginCache(this, s);
    27. } else {
    28. System.out.println("Invalid URL: " + s);
    29. }
    30. }
    31. fm.addToPreLoginCache(this, "[url]http://www.minecraft.net/images/char.png[/url]");
    32. new SetPlayerScreen(this);
    33. new SetSelfScreen(this);
    34. }
    35. }
    36.  
    37. @Override
    38. public void onDisable() {
    39. iSkinLoader.save(playerSkin, new File(this.getDataFolder(), "PlayerSkins.txt"));
    40. }
    41.  
    42. private void setupConfiguration() {
    43. File file = new File(this.getDataFolder(), "config.yml");
    44. if (!file.exists()) {
    45. skinList.add("[url]http://s3.amazonaws.com/MinecraftSkins/Notch.png[/url]");
    46. skinList.add("[url]http://s3.amazonaws.com/MinecraftSkins/thehutch.png[/url]");
    47. this.getConfig().options().header("[url]http://s3.amazonaws.com/MinecraftSkins/<minecraft[/url] name here>.png \n"
    48. + "use this template URL to obtain skins from existing minecraft players \n"
    49. + "otherwise use another URL with valid skins");
    50. this.getConfig().addDefault("Default-Skin", "[url]http://s3.amazonaws.com/MinecraftSkins/Notch.png[/url]");
    51. this.getConfig().addDefault("Allowed-Skins", skinList);
    52. this.getConfig().addDefault("Skins.testplayer", new ArrayList<String>());
    53. this.getConfig().options().copyDefaults(true);
    54. this.saveConfig();
    55. this.reloadConfig();
    56. }
    57. }
    58.  
    59. private void loadHashMap() {
    60. File file = new File(this.getDataFolder(), "PlayerSkins.txt");
    61. if (!file.exists()) {
    62. try {
    63. file.createNewFile();
    64. } catch (IOException ex) {
    65. ex.printStackTrace();
    66. }
    67. }
    68. else {
    69. iSkinLoader.load(file);
    70. }
    71. }
    72.  
    73. public static boolean checkURL(String s) {
    74. try {
    75. URL a = new URL(s);
    76. HttpURLConnection b = (HttpURLConnection) a.openConnection();
    77. if (b.getResponseCode() == HttpURLConnection.HTTP_OK) {
    78. return true;
    79. }
    80. } catch (Exception e) {
    81. System.out.println("Error: URL = " + s);
    82. }
    83. return false;
    84. }
    85. }
    86.  
     
  2. Offline

    hatstand

    ...why are you wrapping your URL's in tags?
     
  3. Offline

    thehutch

    Oh sorry that is just bukkit seeing a url that's not me :D
     
Thread Status:
Not open for further replies.

Share This Page