Solved I need help on developing a minecraft plugin

Discussion in 'Plugin Development' started by Calamandrey, May 18, 2020.

  1. Offline

    Calamandrey

    I'm developing a ranks plugin, when I run a specified command this is the output:

    [​IMG]

    This is the code of this command:


    Code:
    
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    
    private static Economy econ;
    
    
    if(cmd.getName().equalsIgnoreCase("rankup")) {
                  
                    UUID SenderID = ((Player) sender).getPlayer().getUniqueId();
                    String Rank = Main.getPlayersData().getString("Players."+SenderID);
                    boolean RankupwithoutspecifyTrack = Boolean.parseBoolean(Main.getConf().getString("Settings.RankupwithoutspecifyTrack"));
                    String PlayerName = sender.getName();
                    double balance;
                    if(args.length == 0) {
                  
                        if (RankupwithoutspecifyTrack = true) {
                          
                            String DefaultTrack = Main.getConf().getString("Settings.DefaultTrack");
                            int posintrack = Main.getConf().getInt("Rankslist."+Rank+".positionintrack"+DefaultTrack);
                            int rankuprank = posintrack + 1;
                            String NewRank = Main.getTracksConf().getString("Tracks."+DefaultTrack+"."+rankuprank);
                            pdata.set("Players."+SenderID, NewRank);
                            String RankName = NewRank;
                            sender.sendMessage(""+(econ.getBalance(PlayerName)));
                            double Cost = Main.getConf().getDouble("Rankslist."+RankName+".cost");
                          
                                if((econ.getBalance(PlayerName) - Cost)<= 0) {
                                  
                                    try {
                                        pdata.save(PlayerData);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                  
                                    econ.withdrawPlayer(PlayerName, Cost);
                                    sender.sendMessage("§aYou ranked up to "+NewRank+"!");
                                }else {
                                    sender.sendMessage("§cYou don't have enough money!");
                                  
                                }
                        }else {
                            sender.sendMessage("§cSorry you have to specify track!");
                          
                        }
    For Eclipse there isn't any syntax error.
    I sent you only the part of command, without others codes.
     
  2. Offline

    KarimAKL

  3. Offline

    Calamandrey

    Oh I forgot to give line's numbers.
    Line 356 is:
    sender.sendMessage(""+(econ.getBalance(PlayerName)));
     
  4. Offline

    timtower Moderator Moderator

  5. Offline

    Calamandrey

    I understood it, but how can I solve it?
     
  6. Offline

    timtower Moderator Moderator

    Do you have a setupEcon function somewhere? Or a place where you set a value to econ?
     
  7. Offline

    Calamandrey

    Nope, that's the first plugin that I code, so I'm not too expert about java coding...
    At the head of the class I wrote this:
    private static Economy econ;
    Isn't it enough?
     
  8. Offline

    timtower Moderator Moderator

Share This Page