Class Kingdom

All Implemented Interfaces:
org.kingdoms.abstraction.GroupOperator, KingdomOperator, org.kingdoms.abstraction.Levellable, org.kingdoms.abstraction.NamespacedFlagsContainer, NationOperator, Keyed<UUID>, SmartObject, org.kingdoms.constants.group.model.logs.Loggable, org.kingdoms.constants.themes.ThemeContainer, org.kingdoms.locale.provider.CascadingMessageContextProvider, org.kingdoms.locale.provider.MessageContextProvider

@NonExtendable public class Kingdom extends Group implements KingdomOperator, NationOperator
  • Constructor Details

    • Kingdom

      public Kingdom(@NonNull UUID id, @NonNull Map<UUID,KingdomRelationshipRequest> relationshipRequests, @NonNull Set<UUID> mails, @NonNull Map<UUID,Long> challenges, @NonNull Map<String,InviteCode> inviteCodes, @NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> miscUpgrades, @NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> powerups, @NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> championUpgrades, @NonNull Set<SimpleChunkLocation> lands, @NonNull RankMap ranks, @NonNull Map<UUID,KingdomRelation> relations, @NonNull Set<UUID> members, @Nullable String lore, @NonNull String championType, @Nullable UUID king, @Nullable UUID nation, @NonNull String name, @Nullable String tag, int level, @Nullable org.kingdoms.constants.namespace.NamespacedMap<org.kingdoms.utils.compilers.expressions.MathExpression> taxes, @Nullable SimpleLocation nexus, org.kingdoms.server.location.Location home, @NonNull Map<String,BookChapter> book, Map<Integer,org.bukkit.inventory.ItemStack> nexusChest, @Nullable GroupBanner flag, GroupBanner banner, org.kingdoms.constants.namespace.NamespacedMap<Color> colors, org.kingdoms.constants.economy.Balance resourcePoints, int maxLandsModifier, org.kingdoms.constants.economy.Balance bank, org.kingdoms.constants.namespace.NamespacedFlags flags, org.kingdoms.constants.stats.Statistics stats, long lastInvasion, long since, org.kingdoms.constants.group.Shield shield, @NonNull Map<KingdomRelation,Set<org.kingdoms.constants.group.model.relationships.RelationAttribute>> attributes)
    • Kingdom

      public Kingdom(@Nullable UUID king, @Nullable String name)
  • Method Details

    • generateInviteCode

      public InviteCode generateInviteCode(Duration expiration, UUID creator, int uses)
    • getKingdom

      public static @Nullable Kingdom getKingdom(@NonNull String name)
    • getKingdom

      public static @Nullable Kingdom getKingdom(@NonNull UUID id)
    • hasNation

      public boolean hasNation()
    • getMaxMembers

      public int getMaxMembers()
      Specified by:
      getMaxMembers in class Group
    • placeOrMoveNexus

      public NexusMoveEvent placeOrMoveNexus(org.kingdoms.server.location.Location toLocation, @Nullable KingdomPlayer kp)
      Specified by:
      placeOrMoveNexus in class Group
    • getMaxClaims

      public int getMaxClaims()
      Note, in some servers different worlds have different max claims. This will return the value for worlds that are not special (by default) and all have the same value for the same kingdom.
      See Also:
    • getMaxClaims

      public int getMaxClaims(String world)
    • updateChest

      public void updateChest()
    • isMember

      public boolean isMember(@NonNull KingdomPlayer kp)
    • isMember

      public boolean isMember(@NonNull org.bukkit.OfflinePlayer player)
    • isClaimed

      public boolean isClaimed(@NonNull SimpleChunkLocation location)
    • getKingdomsWithRelation

      public List<Kingdom> getKingdomsWithRelation(@NonNull KingdomRelation... relation)
    • getInviteCodes

      public @NonNull Map<String,InviteCode> getInviteCodes()
    • setInviteCodes

      public void setInviteCodes(@NonNull Map<String,InviteCode> inviteCodes)
    • getLevel

      public int getLevel()
      Description copied from class: Group
      This option is affected by forced levels config option if it's enabled (e.g. KingdomsConfig.GROUP_LEVELS_KINGDOMS_FORCE) The raw level is accessed from Group.getRawLevel() but you shouldn't need to use that method in almost all cases.
      Specified by:
      getLevel in interface org.kingdoms.abstraction.Levellable
      Overrides:
      getLevel in class Group
    • countStructures

      public int countStructures(Predicate<Structure> filter)
    • getAllStructures

      public List<Structure> getAllStructures()
    • sendRelationshipRequest

      public @NonNull org.kingdoms.events.general.GroupRelationshipRequestEvent sendRelationshipRequest(@Nullable KingdomPlayer sender, @NonNull Kingdom kingdom, @NonNull KingdomRelation relation, long acceptTime)
    • sendRelationshipRequest

      public @NonNull org.kingdoms.events.general.GroupRelationshipRequestEvent sendRelationshipRequest(@Nullable KingdomPlayer sender, @NonNull Kingdom kingdom, @NonNull KingdomRelation relation)
    • getKingId

      public @Nullable UUID getKingId()
    • getOnlineMembers

      public @NonNull List<org.bukkit.entity.Player> getOnlineMembers()
      Specified by:
      getOnlineMembers in class Group
    • getPlayerMembers

      public @NonNull List<org.bukkit.OfflinePlayer> getPlayerMembers()
      Specified by:
      getPlayerMembers in class Group
    • getKingdomPlayers

      public @NonNull List<KingdomPlayer> getKingdomPlayers()
      Specified by:
      getKingdomPlayers in class Group
    • getLands

      public @NonNull List<Land> getLands()
    • claim

      public @NonNull ClaimLandEvent claim(@NonNull SimpleChunkLocation loc, @NonNull KingdomPlayer claimer, ClaimLandEvent.Reason reason)
    • claim

      public @NonNull ClaimLandEvent claim(@NonNull Set<SimpleChunkLocation> locations, @Nullable KingdomPlayer claimer, @NonNull ClaimLandEvent.Reason reason, boolean history)
    • unclaim

      public @NonNull UnclaimLandEvent unclaim(@NonNull Set<SimpleChunkLocation> lands, @Nullable KingdomPlayer by, @NonNull UnclaimLandEvent.Reason reason, boolean history)
    • getRelations

      public @NonNull Map<UUID,KingdomRelation> getRelations()
      Overrides:
      getRelations in class Group
    • unclaimIf

      @Nonnull public UnclaimLandEvent unclaimIf(@Nullable KingdomPlayer by, UnclaimLandEvent.Reason reason, @Nullable Predicate<Land> filter)
    • getLandLocations

      public @Unmodifiable @NonNull Set<SimpleChunkLocation> getLandLocations()
    • unsafeGetLandLocations

      @Internal @Bookmark(UNSAFE) public @Bookmark(UNSAFE) @NonNull Set<SimpleChunkLocation> unsafeGetLandLocations()
    • rename

      public GroupRenameEvent rename(@NonNull String name, @Nullable KingdomPlayer renamer)
      Specified by:
      rename in class Group
    • getRelationWith

      public @NonNull KingdomRelation getRelationWith(@Nullable Kingdom kingdom)
    • disband

      public KingdomDisbandEvent disband(@Nullable GroupDisband.Reason reason)
      Overrides:
      disband in class Group
    • disband

      public KingdomDisbandEvent disband(@Nullable GroupDisband.Reason reason, @Nullable Runnable predataRemoval)
      Specified by:
      disband in class Group
    • hasAttribute

      public boolean hasAttribute(@Nullable Kingdom kingdom, org.kingdoms.constants.group.model.relationships.RelationAttribute attribute)
    • getKing

      public @Nullable KingdomPlayer getKing()
    • setKing

      public KingdomKingChangeEvent setKing(@NonNull KingdomPlayer newKing, @Nullable KingdomKingChangeEvent.Reason reason)
    • getLandsUnderAttack

      public @NonNull List<Land> getLandsUnderAttack()
    • isBeingInvaded

      public boolean isBeingInvaded()
    • updateRankNode

      public void updateRankNode(@NonNull String node, @NonNull String newNode)
      Specified by:
      updateRankNode in class Group
    • getInvasions

      public @NonNull Map<KingdomPlayer,Invasion> getInvasions()
      All lands that this kingdom is invading. Not the lands that are under attack.
      See Also:
    • isInvading

      public boolean isInvading()
      Checks if any of the members of this kingdom is invading another kingdom.
    • leaveNation

      public NationLeaveEvent leaveNation(LeaveReason reason)
    • toString

      public String toString()
      Overrides:
      toString in class Group
    • isUnderAttack

      public boolean isUnderAttack()
    • setHome

      public @NonNull KingdomSetHomeEvent setHome(org.kingdoms.server.location.Location home, @Nullable KingdomPlayer player)
      Specified by:
      setHome in class Group
      Returns:
      a cancelled event if the current home and the new home aren't different (in which case the event doesn't get called at all)
    • getLore

      public @Nullable String getLore()
    • setLore

      public KingdomLoreChangeEvent setLore(@Nullable String lore, KingdomPlayer by)
    • isPacifist

      public boolean isPacifist()
    • isPrivate

      public boolean isPrivate()
    • setPrivate

      public void setPrivate(boolean privatee)
    • setPacifist

      public KingdomPacifismStateChangeEvent setPacifist(boolean pacifist)
    • setPacifist

      public KingdomPacifismStateChangeEvent setPacifist(boolean pacifist, KingdomPlayer by, org.kingdoms.events.KingdomsEventCallerContext<KingdomPacifismStateChangeEvent> callerContext)
    • getMiscUpgrades

      public @NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> getMiscUpgrades()
    • setMiscUpgrades

      public void setMiscUpgrades(@NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> miscUpgrades)
    • getPowerups

      public @NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> getPowerups()
    • setPowerups

      public void setPowerups(org.kingdoms.constants.namespace.NamespacedMap<Integer> powerups)
    • getChampionUpgrades

      public @NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> getChampionUpgrades()
    • setChampionUpgrades

      public void setChampionUpgrades(@NonNull org.kingdoms.constants.namespace.NamespacedMap<Integer> championUpgrades)
    • getUpgradeLevel

      public int getUpgradeLevel(@NonNull KingdomUpgrade upgrade)
      Returns:
      a negative number if the upgrade is disabled by the kingdom.
    • getUpgradeCost

      public long getUpgradeCost(@NonNull KingdomUpgrade upgrade)
    • setUpgradeLevel

      public void setUpgradeLevel(@NonNull KingdomUpgrade upgrade, int newLevel)
    • isStrongerThan

      public boolean isStrongerThan(Kingdom other)
      Applies the strength comparison formula from config.yml
      Returns:
      false if strength comparison is disabled or this kingdom isn't stronger than the specified kingdom, otherwise true.
    • findChampionSection

      @Internal public ConfigAccessor findChampionSection()
    • spawnChampion

      public @NonNull org.bukkit.entity.Creature spawnChampion(@NonNull org.bukkit.Location location)
      This method is not protected against mob conversions, illager patrols and other general protections that treats mobs as "kingdom mobs".
    • getNexusChest

      public @NonNull org.kingdoms.constants.group.KingdomsInventory getNexusChest()
    • setNexusChest

      public void setNexusChest(@NonNull org.kingdoms.constants.group.KingdomsInventory nexusChest)
    • getLastInvasion

      public long getLastInvasion()
    • setLastInvasion

      public void setLastInvasion(long lastInvasion)
    • getNationId

      public @Nullable UUID getNationId()
    • getNation

      public @Nullable Nation getNation()
      Specified by:
      getNation in interface NationOperator
    • setNation

      @Internal public void setNation(@Nullable UUID nation)
    • calculateTax

      public double calculateTax()
      Specified by:
      calculateTax in class Group
    • getTax

      public double getTax(@NonNull org.bukkit.OfflinePlayer player)
    • payTaxes

      public @NonNull org.kingdoms.data.Pair<Boolean,Double> payTaxes(@NonNull org.bukkit.OfflinePlayer player)
    • isInSameNationAs

      public boolean isInSameNationAs(@Nullable Kingdom kingdom)
    • joinNation

      public NationJoinEvent joinNation(@NonNull Nation nation, KingdomPlayer player)
    • getNationInvites

      public @NonNull Map<UUID,KingdomInvite> getNationInvites()
    • setNationInvites

      public void setNationInvites(@NonNull Map<UUID,KingdomInvite> nationInvites)
    • getMaxLandsModifier

      public int getMaxLandsModifier()
    • setMaxLandsModifier

      public void setMaxLandsModifier(int maxLandsModifier)
    • getChampionType

      public @NonNull String getChampionType()
    • unsafeGetChampionType

      @Bookmark(UNSAFE) @Internal public @Bookmark(UNSAFE) @NonNull String unsafeGetChampionType()
    • setChampionType

      public void setChampionType(@NonNull String championType)
    • getPower

      public double getPower()
    • canBeOverclaimed

      public boolean canBeOverclaimed()
      Whether any of the claims of the kingdom can be overclaimed by another kingdom.
      See Also:
    • getChallenges

      public Map<UUID,Long> getChallenges()
      The returned map keys represents the kingdoms that have challenged this kingdom and the values are the starting time of the challenges from epoch in milliseconds. There is no easy way to get the kingdoms that this kingdom has challenged unless the LogKingdomChallenger logs are checked.

      No expired challenges are present in this map. This map can be modified and the changes will be reflected accordingly.

      See Also:
    • setChallenges

      public void setChallenges(Map<UUID,Long> challenges)
      See Also:
    • getKingdom

      public @NonNull Kingdom getKingdom()
      Specified by:
      getKingdom in interface KingdomOperator
    • getGroup

      @Nullable public @Nullable Group getGroup()
      Specified by:
      getGroup in interface org.kingdoms.abstraction.GroupOperator
      Specified by:
      getGroup in interface KingdomOperator
      Specified by:
      getGroup in interface NationOperator
      Overrides:
      getGroup in class Group
    • getDataHandler

      protected org.kingdoms.data.handlers.abstraction.DataHandler<Kingdom> getDataHandler()
      Description copied from class: CompressedSmartObject
      Used for serialization of the smart object into a compressed state to determine CompressedSmartObject.shouldSave()
      Overrides:
      getDataHandler in class CompressedSmartObject