daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.admirable.buffs.events.inventory;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.inventory.InventoryClickEvent;
  8. import org.bukkit.inventory.Inventory;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.inventory.meta.ItemMeta;
  11. import org.bukkit.potion.PotionEffect;
  12. import org.bukkit.potion.PotionEffectType;
  13.  
  14. public class Swift implements Listener {
  15.    
  16.     @SuppressWarnings("deprecation")
  17.     @EventHandler
  18.     public void onInventoryClick(InventoryClickEvent event) {
  19.  
  20.         ItemStack test2 = new ItemStack(373, 1, (short) 16396);
  21.         if (!(event.getWhoClicked() instanceof Player))
  22.             return;
  23.         Inventory inv = event.getInventory();
  24.         if (!(inv.getTitle().equals("Swiftness")))
  25.             return;
  26.         Player player = (Player) event.getWhoClicked();
  27.         ItemStack item = event.getCurrentItem();
  28.         if (item.getType() == Material.SUGAR) {
  29.             event.setCancelled(true);
  30.             return;
  31.         }
  32.         if (item.getType() == Material.REDSTONE) {
  33.         player.setItemInHand(test2);
  34.         player.updateInventory();
  35.            
  36.             return;
  37.         }
  38.         if (item.getType() == Material.GLOWSTONE_DUST) {
  39.            
  40.             return;
  41.         }
  42.         if (item.getType() == Material.PAPER) {
  43.             player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 3));
  44.             return;
  45.         }
  46.         event.setCancelled(true);
  47.         player.closeInventory();
  48.     }
  49.     private ItemStack nameItem(ItemStack item, String name) {
  50.     ItemMeta meta = item.getItemMeta();
  51.     meta.setDisplayName(name);
  52.     item.setItemMeta(meta);
  53.     return item;
  54.     }
  55.     private ItemStack nameItem(Material item, String name) {
  56.         return nameItem(new ItemStack(item), name);
  57.     }
  58. }
RAW Paste Data
Top