Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  * Called when the user clicks a shop menu category
  3.  * @param mode The buyable items in the shop
  4.  * @param p the Player who this menu should be shown
  5.  */
  6. private static void openMerchantInventory (int mode, Player p){
  7.         // Create inventory
  8.         Merchant inv = new Merchant();
  9.        
  10.         // Instanciate some variables that are re-defined in the switch
  11.         ItemStack buyA = new ItemStack (Material.AIR, 1);
  12.         ItemStack sell;
  13.         ItemMeta meta;
  14.        
  15.         // There are several shop menus, they are defined by the mode variable
  16.         switch (mode) {
  17.         case 0:
  18.            
  19.             // Instanciate the new ItemStacks and add them to the Villager Shop
  20.             buyA = new ItemStack (Material.CLAY_BRICK, 1);
  21.             meta = buyA.getItemMeta ();
  22.             meta.setDisplayName (ChatColor.RED + "Bronze");
  23.             buyA.setItemMeta(meta);
  24.             sell = new ItemStack (Material.SANDSTONE, 2);
  25.             inv.addOffer (new MerchantOffer (buyA, sell));
  26.            
  27.             buyA = new ItemStack (Material.CLAY_BRICK, 7);
  28.             meta = buyA.getItemMeta ();
  29.             meta.setDisplayName (ChatColor.RED + "Bronze");
  30.             buyA.setItemMeta(meta);
  31.             sell = new ItemStack (Material.ENDER_STONE, 1);
  32.             inv.addOffer (new MerchantOffer (buyA, sell));
  33.            
  34.             buyA = new ItemStack (Material.CLAY_BRICK, 2);
  35.             meta = buyA.getItemMeta ();
  36.             meta.setDisplayName (ChatColor.RED + "Bronze");
  37.             buyA.setItemMeta(meta);
  38.             sell = new ItemStack (Material.GLOWSTONE, 1);
  39.             inv.addOffer (new MerchantOffer (buyA, sell));
  40.            
  41.             buyA = new ItemStack (Material.IRON_INGOT, 1);
  42.             meta = buyA.getItemMeta ();
  43.             meta.setDisplayName (ChatColor.GRAY + "Silber");
  44.             buyA.setItemMeta(meta);
  45.             sell = new ItemStack (Material.CHEST, 1);
  46.             inv.addOffer (new MerchantOffer (buyA, sell));
  47.            
  48.             buyA = new ItemStack (Material.IRON_INGOT, 3);
  49.             meta = buyA.getItemMeta ();
  50.             meta.setDisplayName (ChatColor.GRAY + "Silber");
  51.             buyA.setItemMeta(meta);
  52.             sell = new ItemStack (Material.IRON_BLOCK, 1);
  53.             inv.addOffer (new MerchantOffer (buyA, sell));
  54.            
  55.             buyA = new ItemStack (Material.GOLD_INGOT, 1);
  56.             meta = buyA.getItemMeta ();
  57.             meta.setDisplayName (ChatColor.GOLD + "Gold");
  58.             buyA.setItemMeta(meta);
  59.             sell = new ItemStack (Material.ENDER_CHEST, 1);
  60.             meta = sell.getItemMeta();
  61.             meta.setDisplayName(ChatColor.DARK_PURPLE + "Team-Kiste");
  62.             sell.setItemMeta(meta);
  63.             inv.addOffer (new MerchantOffer (buyA, sell));
  64.            
  65.             inv.setTitle ("Blöcke");
  66.             break;
  67.            
  68.             // I've left out some other cases because in fact it's the same
  69.             // only with other shop items
  70.         }
  71.         // Close the old menu that has been shown before
  72.         p.closeInventory();
  73.         // Open the new inventory
  74.         inv.setCustomer(p);
  75.         inv.openTrading(p);
  76.     }