Skip to content

Commit

Permalink
Simplify particle shape definition's prefab constants
Browse files Browse the repository at this point in the history
  • Loading branch information
2008Choco committed May 31, 2020
1 parent 19b9a8a commit bd9ef9c
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

import org.apache.commons.lang.Validate;
import org.bukkit.Location;
Expand Down Expand Up @@ -93,25 +92,26 @@ public enum Prefab {
* x = x
* z = z
*/
BALL(location -> new ParticleShapeDefinition(location, "x", "z")),
BALL("x", "z"),

/**
* x = cos(theta) * 1.2
* z = sin(theta) * 1.2
*/
HELIX(location -> new ParticleShapeDefinition(location, "cos(theta) * 1.2", "sin(theta) * 1.2")),
HELIX("cos(theta) * 1.2", "sin(theta) * 1.2"),

/**
* x = cos(theta) * (100 / t)
* z = sin(theta) * (100 / t)
*/
OPEN_END_HELIX(location -> new ParticleShapeDefinition(location, "cos(theta) * (100 / t)", "sin(theta) * (100 / t)"));
OPEN_END_HELIX("cos(theta) * (100 / t)", "sin(theta) * (100 / t)");


private final Function<Location, ParticleShapeDefinition> fabricator;
private final String xExpression, zExpression;

private Prefab(Function<Location, ParticleShapeDefinition> fabricator) {
this.fabricator = fabricator;
private Prefab(String xExpression, String zExpression) {
this.xExpression = xExpression;
this.zExpression = zExpression;
}

/**
Expand All @@ -123,7 +123,7 @@ private Prefab(Function<Location, ParticleShapeDefinition> fabricator) {
* @return the created prefab
*/
public ParticleShapeDefinition create(Location location) {
return fabricator.apply(location);
return new ParticleShapeDefinition(location, xExpression, zExpression);
}

}
Expand Down

0 comments on commit bd9ef9c

Please sign in to comment.