Skip to content

Commit

Permalink
Update EffChange.java (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
TPGamesNL authored May 4, 2021
1 parent 9884fb1 commit 024c2f6
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/main/java/ch/njol/skript/effects/EffChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,17 @@ else if (mode == ChangeMode.SET)
}

@Override
protected void execute(final Event e) {
final Expression<?> changer = this.changer;
protected void execute(Event e) {
Expression<?> changer = this.changer;
Object[] delta = changer == null ? null : changer.getArray(e);
delta = changer == null ? delta : changer.beforeChange(changed, delta);
if (delta != null && delta.length == 0)
return;
if (delta == null && (mode != ChangeMode.DELETE && mode != ChangeMode.RESET))

if ((delta == null || delta.length == 0) && (mode != ChangeMode.DELETE && mode != ChangeMode.RESET)) {
if (changed.acceptChange(ChangeMode.DELETE) != null)
changed.change(e, null, ChangeMode.DELETE);
return;
changed.change(e, delta, mode); // Trigger beforeChanged hook
// REMIND use a random element out of delta if changed only supports changing a single instance
// changed.change(e, new Changer2<Object>() {
// @Override
// public Object change(Object o) {
// return delta;
// }
// }, mode);
}
changed.change(e, delta, mode);
}

@Override
Expand Down

0 comments on commit 024c2f6

Please sign in to comment.