Solved "CoinAPI" help 1.8

Discussion in 'Plugin Development' started by NeguinDaFarofa, Jan 22, 2017.

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

    NeguinDaFarofa

    I got a method of savings per config and I decided to test but I noticed that the error with me and the person who taught you to use not.

    how it uses:
    Code:
        @EventHandler
        public void onJoin(PlayerJoinEvent e){
            Player p = e.getPlayer();
            if (!Cash.cash.contains(p.getName())){ <--
                Cash.set(p.getName(), 0);
            }
        }
    as I'm using:
    Code:
        @EventHandler
        public void join(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            if(!CoinAPI.contains(p.getName(), 0)) {
                CoinAPI.set(p.getName(), 100); //Add 100 to enter if he doesn't have anything
            }
        }
    CoinAPI
    Code:
    public class CoinAPI {
       
    public static Config coin = new Config("coins.yml");
       
        public static void set(String player, int valor){
            coin.set(player, valor);
            coin.saveConfig();
        }
       
        public static int get(String player){
            return coin.getInt(player);
        }
       
        public static void add(String player, int valor){
            set(player, get(player) + valor);
        }
       
        public static void retirar(String player, int valor){
            set(player, get(player) - valor);
        }
       
        public static boolean contains(String player, int valor){
            if (get(player) < valor){
                return true;
            } else {
                return false;
            }
        }
    When I try to scan using only one value in the event the (p) the contains is with error asking to add a ,int > http://prntscr.com/dz3pd0
     
  2. Offline

    Zombie_Striker

    @NeguinDaFarofa
    You are getting that error because your parameters require an integer. Either provide an integer, or change the requirements so it only requires a string.
     
  3. Offline

    NeguinDaFarofa

    could you help me how to remove it? Because if I take the integer it get() error
    prints: http://prntscr.com/dzgpgu
     
  4. Offline

    Zombie_Striker

    @NeguinDaFarofa
    Then It looks like you want to create a separate method for this. Undo what you did and add this method
    Code:
    public boolean containsPath(String player){
    return coin.contains(player);
    }
    What this does is check if the player is in the config.
     
  5. Offline

    NeguinDaFarofa

    thx
     
Thread Status:
Not open for further replies.

Share This Page