SHARE
TWEET

Untitled

danik159 Jul 19th, 2019 46 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.EntityType;
  11. import org.bukkit.entity.Item;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.EventHandler;
  14. import org.bukkit.event.Listener;
  15. import org.bukkit.event.player.PlayerDropItemEvent;
  16. import org.bukkit.inventory.ItemStack;
  17. import org.bukkit.inventory.meta.ItemMeta;
  18. import org.bukkit.plugin.java.JavaPlugin;
  19. import org.bukkit.scheduler.BukkitRunnable;
  20. import org.bukkit.scheduler.BukkitTask;
  21.  
  22. public class Main extends JavaPlugin implements Listener {
  23.    
  24.     public void onEnable() {
  25.         Bukkit.getPluginManager().registerEvents(this, this);
  26.     }
  27.    
  28.     BukkitTask task;
  29.  
  30.     @EventHandler
  31.     public void playermove(PlayerDropItemEvent e) {
  32.         final Player player = e.getPlayer();
  33.         final Location iloc = e.getItemDrop().getLocation();
  34.         final Item item = e.getItemDrop();
  35.         ItemStack dagger = new ItemStack(Material.DIAMOND_SWORD, 1);
  36.         ItemMeta meta = dagger.getItemMeta();
  37.          
  38.        
  39.         meta.setDisplayName(ChatColor.GRAY + "Dagger");
  40.         if (item.getItemStack().getType() == Material.DIAMOND) {
  41.         task = new BukkitRunnable() {
  42.             @Override
  43.             public void run() {
  44.                 if (!item.isOnGround() && item.isDead()) {
  45.                     cancel();
  46.                 }
  47.                 if (item.getItemStack().getType() == Material.DIAMOND) {
  48.                     final List<Entity> ents = item.getNearbyEntities(2, 2, 2);
  49.                     for (final Entity e : ents) {
  50.                         if (e instanceof Item) {
  51.                             if (item.getItemStack().getType().equals(Material.DIAMOND)) {
  52.                                 player.sendMessage("Diamond has been thrown");
  53.                                 player.getWorld().spawnEntity(iloc, EntityType.LIGHTNING);
  54.                                 player.getInventory().addItem(dagger);
  55.                             }
  56.                         }
  57.                     }
  58.  
  59.                 }
  60.             }
  61.                    
  62.                     }.runTaskTimerAsynchronously(this, 0, 40);
  63.                 }
  64.            
  65.        
  66.          }
  67. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top