9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-27 10:59:14 +00:00

fix: Leads not properly disappearing teleporting into WG region with hidden cosmetics

This commit is contained in:
LoJoSho
2023-07-08 11:40:08 -05:00
parent d2962ba5ed
commit f2b0fb29d3
9 changed files with 19 additions and 44 deletions

View File

@@ -73,6 +73,10 @@ public class CosmeticBalloonType extends Cosmetic {
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
if (user.getHidden()) {
userBalloonManager.getPufferfish().hidePufferfish();
return;
}
if (!user.getHidden() && showLead) {
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
if (sendTo.isEmpty()) return;

View File

@@ -114,22 +114,17 @@ public class PlayerGameListener implements Listener {
return;
}
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
user.respawnBackpack();
user.updateCosmetic();
}, 1);
}
}
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
user.respawnBalloon();
}
user.updateCosmetic();
}, 1);
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
final CosmeticBalloonType cosmeticBalloonType = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
user.despawnBalloon();
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
user.spawnBalloon(cosmeticBalloonType);
}, 2);
}
if (user.getUserEmoteManager().isPlayingEmote()) {
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
}

View File

@@ -365,6 +365,7 @@ public class CosmeticUser {
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
if (this.userBalloonManager != null) return;
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
updateCosmetic(cosmeticBalloonType);
}
public void despawnBalloon() {

View File

@@ -20,7 +20,7 @@ public class UserBalloonPufferfish {
public UserBalloonPufferfish(int id, UUID uuid) {
this.id = id;
this.uuid = uuid;
this.lastUpdate = System.currentTimeMillis();
this.lastUpdate = 0L;
}
public int getId() {
@@ -55,4 +55,9 @@ public class UserBalloonPufferfish {
lastUpdate = System.currentTimeMillis();
return newPlayers;
}
public void hidePufferfish() {
PacketManager.sendEntityDestroyPacket(id, viewers);
viewers.clear();
}
}