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
Creates script aliases.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 ItemType
javaItemType(String name)
Gets an item type that matches the given name.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
parseItemType(String s)
Parses an ItemType.static void
setScriptAliases(@Nullable ScriptAliases aliases)
Sets script aliases to be used for lookups.
-
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
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.
- 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.- Returns:
- Script aliases, ready to be added to.
-
setScriptAliases
Sets script aliases to be used for lookups. Remember to set them to null when the script changes.- Parameters:
aliases
- Script aliases.
-