else if (args[0].equals("Sat"))
{
if (args.length >= 3)
{
if (Functions.SQLDataControl("select * from market where Name = '"+ args[1] +"'"))
{
if (StringUtils.isNumeric(args[2]))
{
int Value = Integer.parseInt(args[2]);
if (Value > 0)
{
double MyMoney = Double.parseDouble(Functions.SQLSingleRead("select * from users where MinecraftUsername = '"+ Username +"'", "money"));
double MoneyValue = Double.parseDouble(Functions.SQLSingleRead("select * from market where Name = '"+ args[1] +"'", "Sell"));
double CurrencyValue = Double.parseDouble(Functions.SQLSingleRead("select * from currency where ID = 1", "Money"));
String ProductCode = Functions.SQLSingleRead("select * from market where Name = '"+ args[1] +"'", "Product");
getLogger().info("[Ekonomi] " + Username + " -> " + MyMoney + "\nMucosoft Lirası Miktarı -> " + CurrencyValue);
double TotalMoney = MoneyValue * Value;
if (CurrencyValue > TotalMoney)
{
Player Pl = (Player) Sender;
PlayerInventory Inv = Pl.getInventory();
ItemStack[] Items = Inv.getContents();
int InvCount = 0;
for (ItemStack Item : Items)
{
if (Item != null & Item.getAmount() > 0 & Item.getType().name() == ProductCode)
{
InvCount += Item.getAmount();
Inv.remove(Item);
}
}
if (InvCount > 0)
{
int Dif = InvCount - Value;
if (Dif > 0)
{
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "give "+ Username +" "+ ProductCode +" "+ Dif);
}
MyMoney += TotalMoney;
CurrencyValue -= TotalMoney;
Functions.SQLExecute("update currency set Money = "+ CurrencyValue +" where ID = 1");
Functions.SQLExecute("update users set money = "+ MyMoney +" where MinecraftUsername = '"+ Username +"'");
MinecraftFunctions.SendMsg(Sender, MsgType.Info, "Ürünü başarılı bir şekilde sattın.");
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, "Ürünü satmak için envanterinde en az 1 adet bulunmalı.");
}
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, "Toplam değer piyasadaki para miktarından fazla. Piyasadaki para miktarı " + CurrencyValue + " ML olarak yer alıyor.");
}
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, "Miktar 0'dan büyük olmalı.");
}
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, "Hatalı sayı formatı girildi.");
}
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, "Ürün markette bulunmuyor.");
}
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, NoArg);
}
}
else.
{
MinecraftFunctions.SendMsg(Sender, MsgType.Error, NoArg);
}