Config true false

Discussion in 'Plugin Development' started by bronzzze, Mar 5, 2015.

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

    bronzzze

    I am not sure how to do it currectly so I am gonna ask you(watch line 29 and 345)
    and line 51 is
    if(i.getConfig().getBoolean("Enchantments") == true){
    it might be this i(instance) i am not sure if i can use it with getconfig()


    Error
    Class:
    http://pastebin.com/iP3n53Td
     
    Last edited: Mar 5, 2015
  2. Offline

    CraftCreeper6

    @bronzzze
    "at me.bronzzze.wardrobe.MainEvent.onClick(MainEvent.java:53) ~[?:?]"
     
  3. Offline

    bronzzze

    this is line 53 i.openInventory(p);
     
  4. Offline

    CraftCreeper6

    @bronzzze
    i is probably null, I suggest using your main class' instance. (Without static)
     
  5. Offline

    bronzzze

    Code:
        public static Main getInstance() {
            return instance;
        }
    i Cant use this without static
     
  6. Offline

    stormneo7

    Could you please post your full code? I don't see anything wrong with .getInstance()
    Perhaps, you can elaborate more what 'i' is.
    Perhaps you could also elaborate more on what the .openInventory(Player p) function does.
     
  7. Offline

    bronzzze

    ok there are 8 or something like that classes I will post Main and other 2 where is error
     
  8. Offline

    CraftCreeper6

  9. Offline

    bronzzze

  10. Offline

    teej107

  11. Offline

    CraftCreeper6

    @bronzzze
    Your ArmourGUI class is impossible to read...
     
  12. Offline

    stormneo7

    Code:
    at me.bronzzze.wardrobe.ArmourGUI.openInventory(ArmourGUI.java:51) ~[?:?]
    at me.bronzzze.wardrobe.MainEvent.onClick(MainEvent.java:53) ~[?:?]
    Code:
    // ArmourGUI Line 50 & 51:
    ItemStack item3 = new ItemStack(Material.LEATHER_HELMET, 1);   item3.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    
    // MainEvent Line 53:
    i.openInventory(p);
    There's nothing wrong with that. Are you sure you didn't any edits since the code you posted above?
     
  13. Offline

    bronzzze

    yes i know its in 51 row and ists null pointer but idk how to fix it

    @CraftCreeper6
    yes i know main in this class is from 1-29. and then else statment if boolean in config is false this is line 345(first time doing with true/false config.

    @stormneo7
    ArmourGUI line 51 is
    if(i.getConfig().getBoolean("Enchantments") == true){
    idk pastebin is dirrent
    MainEvent is
    i.openInventory(p) (as you said)
     
    Last edited by a moderator: Mar 5, 2015
  14. Offline

    stormneo7

    You need to understand that there's nothing wrong with those two lines.
    It's like saying that 1+1 != 2
    So what does that even mean... did you edit your or something?
     
  15. Offline

    bronzzze

    it was working all fine but when add this if(i.getConfig().getBoolean("Enchantments") == true){
    and }else{ in armourgui it's not working

    You have any ideas how should i toggle enchantments True/false in config cuz this way is not working

    I cant do like this right?
    Code:
    if(i.getConfig().getBoolean("Enchantments") == true){
            item1.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
            }
    EDIT by Timtower: merged posts, use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 5, 2015
  16. Offline

    1Rogue

    You're setting the "i" variable before your "instance" variable in the main class has any value.
     
  17. Offline

    bronzzze

    amm? explanation please sorry.
     
  18. Offline

    1Rogue

    When you set the value of i, getInstance returns null because you haven't set it yet
     
  19. Offline

    bronzzze

    so you mean like this? Sorry i am dumb

    Code:
        private ArmourGUI() {
        }
    
        private static ArmourGUI instance = new ArmourGUI();
    
        public static ArmourGUI getInstance() {
            return null;
        }
    
        Main i = Main.getInstance();
     
    Last edited: Mar 6, 2015
Thread Status:
Not open for further replies.

Share This Page