Skip to content

Commit db2a0e5

Browse files
Prevent exceptions when using experimental syntax in effect commands (#7996)
1 parent ecc0002 commit db2a0e5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/ch/njol/skript/lang/parser/ParserInstance.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,12 @@ public void removeExperiment(Experiment experiment) {
518518
* This is safe to retain during runtime (e.g. to defer a check) but will
519519
* not see changes, such as if a script subsequently 'uses' another experiment.
520520
*
521-
* @return A snapshot of the current experiment flags in use
521+
* @return A snapshot of the current experiment flags in use,
522+
* or an empty experiment set if not {@link #isActive()}.
522523
*/
523524
public Experimented experimentSnapshot() {
525+
if (!this.isActive())
526+
return new ExperimentSet();
524527
Script script = this.getCurrentScript();
525528
@Nullable ExperimentSet set = script.getData(ExperimentSet.class);
526529
if (set == null)
@@ -530,8 +533,12 @@ public Experimented experimentSnapshot() {
530533

531534
/**
532535
* Get the {@link ExperimentSet} of the current {@link Script}
536+
* @return Experiment set of {@link #getCurrentScript()},
537+
* or an empty experiment set if not {@link #isActive()}.
533538
*/
534539
public ExperimentSet getExperimentSet() {
540+
if (!this.isActive())
541+
return new ExperimentSet();
535542
Script script = this.getCurrentScript();
536543
ExperimentSet set = script.getData(ExperimentSet.class);
537544
if (set == null)

0 commit comments

Comments
 (0)