Improvements to autolooting blacklist.

Since player names are shorter than many item names, items will now be prevented from being looted if the beginning of the name is in the block list.
The blocklist now also prevents satchels and the ring of wealth from looting items, not just familiars as it did previously.
This commit is contained in:
randy 2025-08-19 11:53:24 -06:00
parent 5a896cecb4
commit 59c55708a6

View file

@ -105,12 +105,15 @@ public final class NPCDropTables {
if (handleBoneCrusher(player, item)) {
return;
}
if (handleSatchel(player, item)) {
return;
}
if (handleCurrency(player, item)) {
return;
}
boolean blocked = isBlockedItem(player, item);
if (!blocked) {
if (handleSatchel(player, item)) {
return;
}
if (handleCurrency(player, item)) {
return;
}
}
if (item.hasItemPlugin() && player != null) {
if (!item.getPlugin().createDrop(item, player, npc, l)) {
return;
@ -118,7 +121,7 @@ public final class NPCDropTables {
item = item.getPlugin().getItem(item, npc);
}
if (!item.getDefinition().isStackable() && item.getAmount() > 1) {
if (hasValidFamiliar(player)) {
if (!blocked && hasValidFamiliar(player)) {
for (int i = 0; i < item.getAmount(); i++) {
if (!addItemFamiliar(player, new Item(item.getId()))) {
GroundItemManager.create(new Item(item.getId()), l, player);
@ -142,7 +145,7 @@ public final class NPCDropTables {
}
} else {
Player looter = getLooter(player, npc, item);
if (hasValidFamiliar(looter) && addItemFamiliar(looter, item)) {
if (!blocked && hasValidFamiliar(looter) && addItemFamiliar(looter, item)) {
return;
}
GroundItem groundItem = GroundItemManager.create(item, l, looter);
@ -158,7 +161,7 @@ public final class NPCDropTables {
}
}
/** Snowlab custom looting
/** Snowscape: custom looting
* Check if the player has a valid familiar that can loot.
* @param player The player
* @return true if they have a valid familiar.
@ -170,15 +173,12 @@ public final class NPCDropTables {
return false;
}
}
/** Snowlab custom looting
/** Snowscape: custom looting
* Attempt adding item to familiar inventory.
* @param player The player
* @return true if item was successfully added.
*/
private boolean addItemFamiliar(Player player, Item item) {
if (player.getCommunication().getBlocked().contains(item.getName().toLowerCase().replace(" ","_"))) {
return false;
}
if ((player.getFamiliarManager().getFamiliar() instanceof PackYakNPC) && ((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer().contains(12435, 1) && player.getBank().add(item)) {
((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer().remove(new Item(12435, 1));
player.sendMessage("Your familiar picked up and banked " + item.getAmount() + " " + item.getName() + ".");
@ -305,6 +305,18 @@ public final class NPCDropTables {
}
return false;
}
//Snowscape: check if the item is in the player's ignore list
private boolean isBlockedItem(Player player, Item item) {
// Format the item name to match the block list formatting. Then check if the item name starts with any of the blocked names.
String formattedName = item.getName().toLowerCase().replace(" ","_");
for (String blocked : player.getCommunication().getBlocked()) {
if (blocked.length() > 0 && formattedName.startsWith(blocked)) {
return true;
}
}
return false;
}
/**
* Gets the ratio for stabilizing NPC combat difficulty & drop rates.