Package fr.andross.banitem.utils.list
Class Listable
java.lang.Object
fr.andross.banitem.utils.list.Listable
A powerful listable class which will attempt to create List object from given data.
Mainly used to load configurations.
- Version:
- 3.1
- Author:
- Andross
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull List<T> getAllObjects(@NotNull ListType type) This method will give all possibles objects for the given type.static @NotNull List<BannedItem> getItems(@NotNull BanDatabase database, @NotNull Object obj, @Nullable Debug d) Trying to get a list of type.static <T> @NotNull List<T> Get a list of type.static @NotNull List<org.bukkit.Material> getMaterials(@NotNull Object obj, @Nullable Debug d) Trying to get a list of materials.static <T> TThis method will try to get an element for the given type.static @NotNull List<com.sk89q.worldguard.protection.regions.ProtectedRegion> getRegionsList(@NotNull BanItem pl, @NotNull Object obj, @Nullable Debug d, @NotNull Collection<org.bukkit.World> worlds) Get a list of protected regions (WorldGuard).getSplitStringList(@Nullable Object o) Get a list of string based on each elements split with ',' character, based on the type of the object (string, list, array).getStringList(@Nullable Object o) Trying to get a list of string from an Object.static @NotNull List<org.bukkit.World> Trying to get a list of type.static <T> @NotNull List<T> newList(T... a) This will create a new (mutable) list from an array.splitToList(@NotNull String string) Split a string into a list of string, based on ',' character.splitToList(@Nullable List<String> list) Split each element in the list into a list of string, based on ',' character.
-
Method Details
-
splitToList
Split a string into a list of string, based on ',' character. Each item will be trimmed.- Parameters:
string- the string to split- Returns:
- the string split into a list of multiple value, separated by ',' character
-
splitToList
Split each element in the list into a list of string, based on ',' character. Each item will be trimmed.- Parameters:
list- the string to split- Returns:
- list of all elements split by ',' character
-
getStringList
Trying to get a list of string from an Object. Mainly used to extract strings from aConfigurationSection.get(String)- Parameters:
o- object to parse- Returns:
- a list of elements in this object
-
getSplitStringList
Get a list of string based on each elements split with ',' character, based on the type of the object (string, list, array).- Parameters:
o- the object- Returns:
- a list of all elements split with ',' character
-
newList
This will create a new (mutable) list from an array.- Type Parameters:
T- parameter- Parameters:
a- elements- Returns:
- a mutable list of elements
-
getList
@NotNull public static <T> @NotNull List<T> getList(@NotNull @NotNull ListType type, @NotNull @NotNull Object obj, @Nullable @Nullable Debug d) Get a list of type. This should not be used for Items, World nor Regions. Use insteadgetItems(BanDatabase, Object, Debug),getWorlds(Object, Debug), andgetRegionsList(BanItem, Object, Debug, Collection),- Type Parameters:
T- parameter respecting the type class- Parameters:
type- type of dataobj- object to get a list fromd- debugger, returning empty list if null and if there is any error- Returns:
- a list of parsed type
-
getWorlds
@NotNull public static @NotNull List<org.bukkit.World> getWorlds(@NotNull @NotNull Object obj, @Nullable @Nullable Debug d) Trying to get a list of type. If there is any error, this will be debugged.- Parameters:
obj- object to get a list fromd- debugger, returning empty list if null and if there is any error- Returns:
- a list of parsed type
-
getMaterials
@NotNull public static @NotNull List<org.bukkit.Material> getMaterials(@NotNull @NotNull Object obj, @Nullable @Nullable Debug d) Trying to get a list of materials. If there is any error, this will be debugged.- Parameters:
obj- object to get a list fromd- debugger, returning empty list if null and if there is any error- Returns:
- a list of parsed type
-
getItems
@NotNull public static @NotNull List<BannedItem> getItems(@NotNull @NotNull BanDatabase database, @NotNull @NotNull Object obj, @Nullable @Nullable Debug d) Trying to get a list of type. If there is any error, this will be debugged.- Parameters:
database- the current database instanceobj- object to get a list fromd- debugger, returning empty list if null and if there is any error- Returns:
- a list of items
-
getRegionsList
@NotNull public static @NotNull List<com.sk89q.worldguard.protection.regions.ProtectedRegion> getRegionsList(@NotNull @NotNull BanItem pl, @NotNull @NotNull Object obj, @Nullable @Nullable Debug d, @NotNull @NotNull Collection<org.bukkit.World> worlds) Get a list of protected regions (WorldGuard).- Parameters:
pl- the plugin instanceobj- object to get a list fromd- debugger, returning empty list if null and if there is any errorworlds- list of worlds where to get the regions- Returns:
- a list of regions
-
getObject
@Nullable public static <T> T getObject(@NotNull @NotNull ListType type, @NotNull @NotNull String key) throws IllegalArgumentException This method will try to get an element for the given type.- Type Parameters:
T- parameter- Parameters:
type- type of the elementkey- object that should be get from this type- Returns:
- an object of type, null if not found
- Throws:
IllegalArgumentException- for any Enum non matches
-
getAllObjects
This method will give all possibles objects for the given type.- Type Parameters:
T- parameter of the type- Parameters:
type- type to get- Returns:
- list of all elements for the given type
-