Skip to content

Commit c4589e7

Browse files
Merge branch 'dev/feature' into feature/custom-model-data
2 parents da60483 + 187a055 commit c4589e7

361 files changed

Lines changed: 6588 additions & 2332 deletions

File tree

Some content is hidden

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

LICENSING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Skript is licensed under the [GNU General Public License (Version 3)](LICENSE).
2+
3+
However, to foster a better open-source community, and in the interest of further opening this project in the future,
4+
we ask that contributors release their code under the MIT License.
5+
Since it is less restrictive than GPLv3, it provides us and other developers
6+
with greater flexibility when making use of contributed code.
7+
8+
To learn more about this license, you can visit [choosealicense.com](https://choosealicense.com/licenses/mit/).
9+
You can also view the full text of the license below:
10+
<details>
11+
<summary>MIT License</summary>
12+
13+
```text
14+
Permission is hereby granted, free of charge, to any person obtaining a copy
15+
of this software and associated documentation files (the "Software"), to deal
16+
in the Software without restriction, including without limitation the rights
17+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
copies of the Software, and to permit persons to whom the Software is
19+
furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all
22+
copies or substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
SOFTWARE.
31+
```
32+
</details>
33+
34+
If you wish to release your contributions to this repository under the MIT License,
35+
please add your name below in your pull request.
36+
37+
When adding your name, please follow the example format below:
38+
39+
`<name> (<commit email address>)`
40+
> [!NOTE]
41+
> For name, you may choose to use your real name or GitHub account name. \
42+
> If you use more than one commit email address, please include all of them.
43+
44+
```text
45+
APickledWalrus (apickledwalrus@icloud.com, apickledwalrus@gmail.com)
46+
Sovde (10354869+sovdeeth@users.noreply.github.com)
47+
UnderscoreTud (98935832+UnderscoreTud@users.noreply.github.com)
48+
```

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,6 @@ contact us about any problems you might have with them.
191191
## Developers
192192
You can find all contributors [here](https://github.com/SkriptLang/Skript/graphs/contributors).
193193

194-
All code is owned by its writer, licensed for others under GPLv3 (see LICENSE)
195-
unless otherwise specified.
194+
All code is owned by its writer, licensed for others under GPLv3 (see [LICENSE](LICENSE)).
195+
Some contributors may choose to release their code under the MIT License.
196+
Further information can be found within [LICENSING.md](LICENSING.md).

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
shadow group: 'org.bstats', name: 'bstats-bukkit', version: '3.1.0'
3030
shadow group: 'net.kyori', name: 'adventure-text-serializer-bungeecord', version: '4.4.0'
3131

32-
implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.21.5-R0.1-SNAPSHOT'
32+
implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.21.7-R0.1-SNAPSHOT'
3333
implementation group: 'com.google.code.findbugs', name: 'findbugs', version: '3.0.1'
3434

3535
// bundled with Minecraft 1.19.4+ for display entity transforms
@@ -246,7 +246,7 @@ void createTestTask(String name, String desc, String environments, int javaVersi
246246
def java21 = 21
247247
def java17 = 17
248248

249-
def latestEnv = 'java21/paper-1.21.5.json'
249+
def latestEnv = 'java21/paper-1.21.7.json'
250250
def latestJava = java21
251251
def oldestJava = java17
252252

code-conventions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ With the exception of contacting our own resources (e.g. to check for updates) c
6464
## Licensing
6565

6666
Code contributed must be licensed under GPLv3, by **you**.
67+
Some contributors may choose to release their code under the MIT License.
68+
Further information can be found within [LICENSING.md](LICENSING.md).
6769
We expect that any code you contribute is either owned by you or you have explicit permission to provide and license it to us.
6870

6971
Licenses do not need to be printed in individual files (or packages) unless the licence applying to the code in

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ groupid=ch.njol
77
name=skript
88
version=2.11.2
99
jarName=Skript.jar
10-
testEnv=java21/paper-1.21.5
10+
testEnv=java21/paper-1.21.7
1111
testEnvJavaVersion=21

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
plugins {
3-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
3+
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
44
}
55

66
rootProject.name = 'Skript'

src/main/java/ch/njol/skript/ScriptLoader.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import ch.njol.skript.config.SectionNode;
66
import ch.njol.skript.config.SimpleNode;
77
import ch.njol.skript.events.bukkit.PreScriptLoadEvent;
8+
import ch.njol.skript.lang.ExecutionIntent;
89
import ch.njol.skript.lang.Section;
910
import ch.njol.skript.lang.SkriptParser;
1011
import ch.njol.skript.lang.Statement;
@@ -20,7 +21,7 @@
2021
import ch.njol.skript.util.SkriptColor;
2122
import ch.njol.skript.util.Task;
2223
import ch.njol.skript.util.Timespan;
23-
import ch.njol.skript.variables.TypeHints;
24+
import ch.njol.skript.variables.HintManager;
2425
import ch.njol.util.NonNullPair;
2526
import ch.njol.util.OpenCloseable;
2627
import ch.njol.util.StringUtils;
@@ -951,6 +952,14 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
951952

952953
ArrayList<TriggerItem> items = new ArrayList<>();
953954

955+
// Begin local variable type hints
956+
parser.getHintManager().enterScope(true);
957+
// Track if the scope has been frozen
958+
// This is the case when a statement that stops further execution is encountered
959+
// Further statements would not run, meaning the hints from them are inaccurate
960+
// When true, before exiting the scope, its hints are cleared to avoid passing them up
961+
boolean freezeScope = false;
962+
954963
boolean executionStops = false;
955964
for (Node subNode : node) {
956965
parser.setNode(subNode);
@@ -983,11 +992,18 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
983992

984993
items.add(item);
985994
} else if (subNode instanceof SectionNode subSection) {
986-
TypeHints.enterScope(); // Begin conditional type hints
987995

988996
RetainingLogHandler handler = SkriptLogger.startRetainingLog();
989997
find_section:
990998
try {
999+
// enter capturing scope
1000+
// it is possible that the line may successfully parse and initialize (via init), but some other issue
1001+
// prevents it from being able to load. for example:
1002+
// - a statement with a section that has no expression to claim the section
1003+
// - a statement with a section that has multiple expressions attempting to claim the section
1004+
// thus, hints may be added, but we do not want to save them as the line is invalid
1005+
parser.getHintManager().enterScope(false);
1006+
9911007
item = Section.parse(expr, "Can't understand this section: " + expr, subSection, items);
9921008
if (item != null)
9931009
break find_section;
@@ -1014,6 +1030,13 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
10141030
}
10151031
continue;
10161032
} finally {
1033+
// exit hint scope (see above)
1034+
HintManager hintManager = parser.getHintManager();
1035+
if (item == null) { // unsuccessful, wipe out hints
1036+
hintManager.clearScope(0, false);
1037+
}
1038+
hintManager.exitScope();
1039+
10171040
RetainingLogHandler afterParse = handler.backup();
10181041
handler.clear();
10191042
handler.printLog();
@@ -1023,9 +1046,6 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
10231046
}
10241047

10251048
items.add(item);
1026-
1027-
// Destroy these conditional type hints
1028-
TypeHints.exitScope();
10291049
} else {
10301050
continue;
10311051
}
@@ -1037,7 +1057,24 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
10371057
Skript.warning("Unreachable code. The previous statement stops further execution.");
10381058
}
10391059
executionStops = item.executionIntent() != null;
1060+
1061+
if (executionStops && !freezeScope) {
1062+
freezeScope = true;
1063+
// Execution might stop for some sections but not all
1064+
// We want to pass hints up to the scope that execution resumes in
1065+
if (item.executionIntent() instanceof ExecutionIntent.StopSections intent) {
1066+
parser.getHintManager().mergeScope(0, intent.levels(), true);
1067+
}
1068+
}
1069+
}
1070+
1071+
// If the scope was frozen, then we need to clear it to prevent passing up inaccurate hints
1072+
// They will have already been copied as necessary
1073+
if (freezeScope) {
1074+
parser.getHintManager().clearScope(0, false);
10401075
}
1076+
// Destroy local variable type hints for this section
1077+
parser.getHintManager().exitScope();
10411078

10421079
for (int i = 0; i < items.size() - 1; i++)
10431080
items.get(i).setNext(items.get(i + 1));

src/main/java/ch/njol/skript/Skript.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,6 @@ public void onDisable() {
12641264
if (disabled)
12651265
return;
12661266
disabled = true;
1267-
this.experimentRegistry = null;
12681267

12691268
if (!partDisabled) {
12701269
beforeDisable();
@@ -1279,6 +1278,8 @@ public void onDisable() {
12791278
Skript.exception(e, "An error occurred while shutting down.", "This might or might not cause any issues.");
12801279
}
12811280
}
1281+
1282+
this.experimentRegistry = null;
12821283
}
12831284

12841285
// ================ CONSTANTS, OPTIONS & OTHER ================

src/main/java/ch/njol/skript/SkriptConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ch.njol.skript;
22

3+
import ch.njol.skript.classes.EnumParser;
34
import ch.njol.skript.config.Config;
4-
import ch.njol.skript.config.EnumParser;
55
import ch.njol.skript.config.Option;
66
import ch.njol.skript.config.OptionSection;
77
import ch.njol.skript.hooks.Hook;
@@ -375,6 +375,10 @@ private static void userDisableHooks(Class<? extends Hook<?>> hookClass, boolean
375375
public static final Option<Integer> variableChangesUntilSave = new Option<>("variable changes until save", 1000)
376376
.setter(FlatFileStorage::setRequiredChangesForResave);
377377

378+
// intentionally not present in the config presented to the user. Users must manually add this option to disable it.
379+
public static final Option<Boolean> simplifySyntaxesOnParse = new Option<>("simplify syntax on parse", true)
380+
.optional(true);
381+
378382
/**
379383
* This should only be used in special cases
380384
*/

src/main/java/ch/njol/skript/aliases/AliasesProvider.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ch.njol.skript.aliases;
22

3-
import ch.njol.skript.Skript;
43
import ch.njol.skript.bukkitutil.BukkitUnsafe;
54
import ch.njol.skript.bukkitutil.ItemUtils;
65
import ch.njol.skript.bukkitutil.block.BlockCompat;
@@ -11,7 +10,6 @@
1110
import java.util.ArrayList;
1211
import java.util.Collections;
1312
import java.util.HashMap;
14-
import java.util.HashSet;
1513
import java.util.List;
1614
import java.util.Map;
1715
import java.util.Set;
@@ -24,9 +22,6 @@
2422
*/
2523
public class AliasesProvider {
2624

27-
// not supported on Spigot versions older than 1.18
28-
private static final boolean FASTER_SET_SUPPORTED = Skript.classExists("it.unimi.dsi.fastutil.objects.ObjectOpenHashSet");
29-
3025
/**
3126
* When an alias is not found, it will requested from this provider.
3227
* Null when this is global aliases provider.
@@ -66,13 +61,7 @@ public AliasesProvider(int expectedCount, @Nullable AliasesProvider parent) {
6661
this.aliases = new HashMap<>(expectedCount);
6762
this.variations = new HashMap<>(expectedCount / 20);
6863
this.aliasesMap = new AliasesMap();
69-
70-
if (FASTER_SET_SUPPORTED) {
71-
this.materials = new ObjectOpenHashSet<>();
72-
} else {
73-
this.materials = new HashSet<>();
74-
}
75-
64+
this.materials = new ObjectOpenHashSet<>();
7665
this.gson = new Gson();
7766
}
7867

0 commit comments

Comments
 (0)