Need help with config !

Discussion in 'Plugin Development' started by Charona, May 6, 2014.

Thread Status:
Not open for further replies.
  1. Hi everybody, my problem is when i try to click on the iron sword nothing happen and in the console i have a message:

    Could not pass event InventoryClickEvent ....
    Caused by java.lang.IllegalArgumentExeption: File cannot be null...


    The code:

    Code:
    @EventHandler
        public void onInterractGui(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            if (!main.choix.contains(player.getName()))
                return;
            switch (event.getCurrentItem().getType()) {
            case IRON_SWORD:
                chevalier(player);
                player.sendMessage("Ca marche a peu pres");
                break;
            case BLAZE_ROD:
                magef(player);
                break;
            case BOW:
                archer(player);
                break;
            case NETHER_STAR:
                ninja(player);
                break;
            case ICE:
                mageg(player);
                break;
            default:
                break;
            }
        }
     
       
     
        public void chevalier(Player player) {
     
            if (getConfig().getString("chevalier." + player.getName()).equals(
                    ".active")) {
     
                player.sendMessage(ChatColor.GOLD + "Votre nouvelle classe est "
                        + ChatColor.DARK_BLUE + "Chevalier");
                main.enlever(player);
                main.chevalier.add(player.getName());
     
                player.closeInventory();
                main.choix.remove(player.getName());
           
            }else {
                player.sendMessage("Ca marche refais");
                getConfig().set("chevalier." + player.getName(), ".active");
            }
        }
    Please help, thanks and sorry for my bad english ;)
     
  2. Offline

    KillerOfPie

    first off please use the Java syntax why you imput code that way it looks like this:
    Code:java
    1. @EventHandler
    2. public void onInterractGui(InventoryClickEvent event) {
    3. Player player = (Player) event.getWhoClicked();
    4. if (!main.choix.contains(player.getName()))
    5. return;
    6. switch (event.getCurrentItem().getType()) {
    7. case IRON_SWORD:
    8. chevalier(player);
    9. player.sendMessage("Ca marche a peu pres");
    10. break;
    11. case BLAZE_ROD:
    12. magef(player);
    13. break;
    14. case BOW:
    15. archer(player);
    16. break;
    17. case NETHER_STAR:
    18. ninja(player);
    19. break;
    20. case ICE:
    21. mageg(player);
    22. break;
    23. default:
    24. break;
    25. }
    26. }
    27.  
    28.  
    29.  
    30. public void chevalier(Player player) {
    31.  
    32. if (getConfig().getString("chevalier." + player.getName()).equals(
    33. ".active")) {
    34.  
    35. player.sendMessage(ChatColor.GOLD + "Votre nouvelle classe est "
    36. + ChatColor.DARK_BLUE + "Chevalier");
    37. main.enlever(player);
    38. main.chevalier.add(player.getName());
    39.  
    40. player.closeInventory();
    41. main.choix.remove(player.getName());
    42.  
    43. }else {
    44. player.sendMessage("Ca marche refais");
    45. getConfig().set("chevalier." + player.getName(), ".active");
    46. }
    47. }


    and secondly please post the full error so that we can see where its going wrong.
     
  3. Offline

    minoneer

    Please show the whole stack trace...
     
  4. Ok sorry i forgot the java syntax,

    Code:
    22:39:15 [GRAVE] Could not pass event InventoryClickEvent to ValyriaCraft v1.0.0
     
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java
    :1383)
            at net.minecraft.server.v1_6_R3.Packet102WindowClick.handle(SourceFile:3
    1)
            at net.minecraft.server.v1_6_R3.NetworkManager.b(NetworkManager.java:296
    )
            at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java
    :116)
            at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
            at net.minecraft.server.v1_6_R3.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:5
    92)
            at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:2
    27)
            at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:4
    88)
            at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java
    :421)
            at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:5
    83)
    Caused by: java.lang.IllegalArgumentException: File cannot be null
            at org.apache.commons.lang.Validate.notNull(Validate.java:203)
            at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(Yam
    lConfiguration.java:170)
            at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117)
            at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111)
            at fr.charona.main.playerListener.chevalier(playerListener.java:50)
            at fr.charona.main.playerListener.onInterractGui(playerListener.java:22)
     
            at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 14 more
    >
     
  5. Offline

    KillerOfPie

    Whats on lines 50 & 22 of your playerListener?
     
  6. Line 22 : chevalier(player);
    and line 50 : if (getConfig().getString("chevalier." + player.getName()).equals(".active")) {
     
  7. Offline

    KillerOfPie

    if this isn't your main plugin file(the one that extends JavaPlugin) then you need to add:
    Code:java
    1. Plugin plugin = Bukkit.getServer().getPlugin("plugin name");

    and then instead of
    Code:java
    1. getConfig().

    do
    Code:java
    1. plugin.getConfig().
     
Thread Status:
Not open for further replies.

Share This Page