Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev/patch' into fix/docs-release…
Browse files Browse the repository at this point in the history
…-push
  • Loading branch information
AyhamAl-Ali committed Oct 10, 2023
2 parents 3f9c9d8 + 61201bd commit ce51b92
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,6 @@ gradle-app.setting
# TODO remove this in the future after some time since https://github.com/SkriptLang/Skript/pull/4979
# This ensures developers don't upload their old existing test_runners/ folder.
test_runners/

## Mac MetaData
**/.DS_Store
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ allprojects {
dependencies {
shadow group: 'io.papermc', name: 'paperlib', version: '1.0.8'
shadow group: 'org.bstats', name: 'bstats-bukkit', version: '3.0.2'
shadow group: 'net.kyori', name: 'adventure-text-serializer-bungeecord', version: '4.3.0'
shadow group: 'net.kyori', name: 'adventure-text-serializer-bungeecord', version: '4.3.1'

implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.20.2-R0.1-SNAPSHOT'
implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.700'
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ensure encoding is consistent across systems
org.gradle.jvmargs=-Dfile.encoding=UTF-8

groupid=ch.njol
name=skript
version=2.7.1
Expand Down
24 changes: 17 additions & 7 deletions src/main/java/ch/njol/skript/effects/EffScriptFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import java.io.File;
import java.io.IOException;
import java.util.Set;

@Name("Enable/Disable/Reload Script File")
@Description("Enables, disables, or reloads a script file.")
Expand Down Expand Up @@ -102,10 +103,8 @@ protected void execute(Event e) {
case RELOAD: {
if (ScriptLoader.getDisabledScriptsFilter().accept(scriptFile))
return;

Script script = ScriptLoader.getScript(scriptFile);
if (script != null)
ScriptLoader.unloadScript(script);

this.unloadScripts(scriptFile);

ScriptLoader.loadScripts(scriptFile, OpenCloseable.EMPTY);
break;
Expand All @@ -114,9 +113,7 @@ protected void execute(Event e) {
if (ScriptLoader.getDisabledScriptsFilter().accept(scriptFile))
return;

Script script = ScriptLoader.getScript(scriptFile);
if (script != null)
ScriptLoader.unloadScript(script);
this.unloadScripts(scriptFile);

try {
FileUtils.move(
Expand All @@ -135,6 +132,19 @@ protected void execute(Event e) {
assert false;
}
}

private void unloadScripts(File file) {
if (file.isDirectory()) {
Set<Script> scripts = ScriptLoader.getScripts(file);
if (scripts.isEmpty())
return;
ScriptLoader.unloadScripts(scripts);
} else {
Script script = ScriptLoader.getScript(file);
if (script != null)
ScriptLoader.unloadScript(script);
}
}

@Override
public String toString(@Nullable Event e, boolean debug) {
Expand Down

0 comments on commit ce51b92

Please sign in to comment.