CustomPvPdrops

Discussion in 'Plugin Development' started by PainSlice, Sep 19, 2021.

  1. Offline

    PainSlice

    hey guys dont know what the freak im doing wrong here
    its for 1.16
    its made in Java 1.8 because i dont find new java jre iam new into making plugins
    Code:
    package me.pain.customkilldrops;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    public class Main extends JavaPlugin implements Listener {
    
        public void onEnable() {
            System.out.println("CustomKillDrops enabled!");
        }
     
        public void onDisable() {
            System.out.println("CustomKillDrops disabled!");
        }
        @EventHandler
        public void pvpKill(PlayerDeathEvent e) { // Event
            ItemStack item = new ItemStack(Material.WITHER_ROSE, 1); //Item das Gedroppt wird
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(ChatColor.BLACK + "Wither_Coin"); //Item Name
            Player v = (Player) e.getEntity();
            Player p = v.getKiller();
            if (p instanceof Player) {
                e.getDrops().add(item);
            p.sendMessage(ChatColor.GREEN + "Du hast" + v.getName() + "getötet!"); //Nachricht für denn Killer
            v.sendMessage(ChatColor.RED + "Du wurdest von" +p.getName() + "getötet!"); //Nachricht für denn Getöten Spieler
            }
        }
    }
    
    it should dropped the item i made when a player gets killed in pvp
    the plugin loads and seems fine but when i kill player nothing dropps :(
     
    Last edited by a moderator: Sep 19, 2021
  2. Offline

    timtower Administrator Administrator Moderator

    @PainSlice You did not register the event in your onEnable
    And please don't log your own plugin, Bukkit does that for you.
     

Share This Page