mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-31 12:56:39 +00:00
Add dyable parts to balloons
This commit is contained in:
@@ -5,22 +5,45 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.entities.BalloonEntity;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
private String modelName;
|
||||
private List<String> dyableParts;
|
||||
//private HashMap<Animations, String> animationBalloons;
|
||||
|
||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
String modelId = config.node("model").getString();
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
|
||||
/*
|
||||
if (!config.node("animations").virtual()) {
|
||||
for (ConfigurationNode animationNode : config.node("animations").childrenMap().values()) {
|
||||
if (EnumUtils.isValidEnum(Animations.class, animationNode.key().toString().toUpperCase())) continue;
|
||||
animationBalloons.put(Animations.valueOf(animationNode.key().toString().toUpperCase()), animationNode.getString());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
} catch (SerializationException e) {
|
||||
// Seriously?
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
this.modelName = modelId;
|
||||
}
|
||||
|
||||
@@ -54,4 +77,18 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
public String getModelName() {
|
||||
return this.modelName;
|
||||
}
|
||||
|
||||
public List<String> getDyableParts() {
|
||||
return dyableParts;
|
||||
}
|
||||
|
||||
public boolean isDyablePart(String name) {
|
||||
return dyableParts.contains(name);
|
||||
}
|
||||
|
||||
/*
|
||||
public String getAnimation(Animations animation) {
|
||||
return animationBalloons.get(animation);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -57,11 +56,15 @@ public class BalloonEntity {
|
||||
modeledEntity.addModel(model, false);
|
||||
if (color != null) {
|
||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||
singleModel.getRendererHandler().setColor(color);
|
||||
singleModel.getRendererHandler().update();
|
||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||
singleModel.getRendererHandler().setColor(color);
|
||||
singleModel.getRendererHandler().update();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (balloonType == BalloonType.ITEM) {
|
||||
modelEntity.getEquipment().setHelmet(cosmeticBalloonType.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user