Skip to content

Commit 8ba1287

Browse files
committed
remove deprecated code use
1 parent 3fcebf6 commit 8ba1287

3 files changed

Lines changed: 9 additions & 24 deletions

File tree

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import ch.njol.skript.lang.parser.ParserInstance;
1212
import ch.njol.skript.registrations.EventValues;
1313
import ch.njol.skript.util.Direction;
14-
import ch.njol.skript.util.Getter;
1514
import ch.njol.skript.util.Timespan;
1615
import ch.njol.skript.util.Timespan.TimePeriod;
1716
import ch.njol.skript.variables.Variables;
@@ -40,12 +39,7 @@ public abstract class DrawShapeEffectSection extends EffectSection {
4039
public static final Timespan ONE_TICK = new Timespan(TimePeriod.TICK, 1);
4140

4241
static {
43-
EventValues.registerEventValue(DrawEvent.class, Shape.class, new Getter<Shape, DrawEvent>() {
44-
@Override
45-
public Shape get(DrawEvent drawEvent) {
46-
return drawEvent.getShape();
47-
}
48-
}, EventValues.TIME_NOW);
42+
EventValues.registerEventValue(DrawEvent.class, Shape.class, DrawEvent::getShape, EventValues.TIME_NOW);
4943
}
5044

5145
protected Expression<Shape> shapes;
@@ -82,7 +76,7 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
8276
AtomicBoolean delayed = new AtomicBoolean(false);
8377
Runnable afterLoading = () -> delayed.set(!getParser().getHasDelayBefore().isFalse());
8478
assert sectionNode != null;
85-
trigger = loadCode(sectionNode, "draw", afterLoading, DrawEvent.class);
79+
trigger = loadCode(sectionNode, "draw", null, afterLoading, DrawEvent.class);
8680
if (delayed.get()) {
8781
Skript.error("Delays can't be used within a Draw Shape Effect Section");
8882
return false;
@@ -144,10 +138,7 @@ protected TriggerItem walk(Event event) {
144138
if (trigger != null) {
145139
consumer = shape -> {
146140
DrawEvent drawEvent = new DrawEvent(shape);
147-
Variables.setLocalVariables(drawEvent, localVars);
148-
TriggerItem.walk(trigger, drawEvent);
149-
Variables.setLocalVariables(event, Variables.copyLocalVariables(drawEvent));
150-
Variables.removeLocals(drawEvent);
141+
Variables.withLocalVariables(event, drawEvent, () -> TriggerItem.walk(trigger, drawEvent));
151142
};
152143
} else {
153144
consumer = null;
@@ -216,11 +207,9 @@ protected void executeSync(Event event, Collection<DynamicLocation> locations, @
216207
for (DynamicLocation dynamicLocation : locations) {
217208
for (Shape shape : shapes.getArray(event)) {
218209
if (consumer != null) {
219-
// copy the shape so that it can be modified by the consumer without affecting the original
220-
shapeCopy = shape.clone();
221-
shapeCopy.draw(dynamicLocation, consumer, recipients);
210+
shape.clone().draw(dynamicLocation, consumer, recipients);
222211
} else {
223-
shape.draw(dynamicLocation, recipients);
212+
shape.clone().draw(dynamicLocation, recipients);
224213
}
225214
}
226215
}
@@ -237,7 +226,7 @@ protected void executeAsync(Collection<DynamicLocation> locations, Collection<Sh
237226
try {
238227
for (DynamicLocation dynamicLocation : locations) {
239228
for (Shape shape : shapes) {
240-
shape.draw(dynamicLocation, recipients);
229+
shape.clone().draw(dynamicLocation, recipients);
241230
}
242231
}
243232
} catch (IllegalArgumentException exception) {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import ch.njol.skript.lang.Expression;
99
import ch.njol.skript.lang.SkriptParser.ParseResult;
1010
import ch.njol.skript.registrations.EventValues;
11-
import ch.njol.skript.util.Getter;
1211
import ch.njol.skript.util.Timespan;
1312
import ch.njol.skript.util.Timespan.TimePeriod;
1413
import ch.njol.util.Kleenean;
@@ -59,12 +58,7 @@ public class EffSecDrawShape extends DrawShapeEffectSection {
5958
"[sync:sync[hronously]] draw [the] shape[s] [of] %shapes% [%-directions% %-locations/entities%] [to %-players%]",
6059
"draw [the] shape[s] [of] %shapes% [%-directions% %-locations/entities%] [to %-players%] (duration:for) [duration] %timespan% [with (delay|refresh [rate]) [of] %-timespan%]"
6160
);
62-
EventValues.registerEventValue(EffSecDrawShape.DrawEvent.class, Shape.class, new Getter<Shape, DrawEvent>() {
63-
@Override
64-
public Shape get(DrawEvent drawEvent) {
65-
return drawEvent.getShape();
66-
}
67-
}, EventValues.TIME_NOW);
61+
EventValues.registerEventValue(EffSecDrawShape.DrawEvent.class, Shape.class, DrawEvent::getShape, EventValues.TIME_NOW);
6862
}
6963

7064
@Nullable

src/main/java/com/sovdee/skriptparticles/shapes/AbstractShape.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ public Shape copyTo(Shape shape) {
366366
shape.setStyle(this.style);
367367
shape.showLocalAxes(this.drawLocalAxes);
368368
shape.showGlobalAxes(this.drawGlobalAxes);
369+
shape.setAnimationDuration(this.animationDuration);
370+
shape.setOrdering(this.ordering);
369371
// ensure that the shape's points are updated, so we don't have to recalculate them unless we change the copy.
370372
shape.setPoints(this.getPoints());
371373
shape.setNeedsUpdate(this.needsUpdate);

0 commit comments

Comments
 (0)