mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-29 11:59:21 +00:00
fix: Backpacks not appearing after respawning in a different world
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.listener;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
|
||||
import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
@@ -17,6 +18,14 @@ public class PaperPlayerGameListener implements Listener {
|
||||
user.updateCosmetic(slotTypeToCosmeticType(event.getSlotType()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerPostRespawnEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) user.respawnBackpack();
|
||||
}
|
||||
|
||||
private CosmeticSlot slotTypeToCosmeticType(PlayerArmorChangeEvent.SlotType slotType) {
|
||||
return switch (slotType) {
|
||||
case HEAD -> CosmeticSlot.HELMET;
|
||||
|
||||
Reference in New Issue
Block a user