-
-
Notifications
You must be signed in to change notification settings - Fork 414
Pig Variants #7846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sovdeeth
merged 7 commits into
SkriptLang:dev/feature
from
Absolutionism:dev/PigVariants
May 15, 2025
Merged
Pig Variants #7846
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1e36607
Initial Commit
Absolutionism 9a3f238
Update WolfData.java
Absolutionism 1169fed
Update PaperUtils.java
Absolutionism 6c2d19e
Requested Changes
Absolutionism 06f024a
Update BukkitClasses.java
Absolutionism 32571d4
Update BukkitClasses.java
Absolutionism 99a4720
Merge branch 'dev/feature' into dev/PigVariants
sovdeeth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package ch.njol.skript.util; | ||
|
|
||
| import ch.njol.skript.Skript; | ||
| import io.papermc.paper.registry.RegistryAccess; | ||
| import io.papermc.paper.registry.RegistryKey; | ||
| import org.bukkit.Keyed; | ||
| import org.bukkit.Registry; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| public class PaperUtils { | ||
|
|
||
| private static final boolean REGISTRY_ACCESS_EXISTS = Skript.classExists("io.papermc.paper.registry.RegistryAccess"); | ||
| private static final boolean REGISTRY_KEY_EXISTS = Skript.classExists("io.papermc.paper.registry.RegistryKey"); | ||
|
|
||
| /** | ||
| * Check if a registry exists within {@link RegistryKey} | ||
| * @param registry Registry to check for (Fully qualified name of registry) | ||
| * @return True if registry exists else false | ||
| */ | ||
| public static boolean registryExists(String registry) { | ||
| return REGISTRY_ACCESS_EXISTS | ||
| && REGISTRY_KEY_EXISTS | ||
| && Skript.fieldExists(RegistryKey.class, registry); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the Bukkit {@link Registry} from Paper's {@link RegistryKey}. | ||
| * @param registry Registry to get (Fully qualified name of registry). | ||
| * @return The Bukkit {@link Registry} if registry exists else {@code null}. | ||
| */ | ||
| public static <T extends Keyed> @Nullable Registry<T> getBukkitRegistry(String registry) { | ||
| if (!registryExists(registry)) | ||
| return null; | ||
| RegistryKey registryKey; | ||
| try { | ||
| registryKey = (RegistryKey) RegistryKey.class.getField(registry).get(null); | ||
| } catch (NoSuchFieldException | IllegalAccessException ignored) { | ||
| return null; | ||
| } | ||
| //noinspection unchecked | ||
| return (Registry<T>) RegistryAccess.registryAccess().getRegistry(registryKey); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.