Skip to content

Commit 29270d6

Browse files
committed
better coding practices
1 parent 37c4a9b commit 29270d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1404
-838
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ processResources {
3939
}
4040
}
4141

42+
javadoc {
43+
source = sourceSets.main.allJava
44+
classpath = configurations.compileClasspath
45+
options.encoding = 'UTF-8'
46+
}
47+
4248
task shadowJar(overwrite: true, type: ShadowJar) {
4349
archiveFileName = 'skript-particle.jar'
4450
}

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@if "%DEBUG%" == "" @echo off
1818
@rem ##########################################################################
1919
@rem
20-
@rem Gradle startup script for Windows
20+
@rem Gradle startup script for Windows
2121
@rem
2222
@rem ##########################################################################
2323

@@ -80,7 +80,7 @@ if "%ERRORLEVEL%"=="0" goto mainEnd
8080
:fail
8181
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8282
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
83+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
8484
exit /b 1
8585

8686
:mainEnd

src/main/java/com/sovdee/skriptparticles/elements/expressions/ExprRotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ public String toString(@Nullable Event e, boolean debug) {
9090
return "rotation around " + axis.toString(e, debug) + " by " + angle.toString(e, debug) + (isRadians ? " radians" : " degrees");
9191
}
9292

93-
}
93+
}

src/main/java/com/sovdee/skriptparticles/elements/expressions/ExprShapeCopy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import ch.njol.util.Kleenean;
1313
import com.sovdee.skriptparticles.shapes.Shape;
1414
import org.bukkit.event.Event;
15-
import org.jetbrains.annotations.NotNull;
15+
import org.checkerframework.checker.nullness.qual.NonNull;
1616
import org.jetbrains.annotations.Nullable;
1717

1818
import java.util.ArrayList;
@@ -40,7 +40,7 @@ public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, Parse
4040
}
4141

4242
@Override
43-
protected Shape[] get(@NotNull Event event) {
43+
protected Shape[] get(@NonNull Event event) {
4444
Shape[] shape = shapeExpr.getArray(event);
4545

4646
if (shape.length == 0)

src/main/java/com/sovdee/skriptparticles/elements/expressions/constructors/ExprArc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ public String toString(@Nullable Event event, boolean debug) {
118118
(isRadians ? " radians " : " degrees ");
119119
}
120120

121-
}
121+
}

src/main/java/com/sovdee/skriptparticles/elements/expressions/constructors/ExprCircle.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.sovdee.skriptparticles.shapes.Shape;
1616
import com.sovdee.skriptparticles.util.MathUtil;
1717
import org.bukkit.event.Event;
18-
import org.jetbrains.annotations.NotNull;
18+
import org.checkerframework.checker.nullness.qual.NonNull;
1919
import org.jetbrains.annotations.Nullable;
2020

2121
@Name("Particle Circle or Cylinder")
@@ -42,7 +42,7 @@ public class ExprCircle extends SimpleExpression<Circle> {
4242
private boolean isCylinder;
4343

4444
@Override
45-
public boolean init(Expression<?>[] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
45+
public boolean init(Expression<?>[] exprs, int matchedPattern, @NonNull Kleenean isDelayed, @NonNull ParseResult parseResult) {
4646
isCylinder = matchedPattern == 1;
4747

4848
radius = (Expression<Number>) exprs[0];
@@ -73,7 +73,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, @NotNull Kleenean
7373

7474
@Override
7575
@Nullable
76-
protected Circle[] get(@NotNull Event event) {
76+
protected Circle[] get(@NonNull Event event) {
7777
Number radius = this.radius.getSingle(event);
7878
Number height = this.height != null ? this.height.getSingle(event) : 0;
7979
if (radius == null || height == null)
@@ -93,13 +93,13 @@ public boolean isSingle() {
9393
}
9494

9595
@Override
96-
@NotNull
96+
@NonNull
9797
public Class<? extends Circle> getReturnType() {
9898
return Circle.class;
9999
}
100100

101101
@Override
102-
@NotNull
102+
@NonNull
103103
public String toString(@Nullable Event event, boolean debug) {
104104
return (isCylinder ? "circle of radius " + radius.toString(event, debug) :
105105
"cylinder of radius " + radius.toString(event, debug) + " and height " + (height != null ? height.toString(event, debug) : "0"));

src/main/java/com/sovdee/skriptparticles/elements/expressions/constructors/ExprEllipsoid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5757
}
5858

5959
if (yRadius instanceof Literal<Number> literal && literal.getSingle().doubleValue() <= 0) {
60-
Skript.error("The y radius of the ellipsoid must be greater than 0. (y radius: " +
60+
Skript.error("The y radius of the ellipsoid must be greater than 0. (y radius: " +
6161
literal.getSingle().doubleValue() + ")");
6262
return false;
6363
}

src/main/java/com/sovdee/skriptparticles/elements/expressions/properties/ExprShapeLocations.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.sovdee.skriptparticles.shapes.Shape;
1414
import org.bukkit.Location;
1515
import org.bukkit.event.Event;
16-
import org.jetbrains.annotations.NotNull;
16+
import org.checkerframework.checker.nullness.qual.NonNull;
1717
import org.jetbrains.annotations.Nullable;
1818

1919
import java.util.ArrayList;
@@ -50,7 +50,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5050

5151
@Override
5252
@Nullable
53-
protected Location[] get(@NotNull Event event) {
53+
protected Location[] get(@NonNull Event event) {
5454
Shape[] shapes = shapeExpr.getAll(event);
5555
if (shapes.length == 0) return null;
5656

@@ -71,12 +71,12 @@ public boolean isSingle() {
7171
}
7272

7373
@Override
74-
public @NotNull Class<? extends Location> getReturnType() {
74+
public @NonNull Class<? extends Location> getReturnType() {
7575
return Location.class;
7676
}
7777

7878
@Override
79-
public @NotNull String toString(@Nullable Event event, boolean debug) {
79+
public @NonNull String toString(@Nullable Event event, boolean debug) {
8080
return "Locations of shapes";
8181
}
8282

src/main/java/com/sovdee/skriptparticles/elements/expressions/properties/ExprShapeParticleDensity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ public class ExprShapeParticleDensity extends SimplePropertyExpression<Shape, Nu
4444
PropertyExpression.register(ExprShapeParticleDensity.class, Number.class, "particle (:density|:count)", "shapes");
4545
}
4646

47-
private boolean flag;
47+
private boolean isDensity;
4848

4949
@Override
5050
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
51-
flag = parseResult.hasTag("density");
51+
isDensity = parseResult.hasTag("density");
5252
return super.init(exprs, matchedPattern, isDelayed, parseResult);
5353
}
5454

5555
@Override
5656
public @Nullable Number convert(Shape shape) {
57-
if (flag)
57+
if (isDensity)
5858
return 1 / shape.getParticleDensity();
5959
else
6060
return shape.getParticleCount();
@@ -82,7 +82,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
8282
change = -change;
8383
case ADD:
8484
for (Shape shape : shapes) {
85-
if (flag) {
85+
if (isDensity) {
8686
// clamp to 0.001 and 1000, enough to kill the client but not enough to cause an actual error
8787
shape.setParticleDensity(MathUtil.clamp(1 / (1 / shape.getParticleDensity() + change), 0.001, 1000));
8888
} else
@@ -93,9 +93,9 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
9393
case DELETE:
9494
case RESET:
9595
case SET:
96-
change = flag ? MathUtil.clamp(change, 0.001, 1000) : Math.max(1, (int) change);
96+
change = isDensity ? MathUtil.clamp(change, 0.001, 1000) : Math.max(1, (int) change);
9797
for (Shape shape : shapes) {
98-
if (flag) {
98+
if (isDensity) {
9999
shape.setParticleDensity(change);
100100
} else {
101101
shape.setParticleCount((int) change);
@@ -115,7 +115,7 @@ public Class<? extends Number> getReturnType() {
115115

116116
@Override
117117
protected String getPropertyName() {
118-
return "particle " + (flag ? "density" : "count");
118+
return "particle " + (isDensity ? "density" : "count");
119119
}
120120

121121
}

src/main/java/com/sovdee/skriptparticles/elements/sections/EffSecDrawShape.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.bukkit.event.HandlerList;
2929
import org.bukkit.scheduler.BukkitRunnable;
3030
import org.bukkit.util.Consumer;
31-
import org.jetbrains.annotations.NotNull;
31+
import org.checkerframework.checker.nullness.qual.NonNull;
3232
import org.jetbrains.annotations.Nullable;
3333

3434
import java.util.ArrayList;
@@ -228,7 +228,7 @@ private void executeSync(Event event, Collection<DynamicLocation> locations, Con
228228
shapeCopy = shape.clone();
229229
shapeCopy.draw(location, consumer, recipients);
230230
} else {
231-
shape.draw(location, null, null, recipients);
231+
shape.draw(location, recipients);
232232
}
233233
}
234234
}
@@ -239,13 +239,13 @@ private void executeAsync(Collection<DynamicLocation> locations, Collection<Shap
239239
for (DynamicLocation dynamicLocation : locations) {
240240
location = dynamicLocation.getLocation();
241241
for (Shape shape : shapes) {
242-
shape.draw(location, null, null, recipients);
242+
shape.draw(location, recipients);
243243
}
244244
}
245245
}
246246

247247
@Override
248-
@NotNull
248+
@NonNull
249249
public String toString(@Nullable Event event, boolean b) {
250250
return "draw shape " + shapes.toString(event, b) + " at " + locations.toString(event, b) + " for " + (players == null ? "all players" : players.toString(event, b));
251251
}
@@ -262,7 +262,7 @@ public Shape getShape() {
262262
}
263263

264264
@Override
265-
@NotNull
265+
@NonNull
266266
public HandlerList getHandlers() {
267267
throw new IllegalStateException();
268268
}

0 commit comments

Comments
 (0)