Easy fix... (Config)

Discussion in 'Plugin Development' started by MrGermanrain, Dec 8, 2013.

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

    MrGermanrain

    Im getting an error at the last line "set"... Because its an int...

    Code:java
    1. if (p.getInventory().getItemInHand().equals(Item.GOLD_INGOT)) {
    2. int gold = p.getInventory().getItemInHand().getAmount();
    3. p.getInventory().removeItem(p.getInventory().getItemInHand());
    4. int balance = getConfig().getInt(p.getName());
    5. balance = balance + gold;
    6. this.getConfig().set(p, balance);
    7. }
     
  2. Offline

    AoH_Ruthless

    MrGermanrain
    What is 'p'? I am assuming p is a player but doesn't hurt to be sure.

    Can you show a sample config?
     
  3. Offline

    Compressions

    MrGermanrain You are trying to store a Player instance in the config, but a Player object can't be directly serialized. Try serializing the player's name instead.
     
    MrGermanrain and reider45 like this.
  4. Offline

    MrGermanrain

    It worked, thanks. Looks like I went dull for a sec ;)

    Code:java
    1. this.getConfig().set(p.getName(), balance);
     
Thread Status:
Not open for further replies.

Share This Page