protected void onDragonDeath(EnderDragon dragon) {
        log("The dragon died.");
        if (_stageNumber != 11) {
            log("But we're not in stage 11, so it doesn't count.");
            return;
        }
        if (DragonFight.CONFIG.FIGHT_OWNER == null) {
            log("But nobody owns the fight, so it doesn't count.");
            return;
        }
        // Bukkit.getOfflinePlayer() NEVER returns null, even for non-existent.
        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(DragonFight.CONFIG.FIGHT_OWNER);
        getNearbyPlayers().forEach(p -> p.sendMessage(ChatColor.LIGHT_PURPLE + offlinePlayer.getName() +
                                                      ChatColor.DARK_PURPLE + " was awarded the prize for defeating the dragon."));
        Player player = offlinePlayer.getPlayer();
        if (player == null) {
            // Fight owner is offline. Record an unclaimed prize.
            log("An unclaimed prize was added to offline fight owner " + offlinePlayer.getName() + ".");
            getNearbyPlayers().forEach(p -> p.sendMessage(ChatColor.DARK_PURPLE + "They can claim it when they log in."));
            DragonFight.CONFIG.incUnclaimedPrizes(offlinePlayer.getUniqueId(), 1);
        } else {
            // Select a single drop from the `df-dragon-drops` loot set.
            // TODO: actually, multiple drops should be supported, once
            // BeastMaster supports deferred item drops.
            log("Generating dragon prizes for " + player.getName());
            List<ItemStack> prizes = generatePrizes();
            if (!givePrizes(player, prizes)) {
                // The item(s) did not fit, so player must claim with command.
                DragonFight.CONFIG.incUnclaimedPrizes(offlinePlayer.getUniqueId(), 1);
                String slots = ChatColor.LIGHT_PURPLE + Integer.toString(prizes.size()) +
                               ChatColor.DARK_PURPLE + " inventory slot" + (prizes.size() > 1 ? "s" : "");
                player.sendMessage(ChatColor.DARK_PURPLE + "You need at least " + slots + " empty.");
                player.sendMessage(ChatColor.DARK_PURPLE + "Run " +
                                   ChatColor.LIGHT_PURPLE + "/dragon prize" +
                                   ChatColor.DARK_PURPLE + " to claim your prize.");
            }
        }
        // Clear the fight owner once prizes have been given or unclaimed prizes
        // recorded, to prevent extra prizes if spurious dragons spawn.
        DragonFight.CONFIG.FIGHT_OWNER = null;
        DragonFight.CONFIG.save();
    }
protected void onDragonDeath(EnderDragon dragon) {
        log("The dragon died.");
        if (_stageNumber != 11) {
            log("But we're not in stage 11, so it doesn't count.");
            return;
        }
        if (DragonFight.CONFIG.FIGHT_OWNER == null) {
            log("But nobody owns the fight, so it doesn't count.");
            return;
        }
       
        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(DragonFight.CONFIG.FIGHT_OWNER);
        getNearbyPlayers().forEach(p -> p.sendMessage(ChatColor.LIGHT_PURPLE + offlinePlayer.getName() +
                                                      ChatColor.DARK_PURPLE + " was awarded the prize for defeating the dragon."));
        Player player = offlinePlayer.getPlayer();
        if (player == null) {
           
            log("An unclaimed prize was added to offline fight owner " + offlinePlayer.getName() + ".");
            getNearbyPlayers().forEach(p -> p.sendMessage(ChatColor.DARK_PURPLE + "They can claim it when they log in."));
            DragonFight.CONFIG.incUnclaimedPrizes(offlinePlayer.getUniqueId(), 1);
        } else {
           
           
           
            log("Generating dragon prizes for " + player.getName());
            List<ItemStack> prizes = generatePrizes();
            if (!givePrizes(player, prizes)) {
               
                DragonFight.CONFIG.incUnclaimedPrizes(offlinePlayer.getUniqueId(), 1);
                String slots = ChatColor.LIGHT_PURPLE + Integer.toString(prizes.size()) +
                               ChatColor.DARK_PURPLE + " inventory slot" + (prizes.size() > 1 ? "s" : "");
                player.sendMessage(ChatColor.DARK_PURPLE + "You need at least " + slots + " empty.");
                player.sendMessage(ChatColor.DARK_PURPLE + "Run " +
                                   ChatColor.LIGHT_PURPLE + "/dragon prize" +
                                   ChatColor.DARK_PURPLE + " to claim your prize.");
            }
        }
       
       
        DragonFight.CONFIG.FIGHT_OWNER = null;
        DragonFight.CONFIG.save();
    }
protected void ondragondeath(enderdragon dragon) { log("the dragon died."); if (_stagenumber != 11) { log("but we're not in stage 11, so it doesn't count."); return; } if (dragonfight.config.fight_owner == null) { log("but nobody owns the fight, so it doesn't count."); return; } offlineplayer offlineplayer = bukkit.getofflineplayer(dragonfight.config.fight_owner); getnearbyplayers().foreach(p -> p.sendmessage(chatcolor.light_purple + offlineplayer.getname() + chatcolor.dark_purple + " was awarded the prize for defeating the dragon.")); player player = offlineplayer.getplayer(); if (player == null) { log("an unclaimed prize was added to offline fight owner " + offlineplayer.getname() + "."); getnearbyplayers().foreach(p -> p.sendmessage(chatcolor.dark_purple + "they can claim it when they log in.")); dragonfight.config.incunclaimedprizes(offlineplayer.getuniqueid(), 1); } else { log("generating dragon prizes for " + player.getname()); list<itemstack> prizes = generateprizes(); if (!giveprizes(player, prizes)) { dragonfight.config.incunclaimedprizes(offlineplayer.getuniqueid(), 1); string slots = chatcolor.light_purple + integer.tostring(prizes.size()) + chatcolor.dark_purple + " inventory slot" + (prizes.size() > 1 ? "s" : ""); player.sendmessage(chatcolor.dark_purple + "you need at least " + slots + " empty."); player.sendmessage(chatcolor.dark_purple + "run " + chatcolor.light_purple + "/dragon prize" + chatcolor.dark_purple + " to claim your prize."); } } dragonfight.config.fight_owner = null; dragonfight.config.save(); }