Add support for color gradients and sizes in particle configurations
Enhanced `ParticleConfig` to handle color gradients and sizes for particles with `DustOptions` and `DustTransition`. Updated `ParticleInfo` to include `colorGradientEnd` and `size` properties. Refactored particle data handling for improved flexibility.
This commit is contained in:
parent
481cb007bf
commit
8aa22a3e7a
|
|
@ -37,6 +37,7 @@ public class ParticleConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all files in particles directory that are valid .json files
|
* Finds all files in particles directory that are valid .json files
|
||||||
|
*
|
||||||
* @return all files found
|
* @return all files found
|
||||||
*/
|
*/
|
||||||
private List<File> getJsonFiles() {
|
private List<File> getJsonFiles() {
|
||||||
|
|
@ -59,6 +60,7 @@ public class ParticleConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a ParticleData object to a ParticleSet
|
* Converts a ParticleData object to a ParticleSet
|
||||||
|
*
|
||||||
* @param particleData The ParticleData object to convert
|
* @param particleData The ParticleData object to convert
|
||||||
* @return A ParticleSet created from the ParticleData
|
* @return A ParticleSet created from the ParticleData
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,24 +80,33 @@ public class ParticleConfig {
|
||||||
double z = particleInfo.getZ();
|
double z = particleInfo.getZ();
|
||||||
|
|
||||||
ParticleBuilder particleBuilder = new ParticleBuilder(particleType);
|
ParticleBuilder particleBuilder = new ParticleBuilder(particleType);
|
||||||
|
Class<?> dataType = particleType.getDataType();
|
||||||
|
|
||||||
// Handle different particle data types
|
// Handle different particle data types
|
||||||
if (particleType.getDataType().equals(Particle.DustOptions.class) && particleInfo.getColor() != null) {
|
if ((dataType.equals(Particle.DustOptions.class)
|
||||||
int rgb = HexFormat.fromHexDigits(particleInfo.getColor());
|
|| dataType.equals(Particle.DustTransition.class))) {
|
||||||
particleBuilder.data(new Particle.DustOptions(Color.fromRGB(rgb), 1));
|
if (particleInfo.getColor() != null) {
|
||||||
}
|
if (particleInfo.getColorGradientEnd() != null) {
|
||||||
// else if (particleType.getDataType().equals(MaterialData.class)) {
|
particleBuilder.colorTransition(getColor(particleInfo.getColor()),
|
||||||
// //TODO implement
|
getColor(particleInfo.getColorGradientEnd()),
|
||||||
// }
|
particleInfo.getSize());
|
||||||
else if (particleType.getDataType().equals(BlockData.class)) {
|
} else {
|
||||||
|
particleBuilder.color(getColor(particleInfo.getColor()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (dataType.equals(Color.class)) {
|
||||||
|
particleBuilder.color(getColor(particleInfo.getColor()));
|
||||||
|
} else if (dataType.equals(BlockData.class)) {
|
||||||
|
particleBuilder.data(Material.STONE.createBlockData());
|
||||||
//TODO implement
|
//TODO implement
|
||||||
} else if (particleType.getDataType().equals(Integer.class)) {
|
} else if (dataType.equals(Integer.class)) {
|
||||||
|
particleBuilder.data(1);
|
||||||
//TODO implement
|
//TODO implement
|
||||||
} else if (particleType.getDataType().equals(Float.class)) {
|
} else if (dataType.equals(Float.class)) {
|
||||||
|
particleBuilder.data(1f);
|
||||||
//TODO implement
|
//TODO implement
|
||||||
} else if (particleType.getDataType().equals(Particle.DustTransition.class)) {
|
} else if (dataType.equals(ItemStack.class)) {
|
||||||
//TODO implement
|
particleBuilder.data(new ItemStack(Material.STONE));
|
||||||
} else if (particleType.getDataType().equals(ItemStack.class)) {
|
|
||||||
//TODO implement
|
//TODO implement
|
||||||
} else if (particleInfo.getExtra() != null) {
|
} else if (particleInfo.getExtra() != null) {
|
||||||
particleBuilder.extra(particleInfo.getExtra());
|
particleBuilder.extra(particleInfo.getExtra());
|
||||||
|
|
@ -110,21 +121,30 @@ public class ParticleConfig {
|
||||||
// Create and return the ParticleSet
|
// Create and return the ParticleSet
|
||||||
ItemStack displayItem = new ItemStack(Material.valueOf(particleData.getDisplayItem()));
|
ItemStack displayItem = new ItemStack(Material.valueOf(particleData.getDisplayItem()));
|
||||||
return new ParticleSet(
|
return new ParticleSet(
|
||||||
loadedFrames,
|
loadedFrames,
|
||||||
particleData.getDisplayName(),
|
particleData.getDisplayName(),
|
||||||
List.of(particleData.getLore().split("\n")),
|
List.of(particleData.getLore().split("\n")),
|
||||||
particleData.getFrameDelay(),
|
particleData.getFrameDelay(),
|
||||||
particleData.getRepeat(),
|
particleData.getRepeat(),
|
||||||
particleData.getRepeatDelay(),
|
particleData.getRepeatDelay(),
|
||||||
particleData.isStationary(),
|
particleData.isStationary(),
|
||||||
particleData.getAPartType(),
|
particleData.getAPartType(),
|
||||||
particleData.getParticleName(),
|
particleData.getParticleName(),
|
||||||
particleData.getPermission(),
|
particleData.getPermission(),
|
||||||
particleData.getPackagePermission(),
|
particleData.getPackagePermission(),
|
||||||
displayItem
|
displayItem
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Color getColor(String hexColor) {
|
||||||
|
int color = HexFormat.fromHexDigits(hexColor);
|
||||||
|
if (hexColor.length() == 6) {
|
||||||
|
return Color.fromARGB(color);
|
||||||
|
} else {
|
||||||
|
return Color.fromRGB(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
ParticleStorage.clear();
|
ParticleStorage.clear();
|
||||||
ParticleConfig instance = getInstance();
|
ParticleConfig instance = getInstance();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ public class ParticleInfo {
|
||||||
|
|
||||||
// For DustOptions
|
// For DustOptions
|
||||||
private String color;
|
private String color;
|
||||||
|
@JsonProperty("color_gradient_end")
|
||||||
|
private String colorGradientEnd;
|
||||||
|
// For DustOptions
|
||||||
|
|
||||||
|
@JsonProperty(value = "size", defaultValue = "1")
|
||||||
|
private int size;
|
||||||
|
|
||||||
// For other particle types
|
// For other particle types
|
||||||
private Double extra;
|
private Double extra;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user