Advertisement
Guest User

onPlayerInteract

a guest
Apr 14th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 KB | None | 0 0
  1.     @SuppressWarnings("deprecation")
  2.     @EventHandler
  3.     public void onPlayerInteract(PlayerInteractEvent event) {//onPlayerInteract method.
  4.     Player player = event.getPlayer(); //Get player
  5.     if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK && player.getItemInHand().getType() == Material.MUSHROOM_SOUP && player.getHealth()!=20) {
  6.     player.setHealth(player.getHealth()+3);
  7.     event.getPlayer().getItemInHand().setType(Material.BOWL);
  8.    
  9.     }
  10.     if (event.getClickedBlock().getState() instanceof Sign){
  11.         Sign sign = (Sign) event.getClickedBlock().getState();
  12.             if(sign.getLine(0).equalsIgnoreCase("[kit]")) {
  13.                 if(sign.getLine(1).equalsIgnoreCase("Standard")){
  14.                     player.sendMessage("You have revieved: "+ChatColor.RED+"Standard");
  15.                     PlayerInventory inventory = player.getInventory(); // The player's inventory
  16.                     Enchantment prot = new EnchantmentWrapper(0);
  17.                     Enchantment s = new EnchantmentWrapper(16);
  18.                     ItemStack diamondsword = new ItemStack(Material.DIAMOND_SWORD, 1);
  19.                     ItemStack ironchestplate = new ItemStack(Material.IRON_CHESTPLATE, 1);
  20.                     ironchestplate.addEnchantment(prot, 1);
  21.                     ItemStack ironleggings = new ItemStack(Material.IRON_LEGGINGS, 1);
  22.                     ironleggings.addEnchantment(prot, 1);
  23.                     ItemStack ironboots = new ItemStack(Material.IRON_BOOTS, 1);
  24.                     ironboots.addEnchantment(prot, 1);
  25.                     ItemStack ironhelmet = new ItemStack(Material.IRON_HELMET, 1);
  26.                     ironhelmet.addEnchantment(prot, 2);
  27.                     ItemStack food = new ItemStack(Material.GRILLED_PORK, 32);
  28.                     diamondsword.addEnchantment(s, 1);
  29.  
  30.                         Kit="Standard";
  31.                         //If player has: food, diamondsword, and iron armour, do this:
  32.                         if(!(inventory.contains(food) && inventory.contains(diamondsword) && inventory.getHelmet().equals(ironhelmet) && inventory.getChestplate().equals(ironchestplate) && inventory.getLeggings().equals(ironleggings) && inventory.getBoots().equals(ironboots))){
  33.                             inventory.setHelmet(ironhelmet);
  34.                             inventory.setChestplate(ironchestplate);
  35.                             inventory.setLeggings(ironleggings);
  36.                             inventory.setBoots(ironboots);
  37.                             inventory.addItem(food, diamondsword);
  38.                             player.updateInventory();
  39.                         }else{
  40.                             player.sendMessage("You already have kit "+Kit);
  41.                        
  42.                    
  43.                         }//End of else statement
  44.                
  45.                 //End of if line 1 contains standard.
  46.                 }else if(sign.getLine(1).equalsIgnoreCase("Archer")){
  47.                     player.sendMessage("You have revieved: "+ChatColor.RED+"Standard");
  48.                     Enchantment ff = new EnchantmentWrapper(2);
  49.                     //ItemStack chainhelmet = new ItemStack(302, 1);
  50.                     //ItemStack chainplate = new ItemStack(302, 1);
  51.                     //ItemStack chainleggings = new ItemStack(302, 1);
  52.                     ItemStack chainboots = new ItemStack(305,1);
  53.                     chainboots.addEnchantment(ff,5);
  54.                 }else{
  55.                     player.sendMessage("You already have kit "+Kit);
  56.                 }
  57.             //End of if line 0 contains map.
  58.             }
  59.     }//End of if sign check.
  60.     }//End of onPlayerInteract Method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement