Class PermissionsService

java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.PermissionsService

public class PermissionsService extends Object
This Service is responsible for handling the Permission of a SlimefunItem. You can set up these Permission nodes inside the permissions.yml file.
Author:
TheBusyBiscuit
  • Constructor Details

    • PermissionsService

      public PermissionsService(@Nonnull Slimefun plugin)
  • Method Details

    • update

      public void update(@Nonnull Iterable<SlimefunItem> items, boolean save)
      This method registers the given Iterable of SlimefunItems for use with this PermissionsService.
      Parameters:
      items - An Iterable of SlimefunItems to register
      save - Whether to save the default values to our permissions file
    • update

      public void update(@Nonnull SlimefunItem item, boolean save)
    • hasPermission

      public boolean hasPermission(org.bukkit.permissions.Permissible p, SlimefunItem item)
      This method checks whether the given Permissible has the Permission to access the given SlimefunItem.
      Parameters:
      p - The Permissible to check
      item - The SlimefunItem in question
      Returns:
      Whether the Permissible has the required Permission
    • getPermission

      @Nonnull public Optional<String> getPermission(@Nonnull SlimefunItem item)
      This returns the associated Permission with the given SlimefunItem. It actually returns an Optional, Optional.empty() means that there was no Permission set for the given SlimefunItem
      Parameters:
      item - The SlimefunItem to retrieve the Permission for.
      Returns:
      An Optional holding the Permission as a String or an empty Optional
    • setPermission

      public void setPermission(@Nonnull SlimefunItem item, @Nullable String permission)
      This method sets the Permission for a given SlimefunItem.
      Parameters:
      item - The SlimefunItem to modify
      permission - The Permission to set
    • save

      public void save()
      This saves every configured Permission to the permissions File.
    • getLore

      @Nonnull public List<String> getLore(@Nonnull SlimefunItem item)
      This returns the lore to display for a given SlimefunItem when a Player does not have the required permission node.
      Parameters:
      item - The SlimefunItem
      Returns:
      The configured lore to display