<commit_before>package info.tregmine.currency;


import java.text.NumberFormat;
import java.util.logging.Logger;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import info.tregmine.Tregmine; 
import info.tregmine.zones.ZonesPlugin;

public class Main extends JavaPlugin {

	public final Logger log = Logger.getLogger("Minecraft");
	public Tregmine tregmine = null;
	public ZonesPlugin zones = null;
	NumberFormat nf = NumberFormat.getNumberInstance();

	@Override
	public void onEnable(){
		Plugin test = this.getServer().getPluginManager().getPlugin("Tregmine");

		if(this.tregmine == null) {
			if(test != null) {
				this.tregmine = ((Tregmine)test);
			} else {
				log.info(this.getDescription().getName() + " " + this.getDescription().getVersion() + " - could not find Tregmine");
				this.getServer().getPluginManager().disablePlugin(this);
			}
		}

		
		Plugin zonesTest = this.getServer().getPluginManager().getPlugin("ZonesPlugin");

		if(this.zones == null) {
			if(test != null) {
				this.zones = ((ZonesPlugin)zonesTest);
			} else {
				log.info(this.getDescription().getName() + " " + this.getDescription().getVersion() + " - could not find zones");
				this.getServer().getPluginManager().disablePlugin(this);
			}
		}
		
		
		
		getServer().getPluginManager().registerEvents(new CurrencyPlayer(this), this);
	}

	@Override
	public void onDisable(){
	}

	@Override
	public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
		String commandName = command.getName().toLowerCase();

		if(!(sender instanceof Player)) {
			return false;
		}
		Player player = (Player) sender;
		info.tregmine.api.TregminePlayer tregminePlayer = this.tregmine.tregminePlayer.get(player.getName());

		if (commandName.matches("wallet") && args.length > 0) {
			
			if (args[0].matches("balance")) {
				Wallet wallet = new Wallet(player);
				long balance = wallet.balance();
				if (balance >= 0) {
						player.sendMessage("You have " + ChatColor.GOLD +  nf.format( balance ) + ChatColor.WHITE + " Tregs" );
				} else {
					player.sendMessage(ChatColor.RED + "You have have no wallet. Contact an administrator." );					
				}
				return true;
			}

			if (args[0].matches("tell")) {
				Wallet wallet = new Wallet(player);
//				ChatColor color = this.tregmine.playerSetting.get(player.getName()).getColor();
				long balance = wallet.balance();
				if (balance >= 0) {
					if (!tregminePlayer.isAdmin()) {
						this.getServer().broadcastMessage(tregminePlayer.getChatName() + ChatColor.AQUA + " has " + ChatColor.GOLD + nf.format( balance ) + ChatColor.AQUA + " Tregs." );
					} else {
						player.sendMessage(tregminePlayer.getChatName() + " has " + ChatColor.GOLD +  "more" + ChatColor.WHITE + " Tregs than you." );						
					}

				} else {
					this.getServer().broadcastMessage(tregminePlayer.getChatName() + ChatColor.RED + " has no wallet. Contact an administrator.");
				}
				return true;
			}

			if (args[0].matches("donate") && args.length > 2) {
				int amount;
				Player to;
				
				try {
					amount = Integer.parseInt(args[2]);
				} catch (Exception  e) {
					amount = 0;
				}
				
				try {
					to = this.getServer().matchPlayer(args[1]).get(0);
				} catch (Exception  e) {
					to = null;
				}
				
				if (to != null && amount > 0) {
					if  (info.tregmine.api.math.Distance.calc2d(player.getLocation(), to.getLocation()) > 5) {
						player.sendMessage(ChatColor.RED + to.getName() + " is to far away for a wallet transaction, please move closer");
					}
					
					
					info.tregmine.api.TregminePlayer toPlayer = this.tregmine.tregminePlayer.get(to.getName());
					Wallet wallet = new Wallet(player);
					Wallet toWallet = new Wallet(to);
					
					long newAmount = wallet.balance() - amount;
					if (newAmount >= 0) {
						toWallet.add(amount);
						wallet.take(amount);
						player.sendMessage(ChatColor.AQUA + "You donated to " + toPlayer.getChatName() + " " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs.");
						to.sendMessage(ChatColor.AQUA + "You received " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs from a secret admirer.");
						this.log.info(amount+ ":TREG_DONATED " + player.getName() + " => " + to.getName());
					} else {
						player.sendMessage(ChatColor.RED + "You cant give more then you have!");
					}
				}
				return true;
			}
			if (args[0].matches("give") && args.length > 2) {
				int amount;
				Player to;
				
				try {
					amount = Integer.parseInt(args[2]);
				} catch (Exception  e) {
					amount = 0;
				}
				
				try {
					to = this.getServer().matchPlayer(args[1]).get(0);
				} catch (Exception  e) {
					to = null;
				}
				
				if (to != null && amount > 0) {
					info.tregmine.api.TregminePlayer toPlayer = this.tregmine.tregminePlayer.get(to.getName());
					Wallet wallet = new Wallet(player);
					Wallet toWallet = new Wallet(to);
					
					long newAmount = wallet.balance() - amount;
					if (newAmount >= 0) {
						toWallet.add(amount);
						wallet.take(amount);
						player.sendMessage(ChatColor.AQUA + "You gave " + toPlayer.getChatName() + " " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs.");
						to.sendMessage(ChatColor.AQUA + "You received " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs from " + tregminePlayer.getChatName() + ".");
						this.log.info(amount+ ":TREG " + player.getName() + " => " + to.getName());
					} else {
						player.sendMessage(ChatColor.RED + "You cant give more then you have!");
					}
				}<commit_msg>added the distance to wallet donate aswell<commit_after>package info.tregmine.currency;


import java.text.NumberFormat;
import java.util.logging.Logger;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import info.tregmine.Tregmine; 
import info.tregmine.zones.ZonesPlugin;

public class Main extends JavaPlugin {

	public final Logger log = Logger.getLogger("Minecraft");
	public Tregmine tregmine = null;
	public ZonesPlugin zones = null;
	NumberFormat nf = NumberFormat.getNumberInstance();

	@Override
	public void onEnable(){
		Plugin test = this.getServer().getPluginManager().getPlugin("Tregmine");

		if(this.tregmine == null) {
			if(test != null) {
				this.tregmine = ((Tregmine)test);
			} else {
				log.info(this.getDescription().getName() + " " + this.getDescription().getVersion() + " - could not find Tregmine");
				this.getServer().getPluginManager().disablePlugin(this);
			}
		}

		
		Plugin zonesTest = this.getServer().getPluginManager().getPlugin("ZonesPlugin");

		if(this.zones == null) {
			if(test != null) {
				this.zones = ((ZonesPlugin)zonesTest);
			} else {
				log.info(this.getDescription().getName() + " " + this.getDescription().getVersion() + " - could not find zones");
				this.getServer().getPluginManager().disablePlugin(this);
			}
		}
		
		
		
		getServer().getPluginManager().registerEvents(new CurrencyPlayer(this), this);
	}

	@Override
	public void onDisable(){
	}

	@Override
	public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
		String commandName = command.getName().toLowerCase();

		if(!(sender instanceof Player)) {
			return false;
		}
		Player player = (Player) sender;
		info.tregmine.api.TregminePlayer tregminePlayer = this.tregmine.tregminePlayer.get(player.getName());

		if (commandName.matches("wallet") && args.length > 0) {
			
			if (args[0].matches("balance")) {
				Wallet wallet = new Wallet(player);
				long balance = wallet.balance();
				if (balance >= 0) {
						player.sendMessage("You have " + ChatColor.GOLD +  nf.format( balance ) + ChatColor.WHITE + " Tregs" );
				} else {
					player.sendMessage(ChatColor.RED + "You have have no wallet. Contact an administrator." );					
				}
				return true;
			}

			if (args[0].matches("tell")) {
				Wallet wallet = new Wallet(player);
//				ChatColor color = this.tregmine.playerSetting.get(player.getName()).getColor();
				long balance = wallet.balance();
				if (balance >= 0) {
					if (!tregminePlayer.isAdmin()) {
						this.getServer().broadcastMessage(tregminePlayer.getChatName() + ChatColor.AQUA + " has " + ChatColor.GOLD + nf.format( balance ) + ChatColor.AQUA + " Tregs." );
					} else {
						player.sendMessage(tregminePlayer.getChatName() + " has " + ChatColor.GOLD +  "more" + ChatColor.WHITE + " Tregs than you." );						
					}

				} else {
					this.getServer().broadcastMessage(tregminePlayer.getChatName() + ChatColor.RED + " has no wallet. Contact an administrator.");
				}
				return true;
			}

			if (args[0].matches("donate") && args.length > 2) {
				int amount;
				Player to;
				
				try {
					amount = Integer.parseInt(args[2]);
				} catch (Exception  e) {
					amount = 0;
				}
				
				try {
					to = this.getServer().matchPlayer(args[1]).get(0);
				} catch (Exception  e) {
					to = null;
				}
				
				if (to != null && amount > 0) {
					if  (info.tregmine.api.math.Distance.calc2d(player.getLocation(), to.getLocation()) > 5) {
						player.sendMessage(ChatColor.RED + to.getName() + " is to far away for a wallet transaction, please move closer");
					}
					
					
					info.tregmine.api.TregminePlayer toPlayer = this.tregmine.tregminePlayer.get(to.getName());
					Wallet wallet = new Wallet(player);
					Wallet toWallet = new Wallet(to);
					
					long newAmount = wallet.balance() - amount;
					if (newAmount >= 0) {
						toWallet.add(amount);
						wallet.take(amount);
						player.sendMessage(ChatColor.AQUA + "You donated to " + toPlayer.getChatName() + " " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs.");
						to.sendMessage(ChatColor.AQUA + "You received " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs from a secret admirer.");
						this.log.info(amount+ ":TREG_DONATED " + player.getName() + " => " + to.getName());
					} else {
						player.sendMessage(ChatColor.RED + "You cant give more then you have!");
					}
				}
				return true;
			}
			if (args[0].matches("give") && args.length > 2) {
				int amount;
				Player to;
				
				try {
					amount = Integer.parseInt(args[2]);
				} catch (Exception  e) {
					amount = 0;
				}
				
				try {
					to = this.getServer().matchPlayer(args[1]).get(0);
				} catch (Exception  e) {
					to = null;
				}
				
				if (to != null && amount > 0) {
					info.tregmine.api.TregminePlayer toPlayer = this.tregmine.tregminePlayer.get(to.getName());
					Wallet wallet = new Wallet(player);
					Wallet toWallet = new Wallet(to);

					if  (info.tregmine.api.math.Distance.calc2d(player.getLocation(), to.getLocation()) > 5) {
						player.sendMessage(ChatColor.RED + to.getName() + " is to far away for a wallet transaction, please move closer");
					}

					
					long newAmount = wallet.balance() - amount;
					if (newAmount >= 0) {
						toWallet.add(amount);
						wallet.take(amount);
						player.sendMessage(ChatColor.AQUA + "You gave " + toPlayer.getChatName() + " " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs.");
						to.sendMessage(ChatColor.AQUA + "You received " + ChatColor.GOLD + this.nf.format( amount ) + ChatColor.AQUA +" Tregs from " + tregminePlayer.getChatName() + ".");
						this.log.info(amount+ ":TREG " + player.getName() + " => " + to.getName());
					} else {
						player.sendMessage(ChatColor.RED + "You cant give more then you have!");
					}
				}
{'fraction_non_alphanumeric': 0.14861995753715498, 'fraction_numerical': 0.004076433121019108, 'mean_word_length': 3.1450193593805, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 28, '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': '360935', 'n_tokens_mistral': 4698, 'n_tokens_neox': 3790, 'n_words': 779}