<commit_before>package net.craftstars.general.money;

import net.craftstars.general.General;

import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import com.iConomy.iConomy;
import com.iConomy.system.Account;
import com.iConomy.system.Holdings;

public class iConomy5EconomyHandler implements EconomyBase {
	private boolean wasLoaded;
	private String version;
	
	public iConomy5EconomyHandler() {
		Plugin test = General.plugin.getServer().getPluginManager().getPlugin("iConomy");
		
		if(test != null) {
			if(!wasLoaded) {
				General.plugin.getServer().getPluginManager().enablePlugin(test);
				this.wasLoaded = true;
			}
			this.version = test.getDescription().getVersion();
			String majorRev = version.substring(0, version.indexOf('.'));
			if(Integer.valueOf(majorRev) < 5) {
				wasLoaded = false;
				General.logger.warn("Was looking for iConomy 5 but found iConomy 4 instead. Please either update iConomy, " +
						"or edit your config.yml to specify iConomy4.");
			}
		} else this.version = "0.0";
	}
	
	@Override
	public boolean wasLoaded() {
		return wasLoaded;
	}
	
	@Override
	public String getVersion() {
		return version;
	}
	
	@Override
	public String getName() {
		return "iConomy";
	}
	
	@Override
	public double getBalance(Player who) {
		String player = who.getName();
		if(!iConomy.hasAccount(player)) return 0;
		return iConomy.getAccount(player).getHoldings().balance();
		
	}
	
	@Override
	public String getBalanceForDisplay(Player who) {
		String player = who.getName();
		if(!iConomy.hasAccount(player)) return iConomy.format(0);
		return iConomy.format(player);
	}
	
	@Override
	public String formatCost(double amount) {
		return iConomy.format(amount);
	}
	
	@Override
	public boolean takePayment(Player fromWhom, double amount) {
		String player = fromWhom.getName();
		if(!iConomy.hasAccount(player)) return false;
		Account acc = iConomy.getAccount(player);
		if(acc == null) return false;
		Holdings money = acc.getHoldings();
		if(!money.hasEnough(amount)) return false;<commit_msg>Possible fix for the balance being reported as 0 with iConomy 5<commit_after>package net.craftstars.general.money;

import net.craftstars.general.General;

import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import com.iConomy.iConomy;
import com.iConomy.system.Account;
import com.iConomy.system.Holdings;

public class iConomy5EconomyHandler implements EconomyBase {
	private boolean wasLoaded;
	private String version;
	
	public iConomy5EconomyHandler() {
		Plugin test = General.plugin.getServer().getPluginManager().getPlugin("iConomy");
		
		if(test != null) {
			if(!wasLoaded) {
				General.plugin.getServer().getPluginManager().enablePlugin(test);
				this.wasLoaded = true;
			}
			this.version = test.getDescription().getVersion();
			String majorRev = version.substring(0, version.indexOf('.'));
			if(Integer.valueOf(majorRev) < 5) {
				wasLoaded = false;
				General.logger.warn("Was looking for iConomy 5 but found iConomy 4 instead. Please either update iConomy, " +
						"or edit your config.yml to specify iConomy4.");
			}
		} else this.version = "0.0";
	}
	
	@Override
	public boolean wasLoaded() {
		return wasLoaded;
	}
	
	@Override
	public String getVersion() {
		return version;
	}
	
	@Override
	public String getName() {
		return "iConomy";
	}
	
	@Override
	public double getBalance(Player who) {
		String player = who.getName();
		if(!iConomy.hasAccount(player)) return 0;
		return iConomy.getAccount(player).getHoldings().balance();
		
	}
	
	@Override
	public String getBalanceForDisplay(Player who) {
		String player = who.getName();
		String balance = iConomy.format(player);
		if(balance == null) return "0";
		return balance;
		
	}
	
	@Override
	public String formatCost(double amount) {
		return iConomy.format(amount);
	}
	
	@Override
	public boolean takePayment(Player fromWhom, double amount) {
		String player = fromWhom.getName();
		if(!iConomy.hasAccount(player)) return false;
		Account acc = iConomy.getAccount(player);
		if(acc == null) return false;
		Holdings money = acc.getHoldings();
		if(!money.hasEnough(amount)) return false;
{'fraction_non_alphanumeric': 0.11897261933607947, 'fraction_numerical': 0.005815362248606736, 'mean_word_length': 4.424441524310118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2367923', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1295, 'n_words': 308}