Skip to content

Commit

Permalink
Fix loading on Spigot versions older than 1.18 (#6399)
Browse files Browse the repository at this point in the history
  • Loading branch information
APickledWalrus committed Feb 3, 2024
1 parent 909a14d commit 3d1047d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/ch/njol/skript/aliases/AliasesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.List;
import java.util.Map;

import ch.njol.skript.Skript;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
Expand All @@ -42,6 +44,9 @@
* Provides aliases on Bukkit/Spigot platform.
*/
public class AliasesProvider {

// not supported on Spigot versions older than 1.18
private static final boolean FASTER_SET_SUPPORTED = Skript.classExists("it.unimi.dsi.fastutil.objects.ObjectOpenHashSet");

/**
* When an alias is not found, it will requested from this provider.
Expand Down Expand Up @@ -173,7 +178,12 @@ public AliasesProvider(int expectedCount, @Nullable AliasesProvider parent) {
this.aliases = new HashMap<>(expectedCount);
this.variations = new HashMap<>(expectedCount / 20);
this.aliasesMap = new AliasesMap();
this.materials = new ObjectOpenHashSet<>();

if (FASTER_SET_SUPPORTED) {
this.materials = new ObjectOpenHashSet<>();
} else {
this.materials = new HashSet<>();
}

this.gson = new Gson();
}
Expand Down

0 comments on commit 3d1047d

Please sign in to comment.