java.lang.Object
ua.mcchickenstudio.opencreative.planets.Planet

public class Planet extends Object

Planet

This class represents a Planet, the individual place for players that consists of two worlds: for building and for developing. It has owner, world size, sharing, world mode, limits, flags, players data, variables and states.

Planet files are stored in ./planets/planetID folder.

Since:
1.0
  • Constructor Details

    • Planet

      public Planet(int id)
      Loads a planet with world name.
  • Method Details

    • getInformation

      @NotNull public @NotNull PlanetInfo getInformation()
      Returns information of planet, that stores display name, description, custom ID and icon.
      Returns:
      planet's info.
    • getWorldPlayers

      @NotNull public @NotNull PlanetPlayers getWorldPlayers()
      Returns players registry of planet, that stores builders, developers, whitelisted and banned players.
      Returns:
      planet's registry of players.
    • getConfiguration

      @NotNull public @NotNull PlanetConfig getConfiguration()
      Returns configuration, that stores settings of planet.
      Returns:
      planet's config.
    • isDebug

      public boolean isDebug()
      Checks whether world's coding is in debug mode.
      Returns:
      true - in debug mode, false - not.
    • setDebug

      public void setDebug(boolean debug)
      Sets debug mode for coding in world.
      Parameters:
      debug - true - enabled, false - disabled.
    • getVariables

      @NotNull public @NotNull WorldVariables getVariables()
      Returns holder of global and saved variables in planet.
      Returns:
      planet's variables.
    • isCorrupted

      public boolean isCorrupted()
      Returns whether world is corrupted (doesn't have owner information) or not.
      Returns:
      true - corrupted, false - not.
    • getLimits

      @NotNull public @NotNull PlanetLimits getLimits()
      Returns holder of planet's limits and modifiers.
      Returns:
      planet's limits.
    • getExperiments

      @NotNull public @NotNull PlanetExperiments getExperiments()
      Returns holder of planet's experiments.
      Returns:
      planet's experiments.
    • getGroup

      @NotNull public @NotNull Group getGroup()
      Return group of planet's owner.

      Useful to get limits and modifiers.

      Returns:
      group of owner.
    • getSharing

      @NotNull public @NotNull Planet.Sharing getSharing()
      Returns sharing mode of planet.

      Public - all players can connect to the world.

      Private - only world owner can connect to the world.

      Closed - no one can connect to the world, deleting mode.

      Returns:
      sharing mode.
    • setSharing

      public void setSharing(@NotNull @NotNull Planet.Sharing sharing)
      Sharing is ability for players to connect to the world.

      Public - all players can connect to the world.

      Private - only world owner can connect to the world.

      Closed - no one can connect to the world, deleting mode.

      Parameters:
      sharing - sharing mode.
    • getWorldName

      @NotNull public @NotNull String getWorldName()
      Returns world's name on server in the format: ./planets/planetID

      Can be used for getting world from server.

      Returns:
      world's name on server.
    • getId

      public int getId()
      Returns numeric ID of world.
      Returns:
      numeric ID.
    • getDevPlanet

      @NotNull public @NotNull DevPlanet getDevPlanet()
      Returns developer's planet of world, that has coding platforms to create a code.
      Returns:
      developer's planet.
    • isChangingOwner

      public boolean isChangingOwner()
      Checks whether world is in a state of changing owner.
      Returns:
      true - owner requested to transfer world, false - not.
    • setChangingOwner

      public void setChangingOwner(boolean changingOwner)
      Sets state of changing world's owner.
      Parameters:
      changingOwner - true - owner requested to transfer world, false - not.
    • isOwner

      public boolean isOwner(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks whether the player is owner of planet.
      Parameters:
      player - player to check.
      Returns:
      true - is owner, false - not owner.
    • isOwner

      public boolean isOwner(@NotNull @NotNull String nickname)
      Checks whether the owner's nickname same as specified.

      Ignores caps consideration.

      Parameters:
      nickname - name to check.
      Returns:
      true - is owner, false - not owner.
    • getTerritory

      public PlanetTerritory getTerritory()
      Returns territory of planet, that contains planet's world, environment, flags, boss bars, scoreboards, code script and other temporary values.
      Returns:
      planet's territory.
    • isLoaded

      public boolean isLoaded()
      Checks if loaded main world of planet.
      Returns:
      true - if loaded, false - unloaded.
    • getWorld

      public org.bukkit.World getWorld()
      Returns world if planet is loaded, null - planet is unloaded.
      Returns:
      world, or null.
    • getMode

      @NotNull public @NotNull Planet.Mode getMode()
      Returns current mode of planet.
      Returns:
      playing or build mode.
    • setMode

      public void setMode(@NotNull @NotNull Planet.Mode mode)
      Changes planet's mode to Play or Build.

      In the Build mode players cannot get damaged, they only can look at builders which are creating a map.

      In the Play mode code script will work, player damaging is enabled.

      Parameters:
      mode - Mode to set.
    • getOnline

      public int getOnline()
      Returns total players count in world.

      Includes all players from build world and developer's world.

      Returns:
      online of planet.
    • getCreationTime

      public long getCreationTime()
      Returns creation time of world.

      If value is unknown (0), will return 1670573410000L (publication of OpenCreative+).

      Returns:
      Unix time, when world was created.
    • setCreationTime

      public void setCreationTime(long creationTime)
      Sets creation Unix time of world.
      Parameters:
      creationTime - time, when world was created.
    • getLastActivityTime

      public long getLastActivityTime()
      Returns last activity time of world.

      If value is unknown (0), will return 1670573410000L (publication of OpenCreative+).

      Returns:
      Unix last time, when someone joined the world.
    • setLastActivityTime

      public void setLastActivityTime(long activityTime)
      Sets last activity Unix time in world.
      Parameters:
      activityTime - last activity time.
    • getPlayers

      public List<org.bukkit.entity.Player> getPlayers()
      Returns list of all players in world.

      Includes all players from build world and developer's world.

      Returns:
      list of all online players in world.
    • getAudience

      @NotNull public @NotNull net.kyori.adventure.audience.Audience getAudience()
      Returns audience of world, that contains players in world and players from developer's world.
      Returns:
      audience of world.
    • getOwner

      public String getOwner()
      Returns owner's nickname of planet.
      Returns:
      owner's name.
    • setOwner

      public void setOwner(String owner)
      Sets new owner of world.
      Parameters:
      owner - owner to set.
    • getOwnerGroup

      public String getOwnerGroup()
      Returns owner's group of planet.
      Returns:
      owner's group.
    • setMode

      public void setMode(@NotNull @NotNull Planet.Mode mode, boolean ignoreEvents)
      Changes planet's mode to Play or Build.

      In the Build mode players cannot get damaged, they only can look at builders which are creating a map.

      In the Play mode code script will work, player damaging is enabled.

      Parameters:
      mode - Mode to set.
      ignoreEvents - Don't call world start, player join or player quit events on mode change.
    • loadInfo

      public void loadInfo()
      Loads information of planet: owner, owner's group, mode, sharing, corrupted state, creation time, last activity time.
    • getFlagValue

      public byte getFlagValue(PlanetFlags.PlanetFlag flag)
      Returns byte value of flag.
      Parameters:
      flag - flag to get value.
      Returns:
      value of flag.
    • setFlagValue

      public void setFlagValue(PlanetFlags.PlanetFlag flag, byte value)
      Sets byte value of flag.
      Parameters:
      flag - flag to set value.
      value - new value.
    • connectPlayer

      public void connectPlayer(@NotNull @NotNull org.bukkit.entity.Player player)
      Connects player to the planet.

      May not connect player to the planet if some conditions are not met.

      For example: stability is not good, world is private, player is banned in world, error while loading spawn location.

      Parameters:
      player - player to connect.
    • connectPlayer

      public void connectPlayer(@NotNull @NotNull org.bukkit.entity.Player player, boolean hidePlayer)
      Connects player to the planet.

      May not connect player to the planet if some conditions are not met.

      For example: stability is not good, world is private, player is banned in world, error while loading spawn location.

      Parameters:
      player - player to connect.
      hidePlayer - hide player's join message, and make him in spectator mode or not.