9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 12:29:16 +00:00

more refactoring

This commit is contained in:
LoJoSho
2023-02-07 15:04:17 -06:00
parent 6ba078dcc4
commit 89825659a6
3 changed files with 32 additions and 29 deletions

View File

@@ -48,11 +48,11 @@ public class CosmeticBalloonType extends Cosmetic {
@Override
public void update(CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId());
UserBalloonManager userBalloonManager = user.getBalloonEntity();
UserBalloonManager userBalloonManager = user.getBalloonManager();
Location newLocation = player.getLocation();
if (player == null || userBalloonManager == null || newLocation == null) return;
if (user.isInWardrobe()) return;
Location currentLocation = user.getBalloonEntity().getLocation();
Location currentLocation = user.getBalloonManager().getLocation();
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
List<Player> viewer = PacketManager.getViewers(player.getLocation());

View File

@@ -80,9 +80,6 @@ public class CosmeticUser {
public Collection<Cosmetic> getCosmetic() {
return playerCosmetics.values();
}
public UserBalloonManager getBalloonEntity() {
return this.userBalloonManager;
}
public void addPlayerCosmetic(Cosmetic cosmetic) {
addPlayerCosmetic(cosmetic, null);
@@ -206,6 +203,18 @@ public class CosmeticUser {
return item;
}
public UserBackpackManager getUserBackpackManager() {
return userBackpackManager;
}
public UserBalloonManager getBalloonManager() {
return this.userBalloonManager;
}
public UserWardrobeManager getWardrobeManager() {
return userWardrobeManager;
}
public void enterWardrobe() {
enterWardrobe(false);
}
@@ -231,19 +240,15 @@ public class CosmeticUser {
}
}
public UserWardrobeManager getWardrobe() {
return userWardrobeManager;
}
public void leaveWardrobe() {
PlayerWardrobeLeaveEvent event = new PlayerWardrobeLeaveEvent(this);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
if (!getWardrobe().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
getWardrobe().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
if (WardrobeSettings.isEnabledTransition()) {
MessagesUtil.sendTitle(
@@ -284,9 +289,7 @@ public class CosmeticUser {
userBackpackManager = null;
}
public UserBackpackManager getUserBackpackManager() {
return userBackpackManager;
}
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
Player player = Bukkit.getPlayer(getUniqueId());
@@ -298,7 +301,7 @@ public class CosmeticUser {
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
viewer.add(player);
PacketManager.sendLeashPacket(getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
}
public void despawnBalloon() {
@@ -382,9 +385,9 @@ public class CosmeticUser {
hideCosmetics = true;
hiddenReason = reason;
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
getBalloonEntity().removePlayerFromModel(getPlayer());
getBalloonManager().removePlayerFromModel(getPlayer());
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
PacketManager.sendLeashPacket(getBalloonEntity().getPufferfishBalloonId(), -1, viewer);
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
}
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
userBackpackManager.getArmorstand().getEquipment().clear();
@@ -406,9 +409,9 @@ public class CosmeticUser {
hiddenReason = HiddenReason.NONE;
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
getBalloonEntity().addPlayerToModel(this, balloonType);
getBalloonManager().addPlayerToModel(this, balloonType);
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
PacketManager.sendLeashPacket(getBalloonEntity().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
}
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);

View File

@@ -118,12 +118,12 @@ public class UserWardrobeManager {
}
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), -1, viewer);
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
PacketManager.sendLeashPacket(VIEWER.getBalloonManager().getPufferfishBalloonId(), -1, viewer);
PacketManager.sendLeashPacket(VIEWER.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
PacketManager.sendTeleportPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
VIEWER.getBalloonEntity().getModelEntity().teleport(npcLocation.clone().add(Settings.getBalloonOffset()));
PacketManager.sendTeleportPacket(VIEWER.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
VIEWER.getBalloonManager().getModelEntity().teleport(npcLocation.clone().add(Settings.getBalloonOffset()));
}
if (WardrobeSettings.getEnabledBossbar()) {
@@ -171,7 +171,7 @@ public class UserWardrobeManager {
this.active = false;
// NPC
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), -1, viewer);
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) PacketManager.sendLeashPacket(VIEWER.getBalloonManager().getModelId(), -1, viewer);
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
@@ -257,11 +257,11 @@ public class UserWardrobeManager {
}
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendTeleportPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
VIEWER.getBalloonEntity().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), -1, outsideViewers);
PacketManager.sendEntityDestroyPacket(VIEWER.getBalloonEntity().getModelId(), outsideViewers);
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
PacketManager.sendTeleportPacket(VIEWER.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
VIEWER.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
PacketManager.sendLeashPacket(VIEWER.getBalloonManager().getPufferfishBalloonId(), -1, outsideViewers);
PacketManager.sendEntityDestroyPacket(VIEWER.getBalloonManager().getModelId(), outsideViewers);
PacketManager.sendLeashPacket(VIEWER.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
}
if (WardrobeSettings.isEquipPumpkin()) {