mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-30 04:19:28 +00:00
feat: per-balloon cosmetic offsets
This commit is contained in:
@@ -176,7 +176,6 @@ public class Settings {
|
||||
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
|
||||
|
||||
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
||||
|
||||
balloonOffset = loadVector(balloonSection);
|
||||
|
||||
ConfigurationNode dyeMenuSettings = source.node(DYE_MENU_PATH);
|
||||
@@ -198,7 +197,7 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector loadVector(final ConfigurationNode config) {
|
||||
public static Vector loadVector(final ConfigurationNode config) {
|
||||
return new Vector(config.node("x").getDouble(), config.node("y").getDouble(), config.node("z").getDouble());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -19,17 +20,27 @@ import java.util.List;
|
||||
|
||||
public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
@Getter
|
||||
private final String modelName;
|
||||
@Getter
|
||||
private List<String> dyableParts;
|
||||
@Getter
|
||||
private final boolean showLead;
|
||||
@Getter
|
||||
private Vector balloonOffset;
|
||||
|
||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
String modelId = config.node("model").getString();
|
||||
|
||||
showLead = config.node("show-lead").getBoolean(true);
|
||||
|
||||
ConfigurationNode balloonOffsetNode = config.node("balloon-offset");
|
||||
if (balloonOffsetNode.virtual())
|
||||
balloonOffset = Settings.getBalloonOffset();
|
||||
else
|
||||
balloonOffset = Settings.loadVector(balloonOffsetNode);
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) {
|
||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
@@ -57,7 +68,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
Location newLocation = entity.getLocation();
|
||||
Location currentLocation = user.getBalloonManager().getLocation();
|
||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||
newLocation = newLocation.clone().add(getBalloonOffset());
|
||||
|
||||
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
|
||||
|
||||
@@ -85,22 +96,10 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
}
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return this.modelName;
|
||||
}
|
||||
|
||||
public List<String> getDyableParts() {
|
||||
return dyableParts;
|
||||
}
|
||||
|
||||
public boolean isDyablePart(String name) {
|
||||
// If player does not define parts, dye whole model
|
||||
if (dyableParts == null) return true;
|
||||
if (dyableParts.isEmpty()) return true;
|
||||
return dyableParts.contains(name);
|
||||
}
|
||||
|
||||
public boolean isShowLead() {
|
||||
return showLead;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,9 +339,10 @@ public class PlayerGameListener implements Listener {
|
||||
CosmeticUser user = event.getUser();
|
||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
||||
// We know that no other entity besides a regular player will be in the wardrobe
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(Settings.getBalloonOffset()), false, List.of(user.getPlayer()));
|
||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(Settings.getBalloonOffset()));
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(cosmetic.getBalloonOffset()), false, List.of(user.getPlayer()));
|
||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(cosmetic.getBalloonOffset()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ 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;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
@@ -27,6 +28,7 @@ public class UserBalloonManager {
|
||||
|
||||
private BalloonType balloonType;
|
||||
private CosmeticBalloonType cosmeticBalloonType;
|
||||
@Getter
|
||||
private UserBalloonPufferfish pufferfish;
|
||||
private final ArmorStand modelEntity;
|
||||
|
||||
@@ -175,10 +177,6 @@ public class UserBalloonManager {
|
||||
}
|
||||
}
|
||||
|
||||
public UserBalloonPufferfish getPufferfish() {
|
||||
return pufferfish;
|
||||
}
|
||||
|
||||
public enum BalloonType {
|
||||
MODELENGINE,
|
||||
ITEM,
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
@@ -122,11 +123,12 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
|
||||
Location balloonLocation = npcLocation.clone().add(Settings.getBalloonOffset());
|
||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user