1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

I could not use "breaK" as advised as that would completely break the loop and cease checking for duplicates among the remaining items. However, we are only checking against 5 additional slots here, so I've stated them each and made them return if a match is a bit better than setting a variable and all that, this is also more clear about what is going on here. I will state that the previous patch does introduce a limitation: identical soulbound items would be lost. Having exactly duplicated soulbound items prior to a death is a rather extreme situation, but during my testing I actually was using some I duplicated in creative mode and noticed that I would only retrieve one of each, and not the copies. It might be desireable to integrate an option here to only use this logic IF keep inventory regions will be in use somewhere, although not entirely necessary.

This commit is contained in:
Rick 2018-04-20 17:53:36 -04:00
parent 44e9a3cc43
commit 785cbea08f

View File

@ -21,6 +21,12 @@ public class Soul {
public static void retrieveItems(Player p) { public static void retrieveItems(Player p) {
if (Variables.soulbound.containsKey(p.getUniqueId())) { if (Variables.soulbound.containsKey(p.getUniqueId())) {
for (ItemStack item: Variables.soulbound.get(p.getUniqueId())) { for (ItemStack item: Variables.soulbound.get(p.getUniqueId())) {
if (item.equals(p.getInventory().getHelmet())) return;
if (item.equals(p.getInventory().getChestplate())) return;
if (item.equals(p.getInventory().getLeggings())) return;
if (item.equals(p.getInventory().getBoots())) return;
if (item.equals(p.getInventory().getItemInOffHand())) return;
if(!p.getInventory().contains(item)) { if(!p.getInventory().contains(item)) {
p.getInventory().addItem(item); p.getInventory().addItem(item);
} }