Class Planet

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
Version:
6.0
Author:
McChicken Studio
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
    static enum 
     
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Planet(int id)
    Loads a planet with world name.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    connectPlayer(@NotNull org.bukkit.entity.Player player)
    Connects player to the planet.
    void
    connectPlayer(@NotNull org.bukkit.entity.Player player, boolean hidePlayer)
    Connects player to the planet.
    void
    connectToDevPlanet(org.bukkit.entity.Player player)
    Connects player to developer's world.
    void
    connectToDevPlanet(org.bukkit.entity.Player player, boolean hidePlayer)
    Connects player to developer's planet.
    void
    connectToDevPlanet(org.bukkit.entity.Player player, double x, double y, double z)
    Connects player to developer's world, teleports next to block on specified coordinates.
    @NotNull net.kyori.adventure.audience.Audience
    Returns audience of world, that contains players in world and players from developer's world.
    long
    Returns creation time of world.
    Returns developer's planet of world, that has coding platforms to create a code.
    Returns holder of planet's experiments.
    byte
    Returns byte value of flag.
    @NotNull Group
    Return group of planet's owner.
    int
    Returns numeric ID of world.
    Returns information of planet, that stores display name, description, custom ID and icon.
    long
    Returns last activity time of world.
    Returns holder of planet's limits and modifiers.
    Returns current mode of planet.
    int
    Returns total players count in world.
    Returns owner's nickname of planet.
    Returns owner's group of planet.
    List<org.bukkit.entity.Player>
    Returns list of all players in world.
    Returns sharing mode of planet.
    Returns territory of planet, that contains planet's world, environment, flags, boss bars, scoreboards, code script and other temporary values.
    Returns holder of global and saved variables in planet.
    org.bukkit.World
    Returns world if planet is loaded, null - planet is unloaded.
    Returns world's name on server in the format: ./planets/planetID
    Returns players registry of planet, that stores builders, developers, whitelisted and banned players.
    boolean
    Checks whether world is in a state of changing owner.
    boolean
    Returns whether world is corrupted (doesn't have owner information) or not.
    boolean
    Checks whether world's coding is in debug mode.
    boolean
    Checks if loaded main world of planet.
    boolean
    isOwner(String nickname)
    Checks whether the owner's nickname same as specified.
    boolean
    isOwner(org.bukkit.entity.Player player)
    Checks whether the player is owner of planet.
    void
    Loads information of planet: owner, owner's group, mode, sharing, corrupted state, creation time, last activity time.
    void
    setChangingOwner(boolean changingOwner)
    Sets state of changing world's owner.
    void
    setCreationTime(long creationTime)
    Sets creation unix time of world.
    void
    setDebug(boolean debug)
    Sets debug mode for coding in world.
    void
    Sets byte value of flag.
    void
    setLastActivityTime(long activityTime)
    Sets last activity unix time in world.
    void
    setMode(@NotNull Planet.Mode mode)
    Changes planet's mode to Play or Build.
    void
    setMode(@NotNull Planet.Mode mode, boolean ignoreEvents)
    Changes planet's mode to Play or Build.
    void
    Sets new owner of world.
    void
    setSharing(@NotNull Planet.Sharing sharing)
    Sharing is ability for players to connect to the world.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Planet

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

    • getInformation

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

      public PlanetPlayers getWorldPlayers()
      Returns players registry of planet, that stores builders, developers, whitelisted and banned players.
      Returns:
      planet's registry of players.
    • 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

      public 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

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

      public 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

      public 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

      public 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(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(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

      public 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.
    • connectToDevPlanet

      public void connectToDevPlanet(org.bukkit.entity.Player player)
      Connects player to developer's world.
      Parameters:
      player - player to connect.
    • connectToDevPlanet

      public void connectToDevPlanet(org.bukkit.entity.Player player, boolean hidePlayer)
      Connects player to developer's planet.
      Parameters:
      player - player to connect.
      hidePlayer - whether hide player's join message and make him in spectator mode or not.
    • connectToDevPlanet

      public void connectToDevPlanet(org.bukkit.entity.Player player, double x, double y, double z)
      Connects player to developer's world, teleports next to block on specified coordinates.

      Will make block glowing.

      Parameters:
      player - player to connect.
      x - x coordinate of block.
      y - y coordinate of block.
      z - z coordinate of block.