Item On Death

This plugin is currently not working properly, and is not recommended for use. I will release an update as soon as I can to fix the major issue I did not see when I was writing the plugin.

The ItemOnDeath plugin is pretty self explanatory; when a player dies, one (random) item is kept from their inventory and is returned to them when they respawn. There is no configuration for this plugin (yet).

Developed by: Derragon (Scott Stevens) Owned by: Open Source Programming Group Source Code: Open


  • Keep one (random) item on death.


  • I am accepting ideas for other server plugins and features for this plugin/other plugin(s).
  • This plugin is tested for major bugs/issues, and updates are not released unless those bugs/issues are fixed.
  • All of my code is open-source, and is meant to help other plugin developers learn.
  • This plugin was designed by the OpenSourceProgramming group, which consists of only myself (Derragon) currently.
  • If you would like to join the OpenSourceProgramming group, please send me a PM with your previous programming experience, along with 1 (one) or more references that can vouch for your previous experience.


  • Create configuration abilities.
  • Add new feature(s).

Source Code:

package ca.bcminecraft.itemondeath;

import java.util.HashMap;
import java.util.Random;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

 * @author Scott
public class Main extends JavaPlugin implements Listener {
    Logger log = Logger.getLogger("Minecraft");
    Random r = new Random();
    HashMap<String, ItemStack> returnItems = new HashMap();
    public void onEnable () {"Enabled.");
        getServer().getPluginManager().registerEvents(this, this);
    public void onDisable () {"Disabled.");
    public boolean onPlayerDeath(PlayerDeathEvent e){
        Player p = e.getEntity();
        Inventory i = p.getInventory();
        int toGet = r.nextInt(i.getContents().length - 1);
        ItemStack item = i.getItem(toGet);
        returnItems.put(p.getName(), item);
        if (returnItems.containsKey(p.getName())){
            return true;
        } else {
            return false;
    public boolean onPlayerRespawn(PlayerRespawnEvent e){
        Player p = e.getPlayer();
        String name = p.getName();
        if (returnItems.containsKey(name)){
            if (p.getItemInHand() == returnItems.get(name)){
            else {
                return false;
        return true;

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of tommycake50 tommycake50 Jun 03, 2013 at 18:46 UTC - 0 likes

    I guess this is discontinued then, Shame, i think ill compile this and edit it slightly for the server i am admin on this looks like a nice plugin(if a little outdated).

    Last edited Jun 03, 2013 by tommycake50
  • 1 comment


Date created
Jul 15, 2012
Last update
Jul 15, 2012
Development stage
GNU General Public License version 3 (GPLv3)