mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
feat: Option to make lead invisible for balloons, resolves #95
This commit is contained in:
@@ -19,12 +19,15 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
private final String modelName;
|
||||
private List<String> dyableParts;
|
||||
private boolean showLead;
|
||||
|
||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
String modelId = config.node("model").getString();
|
||||
|
||||
showLead = config.node("show-lead").getBoolean(true);
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) {
|
||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
@@ -68,7 +71,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
userBalloonManager.setLocation(newLocation);
|
||||
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
if (!user.getHidden()) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
@@ -85,4 +88,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
if (dyableParts.isEmpty()) return true;
|
||||
return dyableParts.contains(name);
|
||||
}
|
||||
|
||||
public boolean isShowLead() {
|
||||
return showLead;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,8 +322,6 @@ public class CosmeticUser {
|
||||
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
||||
viewer.add(player);
|
||||
|
||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
public void despawnBalloon() {
|
||||
@@ -408,8 +406,7 @@ public class CosmeticUser {
|
||||
hiddenReason = reason;
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
|
||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
||||
getBalloonManager().sendRemoveLeashPacket();
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
userBackpackManager.clearItems();
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
@@ -17,12 +19,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class UserBalloonManager {
|
||||
|
||||
private BalloonType balloonType;
|
||||
private CosmeticBalloonType cosmeticBalloonType;
|
||||
private final int balloonID;
|
||||
private final UUID uniqueID;
|
||||
private final ArmorStand modelEntity;
|
||||
@@ -44,6 +48,7 @@ public class UserBalloonManager {
|
||||
balloonType = BalloonType.NONE;
|
||||
}
|
||||
}
|
||||
this.cosmeticBalloonType = cosmeticBalloonType;
|
||||
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
|
||||
|
||||
if (balloonType == BalloonType.MODELENGINE) {
|
||||
@@ -85,6 +90,7 @@ public class UserBalloonManager {
|
||||
}
|
||||
|
||||
modelEntity.remove();
|
||||
cosmeticBalloonType = null;
|
||||
}
|
||||
|
||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||
@@ -156,6 +162,19 @@ public class UserBalloonManager {
|
||||
this.getModelEntity().setVelocity(vector);
|
||||
}
|
||||
|
||||
public void sendRemoveLeashPacket(List<Player> viewer) {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
||||
}
|
||||
|
||||
public void sendRemoveLeashPacket() {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
||||
}
|
||||
|
||||
public void sendLeashPacket(int entityId) {
|
||||
if (cosmeticBalloonType == null) return;
|
||||
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||
}
|
||||
|
||||
public enum BalloonType {
|
||||
MODELENGINE,
|
||||
ITEM,
|
||||
|
||||
@@ -109,8 +109,8 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
||||
@@ -162,7 +162,7 @@ public class UserWardrobeManager {
|
||||
this.active = false;
|
||||
|
||||
// NPC
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) PacketManager.sendLeashPacket(user.getBalloonManager().getModelId(), -1, viewer);
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||
|
||||
@@ -254,9 +254,9 @@ public class UserWardrobeManager {
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, outsideViewers);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
|
||||
@@ -113,7 +113,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user