Package ch.njol.skript.aliases
Class Aliases
java.lang.Object
ch.njol.skript.aliases.Aliases
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Clears aliases.static ScriptAliases
createScriptAliases
(Script script) Creates script aliases for the provided Script.static AliasesProvider
getAddonProvider
(@Nullable SkriptAddon addon) Creates an aliases provider to be used by given addon.static int
static String
getMaterialName
(ItemData type, boolean plural) static @Nullable String
getMinecraftId
(ItemData data) Gets a Vanilla Minecraft material id for given item data.static @Nullable EntityData
<?> getRelatedEntity
(ItemData data) Gets an entity type related to given item.static @Nullable ScriptAliases
getScriptAliases
(Script script) Method for obtaining the ScriptAliases instance of aScript
.static ItemType
javaItemType
(String name) Deprecated, for removal: This API element is subject to removal in a future version.static void
load()
Loads aliases from Skript's standard locations.static void
Loads aliases from configuration.static void
Loads aliases from given path.static void
loadDirectory
(Path dir) Loads aliases from given directory.static @Nullable ItemType
parseAlias
(String s) Parses an ItemType to be used as an alias, i.e.static @Nullable ItemType
Parses an ItemType.
-
Constructor Details
-
Aliases
public Aliases()
-
-
Method Details
-
getMaterialName
-
getGender
- Returns:
- The item's gender or -1 if no name is found
-
parseAlias
Parses an ItemType to be used as an alias, i.e. it doesn't parse 'all'/'every' and the amount.- Parameters:
s
- mixed case string- Returns:
- A new ItemType representing the given value
-
parseItemType
Parses an ItemType.Prints errors.
- Parameters:
s
-- Returns:
- The parsed ItemType or null if the input is invalid.
-
clear
public static void clear()Clears aliases. Make sure to load them after this! -
load
public static void load()Loads aliases from Skript's standard locations. Exceptions will be logged, but not thrown. -
loadDirectory
Loads aliases from given directory.- Parameters:
dir
- Directory of aliases.- Throws:
IOException
- If something goes wrong with loading.
-
load
Loads aliases from given path.- Parameters:
f
- Path of alias file.- Throws:
IOException
- If something goes wrong with loading.
-
load
Loads aliases from configuration.- Parameters:
config
- Configuration containing the aliases.
-
getMinecraftId
Gets a Vanilla Minecraft material id for given item data.- Parameters:
data
- Item data.- Returns:
- Minecraft item id or null.
-
getRelatedEntity
Gets an entity type related to given item. For example, an armor stand item is related with armor stand entity.- Parameters:
data
- Item data.- Returns:
- Entity type or null.
-
javaItemType
Deprecated, for removal: This API element is subject to removal in a future version.Gets an item type that matches the given name. If it doesn't exist, an exception is thrown instead.Item types provided by this method are updated when aliases are reloaded. However, this also means they are tracked by aliases system and NOT necessarily garbage-collected.
Relying on this method to create item types is not safe, as users can change aliases at any point. ItemTypes should instead be created via
Material
s,Tag
s, or any other manual method.- Parameters:
name
- Name of item to search from aliases.- Returns:
- An item.
- Throws:
IllegalArgumentException
- When item is not found.
-
getAddonProvider
Creates an aliases provider to be used by given addon. It can be used to register aliases and variations to be used in scripts.- Parameters:
addon
- Skript addon.- Returns:
- Aliases provider.
-
createScriptAliases
Creates script aliases for the provided Script.- Returns:
- Script aliases that are ready to be added to.
-
getScriptAliases
Method for obtaining the ScriptAliases instance of aScript
.- Parameters:
script
- The script to obtain aliases from.- Returns:
- The obtained aliases, or null if the script has no custom aliases.
-