Add configurable bounty player head drop chance

This commit is contained in:
NotAlexNoyle committed 2026-03-09 04:58:32 -04:00
1 parent 2d10ab8eb6
commit babfe91ef1
2 files changed
+32 -2

No files matched your search

@@ -1,14 +1,19 @@
package com.tcoded.playerbountiesplus.listener;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.profile.PlayerProfile;
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
import com.tcoded.playerbountiesplus.event.BountyClaimEvent;
@@ -150,6 +155,8 @@ public class DeathListener implements Listener {
}
maybeDropPlayerHead(event, victim);
bountyDataManager.removeBounty(victimId);
bountyDataManager.saveBountiesAsync();
@@ -190,6 +197,26 @@ public class DeathListener implements Listener {
}
private void maybeDropPlayerHead(PlayerDeathEvent event, Player victim) {
final double dropChance = Math.max(0D, Math.min(100D, plugin.getConfig().getDouble("bounty-head-drop-chance", 50D)));
if (ThreadLocalRandom.current().nextDouble(100D) >= dropChance) {
return;
}
final ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
final SkullMeta headMeta = (SkullMeta) head.getItemMeta();
final PlayerProfile profile = Bukkit.createPlayerProfile(victim.getUniqueId());
headMeta.setPlayerProfile(profile);
head.setItemMeta(headMeta);
event.getDrops().add(head);
}
private String getLuckPermsPrefixLegacy(Player player) {
if (luckPerms == null) {
@@ -270,4 +297,4 @@ public class DeathListener implements Listener {
}
}
}
+4 -1
View File
@@ -36,9 +36,12 @@ bounty-claim-multiplier: 1.0
# If we should announce that the bounty was claimed
bounty-claimed-announce: true
# Chance (0-100) that claiming a bounty drops the victim's player head.
bounty-head-drop-chance: 50.0
# If we should announce that the bounty was placed
bounty-placed-announce: true
# Should the bounty money be taken from the player who dies?
# This can reduce same-team killing (or the use of alts) to claim the bounty from themselves
bounty-take-from-victim: false
bounty-take-from-victim: false