Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: Java  |  size: 2.20 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. double price = 0;
  2.                                                                 double itemPrice = 0;
  3.                                                                 int items = 0;
  4.                                                                 for(int i = 0; i < 27; i ++)
  5.                                                                 {
  6.                                                                         if(chest.getInventory().getItem(i) != null)
  7.                                                                         {      
  8.                                                                                 itemPrice = fileManager.getItemPrice(chest.getInventory().getItem(i).getType().name());
  9.                                                                                 if(itemPrice != -1)
  10.                                                                                 {
  11.                                                                                         int itemID = chest.getInventory().getItem(i).getTypeId();
  12.                                                                                         if((itemID > 255 && itemID < 260) || itemID == 261 || (itemID > 266 && itemID < 287) || (itemID > 289 && itemID < 295) || (itemID > 297 && itemID < 318) || itemID == 266)
  13.                                                                                         {
  14.                                                                                                 double cto = chest.getInventory().getItem(i).getType().getMaxDurability();
  15.                                                                                                 if(chest.getInventory().getItem(i).getDurability() > cto){itemPrice = 0;}
  16.                                                                                                 else
  17.                                                                                                 {
  18.                                                                                                         double perCent = 100 - 100/cto * chest.getInventory().getItem(i).getDurability();
  19.                                                                                                         itemPrice = itemPrice/100 * perCent;
  20.                                                                                                 }      
  21.                                                                                         }
  22.                                                                                         itemPrice *= chest.getInventory().getItem(i).getAmount();
  23.                                                                                         price += itemPrice;
  24.                                                                                         if(fileManager.getBoolean("LOG_SOLD_ITEMS", true)){fileManager.setChestItemsSold(usedChestID, fileManager.getChestItemsSold(usedChestID) + chest.getInventory().getItem(i).getAmount());}
  25.                                                                                         items++;
  26.                                                                                 }
  27.                                                                                 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;}
  28.                                                                         }      
  29.                                                                 }
  30.                                                                 if(items != 0)
  31.                                                                 {
  32.                                                                         chest.getInventory().clear();
  33.                                                                         System.out.println("Preis:" + price);
  34.                                                                         account.getHoldings().add(price);
  35.                                                                         fileManager.setChestUser(usedChestID, "Niemand");
  36.                                                                         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())));
  37.                                                                 }