Class PlanetScoreboards

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

public class PlanetScoreboards extends Object

PlanetScoreboards

This class represents a scoreboards manager, that contains methods to register, unregister and modify scoreboards.

Every scoreboard has dummy objective called "score" with sidebar display type.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PlanetScoreboards(@NotNull Planet planet)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes and unregisters all scoreboards.
    void
    clearScores(@NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
    Clears all scores from scoreboard.
    void
    destroyScoreboard(@NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
    Removes objective from scoreboard and hides it from all players.
    int
    Returns amount of all scoreboards.
    Map<String, org.bukkit.scoreboard.Scoreboard>
    Returns map of names and scoreboards.
    @Nullable org.bukkit.scoreboard.Scoreboard
    getScoreboard(@NotNull String scoreboard)
    Returns scoreboard by name, or null - if not exists.
    boolean
    hasActiveScoreboard(@NotNull org.bukkit.entity.Player player)
    Checks whether player sees any active scoreboard from this planet.
    void
    registerScoreboard(@NotNull String name, @NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
    Registers new scoreboard, or replaces old with new one.
    void
    Unregisters scoreboard from world by name.
    void
    unregisterScoreboard(@NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
    Unregisters scoreboard from world.

    Methods inherited from class Object

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

    • PlanetScoreboards

      public PlanetScoreboards(@NotNull @NotNull Planet planet)
  • Method Details

    • getMap

      public Map<String, org.bukkit.scoreboard.Scoreboard> getMap()
      Returns map of names and scoreboards.
      Returns:
      map of names and scoreboards.
    • registerScoreboard

      public void registerScoreboard(@NotNull @NotNull String name, @NotNull @NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
      Registers new scoreboard, or replaces old with new one.
      Parameters:
      name - name of scoreboard.
      scoreboard - scoreboard to register.
    • unregisterScoreboard

      public void unregisterScoreboard(@NotNull @NotNull String name)
      Unregisters scoreboard from world by name.
      Parameters:
      name - scoreboard to remove.
    • unregisterScoreboard

      public void unregisterScoreboard(@NotNull @NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
      Unregisters scoreboard from world.
      Parameters:
      scoreboard - scoreboard to remove.
    • destroyScoreboard

      public void destroyScoreboard(@NotNull @NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
      Removes objective from scoreboard and hides it from all players.

      To unregister scoreboard, use unregisterScoreboard(Scoreboard).

      Parameters:
      scoreboard - scoreboard to destroy.
    • clearScores

      public void clearScores(@NotNull @NotNull org.bukkit.scoreboard.Scoreboard scoreboard)
      Clears all scores from scoreboard.
      Parameters:
      scoreboard - scoreboard to clear scores.
    • getScoreboard

      @Nullable public @Nullable org.bukkit.scoreboard.Scoreboard getScoreboard(@NotNull @NotNull String scoreboard)
      Returns scoreboard by name, or null - if not exists.
      Parameters:
      scoreboard - name of scoreboard.
      Returns:
      scoreboard, or null - if not found.
    • getAmount

      public int getAmount()
      Returns amount of all scoreboards.
      Returns:
      amount of scoreboards.
    • hasActiveScoreboard

      public boolean hasActiveScoreboard(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks whether player sees any active scoreboard from this planet.
      Parameters:
      player - player to check.
      Returns:
      true - player sees world's scoreboard, false - doesn't see.
    • clear

      public void clear()
      Removes and unregisters all scoreboards.