Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/com/ranull/graves/manager/GraveManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ public void autoLootGrave(Entity entity, Location location, Grave grave) {
player.getInventory().setItem(counter, itemStack);
grave.getInventory().remove(itemStack);

if ((counter == 39 && InventoryUtil.isHelmet(itemStack))
// Added Shield and Torches to be auto looted
if ((counter == 40 && InventoryUtil.isOffhandItem(itemStack))
|| (counter == 39 && InventoryUtil.isHelmet(itemStack))
|| (counter == 38 && InventoryUtil.isChestplate(itemStack))
|| (counter == 37 && InventoryUtil.isLeggings(itemStack))
|| (counter == 36 && InventoryUtil.isBoots(itemStack))) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/ranull/graves/util/InventoryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public static void equipArmor(Inventory inventory, Player player) {
playArmorEquipSound(player, itemStack);
inventory.removeItem(itemStack);
}

if(player.getInventory().getItemInOffHand().getType().isAir() && isOffhandItem(itemStack)) {
player.getInventory().setItemInOffHand(itemStack);
inventory.removeItem(itemStack);
}
}
}
}
Expand Down Expand Up @@ -132,6 +137,10 @@ public static boolean isBoots(ItemStack itemStack) {
"CHAINMAIL_BOOTS");
}

public static boolean isOffhandItem(ItemStack itemStack) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it always this? Can't you also hold something else in the off-hand?

I'm thinking about the dualwield plugin I forked. So then you'd be able to hold an axe or sword in your offhand.

Isn't there a better way to do this? I mean: maybe it's possible to store (as underneath it's using SQLite) the order of items? And as such, also store armor/hand/offhand data?

Do you think it's possible to do it that way?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure that it would be much better to use SQLite to store the items properly however, I believe it would require a decent change to the way that the graves store the items.

I don't really have the time to implement those changes properly, and this was kind of just a bandaid fix to just get the idea out, mostly for personal use, in the hopes that someone else will expand upon it (in a hopefully much smarter way than I can).

(While writing this out, I realized that it probably would have been better to just make a feature request rather than make a weak attempt at implementing it)

Copy link
Collaborator

@svaningelgem svaningelgem Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you allow me to write to your branch, I will have a try today. Or I just fork your fork 😎.

return itemStack != null && itemStack.getType().name().matches("(?i)SHIELD|TORCH");
}

public static String inventoryToString(Inventory inventory) {
List<String> stringList = new ArrayList<>();

Expand Down