
Untitled
By: a guest on
Apr 26th, 2012 | syntax:
Java | size: 2.20 KB | hits: 15 | expires: Never
double price = 0;
double itemPrice = 0;
int items = 0;
for(int i = 0; i < 27; i ++)
{
if(chest.getInventory().getItem(i) != null)
{
itemPrice = fileManager.getItemPrice(chest.getInventory().getItem(i).getType().name());
if(itemPrice != -1)
{
int itemID = chest.getInventory().getItem(i).getTypeId();
if((itemID > 255 && itemID < 260) || itemID == 261 || (itemID > 266 && itemID < 287) || (itemID > 289 && itemID < 295) || (itemID > 297 && itemID < 318) || itemID == 266)
{
double cto = chest.getInventory().getItem(i).getType().getMaxDurability();
if(chest.getInventory().getItem(i).getDurability() > cto){itemPrice = 0;}
else
{
double perCent = 100 - 100/cto * chest.getInventory().getItem(i).getDurability();
itemPrice = itemPrice/100 * perCent;
}
}
itemPrice *= chest.getInventory().getItem(i).getAmount();
price += itemPrice;
if(fileManager.getBoolean("LOG_SOLD_ITEMS", true)){fileManager.setChestItemsSold(usedChestID, fileManager.getChestItemsSold(usedChestID) + chest.getInventory().getItem(i).getAmount());}
items++;
}
else{player.sendMessage(ChatColor.RED + fileManager.getMSG("ERROR_MESSAGE_NO_ITEMPRICE", "Der Preis für das Item %item% konnte nicht geladen werden, bitte wende dich an einen Administrator.").replace("%item%", chest.getInventory().getItem(i).getType().toString())); fileManager.setChestUser(usedChestID, "Niemand"); return;}
}
}
if(items != 0)
{
chest.getInventory().clear();
System.out.println("Preis:" + price);
account.getHoldings().add(price);
fileManager.setChestUser(usedChestID, "Niemand");
player.sendMessage(ChatColor.DARK_GREEN + fileManager.getMSG("INFO_MESSAGE_STUFF_SOLD", "Du hast deine Items erfolgreich für %money% verkauft, dein aktuelles Vermögen beträgt nun %allmoney%.").replace("%money%", iConomy.format(price)).replace("%allmoney%", iConomy.format(account.getHoldings().getBalance().doubleValue())));
}