Package fr.andross.banitem.database
Class Whitelist
java.lang.Object
java.util.AbstractMap<org.bukkit.World,WhitelistedWorld>
java.util.HashMap<org.bukkit.World,WhitelistedWorld>
fr.andross.banitem.database.Whitelist
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<org.bukkit.World,
WhitelistedWorld>
Map that contains whitelisted worlds.
- Version:
- 3.3
- Author:
- Andross
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionWhitelist
(@NotNull BanItem plugin, @NotNull BanDatabase database, @NotNull org.bukkit.command.CommandSender sender, @Nullable org.bukkit.configuration.ConfigurationSection section) Constructor for a whitelist map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNewException
(@NotNull WhitelistedWorld ww, @NotNull BannedItem item, @NotNull Map<BanAction, BanActionData> actions) This will add a new exception (allowed item) into the WhitelistedWorld object.@NotNull WhitelistedWorld
createNewWhitelistedWorld
(@NotNull org.bukkit.World world, @Nullable List<String> messages, @Nullable List<BanAction> ignored) This method will create a new whitelisted world, and add/replace it into the map.getOrCreateWhitelistedWorld
(@NotNull org.bukkit.World world, @Nullable List<String> messages, @Nullable List<BanAction> ignored) This method try to get an already existing whitelisted world, else create and put one.int
The total amount of items allowed, in all worlds.boolean
isWhitelisted
(@NotNull org.bukkit.World world, @NotNull BannedItem item, @NotNull BanAction action, @Nullable BanData... data) This method is used to check if the item is whitelisted, not involving a player.boolean
isWhitelisted
(@NotNull org.bukkit.entity.Player player, @Nullable org.bukkit.Location location, @NotNull BannedItem item, boolean sendMessage, @NotNull BanAction action, @Nullable BanData... data) Check if the item is whitelisted (allowed).Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
Whitelist
public Whitelist(@NotNull @NotNull BanItem plugin, @NotNull @NotNull BanDatabase database, @NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable org.bukkit.configuration.ConfigurationSection section) Constructor for a whitelist map.- Parameters:
plugin
- main instancedatabase
- the database instancesender
-CommandSender
who to send the debug messagessection
-ConfigurationSection
which contains the blacklist node
-
-
Method Details
-
createNewWhitelistedWorld
@NotNull public @NotNull WhitelistedWorld createNewWhitelistedWorld(@NotNull @NotNull org.bukkit.World world, @Nullable @Nullable List<String> messages, @Nullable @Nullable List<BanAction> ignored) This method will create a new whitelisted world, and add/replace it into the map.- Parameters:
world
- the bukkit worldmessages
- list of "not allowed" messagesignored
- list of ignored actions- Returns:
- the new whitelisted world object
-
getOrCreateWhitelistedWorld
public WhitelistedWorld getOrCreateWhitelistedWorld(@NotNull @NotNull org.bukkit.World world, @Nullable @Nullable List<String> messages, @Nullable @Nullable List<BanAction> ignored) This method try to get an already existing whitelisted world, else create and put one.- Parameters:
world
- the bukkit worldmessages
- list of "not allowed" messagesignored
- list of ignored actions- Returns:
- an existing whitelisted world object, otherwise a new one
-
addNewException
public void addNewException(@NotNull @NotNull WhitelistedWorld ww, @NotNull @NotNull BannedItem item, @NotNull @NotNull Map<BanAction, BanActionData> actions) This will add a new exception (allowed item) into the WhitelistedWorld object.- Parameters:
ww
- whitelisted world, can be get withgetOrCreateWhitelistedWorld(World, List, List)
item
- the itemactions
- actions with their respective data
-
isWhitelisted
public boolean isWhitelisted(@NotNull @NotNull org.bukkit.entity.Player player, @Nullable @Nullable org.bukkit.Location location, @NotNull @NotNull BannedItem item, boolean sendMessage, @NotNull @NotNull BanAction action, @Nullable @Nullable BanData... data) Check if the item is whitelisted (allowed).- Parameters:
player
- player involvedlocation
- the effective location where the action occursitem
- the banned itemsendMessage
- send a message to the player if not allowedaction
- the actiondata
- optional ban data- Returns:
- true if the item is whitelisted (allowed), otherwise false
-
isWhitelisted
public boolean isWhitelisted(@NotNull @NotNull org.bukkit.World world, @NotNull @NotNull BannedItem item, @NotNull @NotNull BanAction action, @Nullable @Nullable BanData... data) This method is used to check if the item is whitelisted, not involving a player. This method is mainly used to check dispensers dispense and hoppers transfer.- Parameters:
world
- bukkit worlditem
- the banned itemaction
- the actiondata
- optional ban data- Returns:
- true if the item is whitelisted (allowed), otherwise false
-
getTotalWhitelistedItems
public int getTotalWhitelistedItems()The total amount of items allowed, in all worlds.- Returns:
- The total amount of items allowed, in all worlds
-