SHARE
TWEET

Untitled

danik159 Jul 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.junkstyle.craftsystem;
  2.  
  3. import java.util.List;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.entity.Entity;
  10. import org.bukkit.entity.Item;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.player.PlayerDropItemEvent;
  15. import org.bukkit.inventory.ItemStack;
  16. import org.bukkit.inventory.meta.ItemMeta;
  17. import org.bukkit.plugin.java.JavaPlugin;
  18. import org.bukkit.scheduler.BukkitRunnable;
  19. import org.bukkit.scheduler.BukkitTask;
  20.  
  21. public class Main extends JavaPlugin implements Listener {
  22.    
  23.     public void onEnable() {
  24.         Bukkit.getPluginManager().registerEvents(this, this);
  25.     }
  26.    
  27.     BukkitTask task;
  28.  
  29.     @EventHandler
  30.     public void playermove(PlayerDropItemEvent e) {
  31.         final Player player = e.getPlayer();
  32.         final Location iloc = e.getItemDrop().getLocation();
  33.         final Item item = e.getItemDrop();
  34.         ItemStack dagger = new ItemStack(Material.DIAMOND_SWORD, 1);
  35.         ItemMeta meta = dagger.getItemMeta();
  36.         meta.setDisplayName(ChatColor.GRAY + "Dagger");
  37.        
  38.         if (item.getItemStack().getType() == Material.STICK) {
  39.         task = new BukkitRunnable() {
  40.             @Override
  41.             public void run() {
  42.                     final List<Entity> ents = item.getNearbyEntities(1, 1, 1);
  43.                     for (final Entity e : ents) {
  44.                         if (e instanceof Item) {
  45.                             final Item item1 = (Item) e;
  46.                             if (!item.isOnGround() && item.isDead()) {
  47.                                 cancel();
  48.                             }
  49.                             if (item1.getItemStack().getType().equals(Material.DIAMOND)) {
  50.                                 player.sendMessage("Diamond has been thrown");
  51.                                 player.getWorld().strikeLightning(iloc);
  52.                                 player.getInventory().addItem(dagger);
  53.                             }
  54.                         }
  55.                     }
  56.  
  57.                 }
  58.  
  59.                    
  60.                     }.runTaskTimerAsynchronously(this, 0, 40);
  61.                 }
  62.            
  63.        
  64.          }
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top