Guest User

Untitled

a guest
Jun 15th, 2021
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // event
  2. @EventHandler
  3. public void onPlayerDeathEvent(PlayerDeathEvent event) {
  4.     Player plr = event.getEntity();
  5.     Player killer = plr.getKiller();
  6.  
  7.     if (killer != null) {
  8.         //Bukkit.broadcastMessage("debug\nvictim: " + plr.getName() + " killer: " + killer.getName());
  9.  
  10.         if (killer.hasPermission("headdrop.candrop")) {
  11.             ItemStack stack = genHead(plr);
  12.             killer.getInventory().addItem(stack);
  13.         }
  14.     }
  15. }
  16.  
  17. // genHead method
  18. private static ItemStack genHead(Player plr) {
  19.     Material type = Material.matchMaterial("PLAYER_HEAD");
  20.     assert type != null;
  21.  
  22.     ItemStack skull = new ItemStack(type, 1);
  23.  
  24.     SkullMeta meta = (SkullMeta) skull.getItemMeta();
  25.     assert meta != null;
  26.  
  27.     meta.setOwningPlayer(plr);
  28.     meta.setDisplayName(plr.getName() + "'s head");
  29.  
  30.     skull.setItemMeta(meta);
  31.  
  32.     return skull;
  33. }
RAW Paste Data