Getting iConomy Balance?

Discussion in 'Plugin Development' started by WALK2222, May 31, 2013.

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

    WALK2222

    I am trying to extract requested user's iConomy balance. For some reason the code manages to run pretty far, but stops at a certain point.

    Code:
    public static void getmoney(Player player, CommandSender sender, String target){
            System.out.println("test");
            // Location of file to read
            try {
                iconomyfile = new Scanner(new File("plugins/iConomy/accounts.mini"));
                System.out.println("Test 2");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                System.out.println("iConomy most likely not installed!");
            }
     
            while(iconomyfile.hasNext()){
                String foundname = iconomyfile.next();
                String bal = iconomyfile.next();
                @SuppressWarnings("unused")
                String status = iconomyfile.next();
                System.out.println("test 3");
                if(foundname == target){
                    bal = iconomyfile.next();
                    System.out.println("test 4");
                    System.out.println("Iconomy balance: "+bal);
                    sender.sendMessage(ChatColor.AQUA + "iConomy Balance: "+ ChatColor.GREEN + bal);
                }
            }
    (one of my methods..)

    I added some code to print to the console (to check where it ran to) and it managed to get to "test 3" before stopping. This must mean it is getting to found name, but isnt finding the specified name..

    The method is being called in the main class (on Command)

    Code:
            if(cmd.getName().equalsIgnoreCase("playerinfo")){
                Player player = Bukkit.getPlayer(sender.getName());
     
                if(args.length == 0){
                    //If no arguments were entered
                    player.sendMessage("Error: You must enter a username");
                    return false;
                }else if(args.length == 2){
                    if (args[0].equalsIgnoreCase("page-two")) {
                        //Get target player from variable
                        Player target = sender.getServer().getPlayer(args[1]);
     
                        if(target == null){
                            //If the player is offline
                            player.sendMessage("That person is NOT online!");
                        }else{
     
                            //If the player is online
                            //Start calling information methods for PAGE TWO
                            InformationRecieverTwo.getmoney(target, sender, label);
                        }
                    }else{
                        //If too many arguments were entered
                        player.sendMessage("Error:  You have entered incorrect parameters");
                    }
                }
     
            }
    Anyone have any idea on how I can fix this? Or even a more easier / efficient way to extract an iConomy balance?
    Thanks!
     
  2. Offline

    the_merciless

    Ultimate_n00b likes this.
  3. Offline

    WALK2222

    Cool, thanks!
     
Thread Status:
Not open for further replies.

Share This Page