Class PermissionsView

java.lang.Object
com.minecolonies.core.colony.permissions.PermissionsView
All Implemented Interfaces:
IPermissions

public class PermissionsView extends Object implements IPermissions
A client side representation of the permissions.
  • Constructor Details

    • PermissionsView

      public PermissionsView()
  • Method Details

    • getUserRank

      public Rank getUserRank()
      Getter for the user rank.
      Returns:
      the rank.
    • getPlayersByRank

      @NotNull public @NotNull Set<ColonyPlayer> getPlayersByRank(Rank rank)
      Gets all player by a certain rank.
      Specified by:
      getPlayersByRank in interface IPermissions
      Parameters:
      rank - the rank.
      Returns:
      set of players.
    • getPlayers

      @NotNull public @NotNull Map<UUID,ColonyPlayer> getPlayers()
      Description copied from interface: IPermissions
      Returns an unmodifiable map of the players list.
      Specified by:
      getPlayers in interface IPermissions
      Returns:
      map of UUIDs and player objects.
    • setPlayerRank

      public boolean setPlayerRank(UUID id, Rank rank, net.minecraft.world.level.Level world)
      Specified by:
      setPlayerRank in interface IPermissions
    • addPlayer

      public boolean addPlayer(@NotNull @NotNull com.mojang.authlib.GameProfile gameprofile, Rank rank)
      Specified by:
      addPlayer in interface IPermissions
    • getPlayersByRank

      @NotNull public @NotNull Set<ColonyPlayer> getPlayersByRank(@NotNull @NotNull Set<Rank> ranks)
      Gets all player by a certain set of rank.
      Specified by:
      getPlayersByRank in interface IPermissions
      Parameters:
      ranks - the set of rank.
      Returns:
      set of players.
    • getFilteredPlayers

      public Set<ColonyPlayer> getFilteredPlayers(@NotNull @NotNull Predicate<Rank> predicate)
      Specified by:
      getFilteredPlayers in interface IPermissions
    • hasPermission

      public boolean hasPermission(UUID id, @NotNull @NotNull Action action)
      Checks if the player has the permission to do an action.
      Parameters:
      id - the id of the player.
      action - the action he is trying to execute.
      Returns:
      true if so.
    • hasPermission

      public boolean hasPermission(Rank rank, @NotNull @NotNull Action action)
      Checks if the rank has the permission to do an action.
      Specified by:
      hasPermission in interface IPermissions
      Parameters:
      rank - the rank of the player.
      action - the action he is trying to execute.
      Returns:
      true if so.
    • setPermission

      public boolean setPermission(Rank rank, @NotNull @NotNull Action action, boolean enable)
      Sets if the rank has the permission to do an action.
      Specified by:
      setPermission in interface IPermissions
      Parameters:
      rank - the rank to set.
      action - the action he is trying to execute.
      enable - or disable permission
      Returns:
      true if so.
    • removePlayer

      public boolean removePlayer(UUID playerID)
      Specified by:
      removePlayer in interface IPermissions
    • alterPermission

      public boolean alterPermission(Rank actor, Rank rank, @NotNull @NotNull Action action, boolean enable)
      Description copied from interface: IPermissions
      Alters the permission through an actor, checks for allowance before altering.
      Specified by:
      alterPermission in interface IPermissions
      Parameters:
      actor - to check
      rank - rank to edit
      action - action to set
      enable - add/remove permission
      Returns:
      success/failure
    • canAlterPermission

      public boolean canAlterPermission(Rank actor, Rank rank, @NotNull @NotNull Action action)
      Description copied from interface: IPermissions
      Check if a specific permission can be altered.
      Specified by:
      canAlterPermission in interface IPermissions
      Parameters:
      actor - acting rank.
      rank - the rank to check it for.
      action - the action to check.
      Returns:
      true if so.
    • getOwnerEntry

      @Nullable public Map.Entry<UUID,ColonyPlayer> getOwnerEntry()
      Specified by:
      getOwnerEntry in interface IPermissions
    • setOwner

      public boolean setOwner(net.minecraft.world.entity.player.Player player)
      Specified by:
      setOwner in interface IPermissions
    • setOwnerAbandoned

      public void setOwnerAbandoned()
      Description copied from interface: IPermissions
      Sets the owner to abandoned
      Specified by:
      setOwnerAbandoned in interface IPermissions
    • getOwner

      @NotNull public @NotNull UUID getOwner()
      Specified by:
      getOwner in interface IPermissions
    • deserialize

      public void deserialize(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf)
      Deserialize content of class to a buffer.
      Parameters:
      buf - the buffer.
    • getRank

      public Rank getRank(@NotNull @NotNull net.minecraft.world.entity.player.Player player)
      Description copied from interface: IPermissions
      Get the rank of a certain player.
      Specified by:
      getRank in interface IPermissions
      Parameters:
      player - the player.
      Returns:
      the rank.
    • getRank

      public Rank getRank(int id)
      Description copied from interface: IPermissions
      Returns the rank with the given ID
      Specified by:
      getRank in interface IPermissions
      Parameters:
      id - the id
      Returns:
      the rank
    • restoreOwnerIfNull

      public void restoreOwnerIfNull()
      Specified by:
      restoreOwnerIfNull in interface IPermissions
    • getRank

      @NotNull public @NotNull Rank getRank(UUID id)
      Description copied from interface: IPermissions
      Get the rank of a UUID.
      Specified by:
      getRank in interface IPermissions
      Parameters:
      id - UUID to check rank of.
      Returns:
      rank of the player.
    • hasPermission

      public boolean hasPermission(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull Action action)
      Description copied from interface: IPermissions
      Returns whether the player has the permission for an action.
      Specified by:
      hasPermission in interface IPermissions
      Parameters:
      player - Player player.
      action - Action action.
      Returns:
      true if has permission, otherwise false.
    • addPlayer

      public boolean addPlayer(@NotNull @NotNull String player, Rank rank, net.minecraft.world.level.Level world)
      Specified by:
      addPlayer in interface IPermissions
    • addPlayer

      public boolean addPlayer(@NotNull @NotNull UUID id, String name, Rank rank)
      Specified by:
      addPlayer in interface IPermissions
    • getOwnerName

      @Nullable public @Nullable String getOwnerName()
      Specified by:
      getOwnerName in interface IPermissions
    • isColonyMember

      public boolean isColonyMember(@NotNull @NotNull net.minecraft.world.entity.player.Player player)
      Description copied from interface: IPermissions
      Returns whether the player is a member of the colony.
      Specified by:
      isColonyMember in interface IPermissions
      Parameters:
      player - Player to check.
      Returns:
      true if the player is a member of the colony.
    • getRanks

      public Map<Integer,Rank> getRanks()
      Description copied from interface: IPermissions
      Returns a map of all ranks present in the colony, identified by their ID
      Specified by:
      getRanks in interface IPermissions
      Returns:
      the map
    • getRankOwner

      public Rank getRankOwner()
      Description copied from interface: IPermissions
      Returns the owner rank
      Specified by:
      getRankOwner in interface IPermissions
      Returns:
      the rank
    • getRankOfficer

      public Rank getRankOfficer()
      Description copied from interface: IPermissions
      Returns the officer rank
      Specified by:
      getRankOfficer in interface IPermissions
      Returns:
      the rank
    • getRankFriend

      public Rank getRankFriend()
      Description copied from interface: IPermissions
      Returns the friend rank
      Specified by:
      getRankFriend in interface IPermissions
      Returns:
      the rank
    • getRankNeutral

      public Rank getRankNeutral()
      Description copied from interface: IPermissions
      Returns the neutral rank
      Specified by:
      getRankNeutral in interface IPermissions
      Returns:
      the rank
    • getRankHostile

      public Rank getRankHostile()
      Description copied from interface: IPermissions
      Returns the hostile rank
      Specified by:
      getRankHostile in interface IPermissions
      Returns:
      the rank
    • addRank

      public void addRank(String name)
      Description copied from interface: IPermissions
      Adds a rink with the given name to the colony
      Specified by:
      addRank in interface IPermissions
      Parameters:
      name - the chosen name
    • removeRank

      public void removeRank(Rank rank)
      Description copied from interface: IPermissions
      Removes the given rank from the colony
      Specified by:
      removeRank in interface IPermissions
      Parameters:
      rank - the rank