Skip to content

Commit

Permalink
Fix friend skull order in manage inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Jun 19, 2024
1 parent 02aba03 commit e6675e9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package de.sean.blockprot.bukkit.inventories;

import com.google.common.collect.Iterables;
import de.sean.blockprot.bukkit.BlockProt;
import de.sean.blockprot.bukkit.TranslationKey;
import de.sean.blockprot.bukkit.Translator;
Expand All @@ -33,7 +34,6 @@
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -212,13 +212,14 @@ public Inventory fill(@NotNull Player player) {
try {
final var profiles = BlockProt.getProfileService().findAllByUuid(state.friendResultCache);

var offset = state.friendResultCache.contains(FriendSupportingHandler.publicUuid) ? 1 : 0;
int i = 0;
while (i < Math.min(maxSkulls, profiles.size())) {
final var profile = profiles.get(i);
// The profiles array doesn't necessarily have the same order as the friendResultCache.
final var index = Iterables.indexOf(state.friendResultCache, f -> f.equals(profile.getUniqueId()));

if (!profile.getUniqueId().equals(FriendSupportingHandler.publicUuid)) {
setPlayerSkull(offset + i, Bukkit.getServer().createPlayerProfile(profile.getUniqueId(), profile.getName()));
setPlayerSkull(index, Bukkit.getServer().createPlayerProfile(profile.getUniqueId(), profile.getName()));
}
i++;
}
Expand Down

0 comments on commit e6675e9

Please sign in to comment.