Skip to content

Commit 0be6027

Browse files
committed
Merge branch 'dev/feature' into feature/remove-inf-value
2 parents d26a6a2 + d725212 commit 0be6027

301 files changed

Lines changed: 4035 additions & 1606 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.6-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.6.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.6
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/SkriptConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

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

Lines changed: 120 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import java.lang.reflect.Field;
4343
import java.util.*;
4444
import java.util.Map.Entry;
45+
import java.util.function.BiPredicate;
46+
import java.util.function.Predicate;
4547
import java.util.stream.Collectors;
4648

4749
@ContainerType(ItemStack.class)
@@ -564,6 +566,30 @@ public Iterator<ItemStack> iterator() {
564566
};
565567
}
566568

569+
/**
570+
* Determines whether this ItemType satisfies the given predicate.
571+
* If {@link #isAll()} is true, this will return true if the predicate is satisfied by all ItemDatas.
572+
* If {@link #isAll()} is false, this will return true if the predicate is satisfied by any ItemData.
573+
* @param predicate A predicate to test items against
574+
* @return Whether this ItemType satisfies the predicate
575+
*/
576+
public boolean satisfies(Predicate<ItemStack> predicate) {
577+
if (isAll()) {
578+
for (Iterator<ItemStack> it = containerIterator(); it.hasNext(); ) {
579+
ItemStack stack = it.next();
580+
if (!predicate.test(stack))
581+
return false;
582+
}
583+
return true;
584+
}
585+
for (Iterator<ItemStack> it = containerIterator(); it.hasNext(); ) {
586+
ItemStack stack = it.next();
587+
if (predicate.test(stack))
588+
return true;
589+
}
590+
return false;
591+
}
592+
567593
@Nullable
568594
public ItemStack removeAll(@Nullable ItemStack item) {
569595
boolean wasAll = all;
@@ -1262,7 +1288,7 @@ public Map<Enchantment,Integer> getEnchantments() {
12621288
public void addEnchantments(Map<Enchantment,Integer> enchantments) {
12631289
if (globalMeta == null)
12641290
globalMeta = ItemData.itemFactory.getItemMeta(Material.STONE);
1265-
for (Map.Entry<Enchantment,Integer> entry : enchantments.entrySet()) {
1291+
for (Entry<Enchantment,Integer> entry : enchantments.entrySet()) {
12661292
assert globalMeta != null;
12671293
globalMeta.addEnchant(entry.getKey(), entry.getValue(), true);
12681294
}
@@ -1339,23 +1365,111 @@ public boolean hasAnyEnchantments(Enchantment... enchantments) {
13391365
}
13401366

13411367
/**
1342-
* Checks whether this item type contains the given enchantments.
1343-
* Also checks the enchantment level.
1368+
* Checks whether this item type contains all the given enchantments.
1369+
* Also checks the enchantment level, where any level equal or lesser than the item's level is accepted.
13441370
* @param enchantments The enchantments to be checked.
1371+
* @deprecated Use {@link #hasEnchantmentsOrBetter(EnchantmentType...)}
13451372
*/
1373+
@Deprecated(since="INSERT VERSION")
13461374
public boolean hasEnchantments(EnchantmentType... enchantments) {
1375+
return hasEnchantmentsOrBetter(true, enchantments);
1376+
}
1377+
1378+
/**
1379+
* Checks whether this item type contains the given enchantments.
1380+
* Also checks the enchantment level, where any level equal or lesser than the item's level is accepted.
1381+
* @param all Whether to check all enchantments or any enchantment.
1382+
* @param enchantments The enchantments to be checked.
1383+
* @deprecated Use {@link #hasEnchantmentsOrBetter(boolean, EnchantmentType...)}
1384+
*/
1385+
@Deprecated(since="INSERT VERSION")
1386+
public boolean hasEnchantments(boolean all, EnchantmentType... enchantments) {
1387+
return hasEnchantmentsOrBetter(all, enchantments);
1388+
}
1389+
1390+
/**
1391+
* Checks whether this item type contains all the given enchantments.
1392+
* Also checks the enchantment level, where any level equal or lesser than the item's level is accepted.
1393+
* @param enchantments The enchantments to be checked.
1394+
*/
1395+
public boolean hasEnchantmentsOrBetter(EnchantmentType... enchantments) {
1396+
return hasEnchantmentsOrBetter(true, enchantments);
1397+
}
1398+
1399+
/**
1400+
* Checks whether this item type contains the given enchantments.
1401+
* Also checks the enchantment level, where any level equal or lesser than the item's level is accepted.
1402+
* @param all Whether to check all enchantments or any enchantment.
1403+
* @param enchantments The enchantments to be checked.
1404+
*/
1405+
public boolean hasEnchantmentsOrBetter(boolean all, EnchantmentType... enchantments) {
1406+
return hasEnchantments((itemLevel, typeLevel) -> itemLevel >= typeLevel, all, enchantments);
1407+
}
1408+
1409+
/**
1410+
* Checks whether this item type contains all the given enchantments.
1411+
* Also checks the enchantment level, where any level equal or greater than the item's level is accepted.
1412+
* @param enchantments The enchantments to be checked.
1413+
*/
1414+
public boolean hasEnchantmentsOrWorse(EnchantmentType... enchantments) {
1415+
return hasEnchantmentsOrWorse(true, enchantments);
1416+
}
1417+
1418+
/**
1419+
* Checks whether this item type contains the given enchantments.
1420+
* Also checks the enchantment level, where any level equal or greater than the item's level is accepted.
1421+
* @param all Whether to check all enchantments or any enchantment.
1422+
* @param enchantments The enchantments to be checked.
1423+
*/
1424+
public boolean hasEnchantmentsOrWorse(boolean all, EnchantmentType... enchantments) {
1425+
return hasEnchantments((itemLevel, typeLevel) -> itemLevel <= typeLevel, all, enchantments);
1426+
}
1427+
1428+
/**
1429+
* Checks whether this item type contains all the given enchantments with the given level.
1430+
* EnchantmentTypes that do not specify a level match any level.
1431+
* @param enchantments The enchantments to be checked.
1432+
*/
1433+
public boolean hasExactEnchantments(EnchantmentType... enchantments) {
1434+
return hasExactEnchantments(true, enchantments);
1435+
}
1436+
1437+
/**
1438+
* Checks whether this item type contains the given enchantments with the given level.
1439+
* EnchantmentTypes that do not specify a level match any level.
1440+
* @param all Whether to check all enchantments or any enchantment.
1441+
* @param enchantments The enchantments to be checked.
1442+
*/
1443+
public boolean hasExactEnchantments(boolean all, EnchantmentType... enchantments) {
1444+
return hasEnchantments(Integer::equals, all, enchantments);
1445+
}
1446+
1447+
/**
1448+
* Checks whether this item type contains the given enchantments.
1449+
* Also checks the enchantment level, with behavior depending on the {@code exact} parameter.
1450+
* @param levelMatchingCondition A predicate used to tell whether the item's level (first param) matches a type's level (second param).
1451+
* Types with no specified level will always match, regardless of this predicate.
1452+
* @param all Whether to check all enchantments or any enchantment.
1453+
* @param enchantments The enchantments to be checked.
1454+
*/
1455+
private boolean hasEnchantments(BiPredicate<@NotNull Integer, @NotNull Integer> levelMatchingCondition, boolean all, EnchantmentType... enchantments) {
13471456
if (!hasEnchantments())
13481457
return false;
13491458
ItemMeta meta = getItemMeta();
13501459
for (EnchantmentType enchantment : enchantments) {
13511460
Enchantment type = enchantment.getType();
13521461
assert type != null; // Bukkit working different than we expect
1353-
if (!meta.hasEnchant(type))
1462+
if (!meta.hasEnchant(type) && all)
13541463
return false;
1355-
if (enchantment.getInternalLevel() != -1 && meta.getEnchantLevel(type) < enchantment.getLevel())
1464+
if (enchantment.getInternalLevel() == -1 || levelMatchingCondition.test(meta.getEnchantLevel(type), enchantment.getLevel())) {
1465+
if (!all)
1466+
return true;
1467+
} else if (all) {
13561468
return false;
1469+
}
13571470
}
1358-
return true;
1471+
return all;
1472+
13591473
}
13601474

13611475
/**

src/main/java/ch/njol/skript/bukkitutil/WorldUtils.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)