Skip to content
Peter edited this page Jul 10, 2023 · 2 revisions

Documentation

private int totalTime

Total time in ticks

private int timeRemaning

Time remaining in ticks

private String name

Internal timer name

private boolean running

If the timer is currently running

private Map<Integer,TimeRunnable> callbacks

Map of callbacks by time remaning as trigger

private int timeBetween = 1

Ticks till next update

private BukkitScheduler scheduler

Scheduler for update events

private JavaPlugin plugin

Plugin info

private static int timerN

Global timer number, used for id in default name

private Map<String,DisplayBar> bars

Map of bossbars associated with timer

private boolean autoChange

If the color of the bar should change based on time

public Logger log

Logger for timer

@Deprecated public Timer(int time, String name, Map<Integer,TimeRunnable> callbacks, Boolean showOnlyTime, JavaPlugin plugin)

Constructor for Timer

  • Parameters:
    • time — Starting time
    • name — Name of the Timer
    • callbacks — Map of ticks remaining to callbacks
    • showOnlyTime — Whether or not to show the time as the bossbar title
    • plugin — The Plugin making the timer
  • Deprecated: Parameter showOnlyTime is deprecated, functionality was moved to DisplayBar via Timer.getBar(String)

public Timer(int time, String name, Map<Integer,TimeRunnable> callbacks, JavaPlugin plugin)

Constructor for Timer

  • Parameters:
    • time — Starting time
    • name — Name of the Timer
    • callbacks — Map of ticks remaining to callbacks
    • plugin — The Plugin making the timer

public Timer(int time, Map<Integer,TimeRunnable> callbacks, JavaPlugin plugin)

Constructor for Timer. Timer will be named "default-#"

  • Parameters:
    • time — Starting time
    • callbacks — Map of ticks remaining to callbacks
    • plugin — The Plugin making the timer

@Deprecated public Timer(int time, Map<Integer,TimeRunnable> callbacks, Boolean showOnlyTime, JavaPlugin plugin)

Constructor for Timer

  • Parameters:
    • time — Starting time
    • callbacks — Map of ticks remaining to callbacks
    • showOnlyTime — Whether or not to show the time as the bossbar title
    • plugin — The Plugin making the timer
  • Deprecated: Parameter showOnlyTime is deprecated, functionality was moved to DisplayBar via Timer.getBar(String)

public int getTicksRemaning()

Return the time remaining in ticks

  • Returns: Ticks remaining

public int getSecondsRemaning()

Return the time remaining in seconds

  • Returns: Seconds remaining (rounding down)

public String getName()

Returns the name of the timer

  • Returns: Timer name

@Deprecated public void setName(String name)

Sets the name of the timer

  • Parameters: name — New name for the timer
  • Deprecated: Timer names should not be changed. If you want to change the bosbar title use Timer.setTitle(String) instead

public void setTitle(String title)

Sets the title of the main bar

  • Parameters: title — The new title

public void setTitle(String title, String bar)

Sets the title of one of the bars

  • Parameters:
    • title — The new title
    • bar — The bar to change

public void setAutoChange(boolean change)

Sets whether or not to automatically change the color of the bar

  • Parameters: change — Whether or not to automatically change the color of the bar

public void reset()

Resets the Timer: setting time remaining to max time, and reseting bossbar title to name or time

public void start()

Starts the timer

public void addAllPlayers()

Adds all players to the main bar

public void addAllPlayers(String bar)

Adds all players to a bar

  • Parameters: bar — Bar to add them to

public void addPlayer(Player p)

Adds a player to the main bar

  • Parameters: p — Player to add

public void addPlayer(Player p, String bar)

Adds a player to a bar

  • Parameters:
    • p — Player to add
    • bar — Bar to add them to

public void addPlayer(List<Player> p)

Adds a list of players to the main bar

  • Parameters: p — List of player to add

public void addPlayer(List<Player> p, String bar)

Adds a list of players to a bar

  • Parameters:
    • p — List of players to add
    • bar — Bar to add them to

public void removeAllPlayers()

Removes all players from the main bar

public void removeAllPlayers(String bar)

Removes all players from a bar

  • Parameters: bar — Bar to remove them from

public void removePlayer(Player p)

Removes a player from the timer

  • Parameters: p — Player to remove

public void removePlayer(Player p, String bar)

Removes a player from the timer

  • Parameters:
    • p — Player to remove
    • bar — Bar to remove them from

public void removePlayer(List<Player> p)

Removes a list of players from the timer

  • Parameters: p — List of players to remove

public void removePlayer(List<Player> p, String bar)

Removes a list of players from the timer

  • Parameters:
    • p — List of players to remove
    • bar — Bar to remove them from

public void stop()

Stops the timer

public void update(int dTime)

Updates the timer. INTERNAL USE ONLY

  • Parameters: dTime — Number of ticks since last update

public boolean setTime(int t)

Sets the time remaining only if the timer is stopped

  • Parameters: t — New time remaining
  • Returns: If the time was set

public boolean setMaxTime(int t)

Sets the max time only if the timer is stopped

  • Parameters: t — New max time
  • Returns: If the max time was set

public void setColor(BarColor color)

Sets the color of the main bar

  • Parameters: color — New color

public void setColor(BarColor color, String bar)

Sets the color of the specified bar

  • Parameters:
    • color — New color
    • bar — Bar to change

public void setStyle(BarStyle style)

Sets the style of the main bar

  • Parameters: style — New style

public void setStyle(BarStyle style, String bar)

Sets the style of the specified bar

  • Parameters:
    • style — New style
    • bar — Bar to change

public void addBar(String key, String title)

Adds a bar to the timer

  • Parameters:
    • key — The key for the bar, used later to access it
    • title — The title of the bar

public void removeBar(String key)

Removes a bar from the timer

  • Parameters: key — The bar to remove

public DisplayBar getBar(String bar)

Gets a bar for more fine control

  • Parameters: bar — Bar name
  • Returns: Bar

private String format(int ticks)

Returns a formated string expressing the time in seconds and minutes

  • Parameters: ticks — Amount of time in ticks
  • Returns: Formated time string

public void addCallback(int t, TimeRunnable c)

Add a callback as specific ticks remaining

  • Parameters:
    • t — Ticks remaining for the callback to be called at
    • c — Callback

public boolean removeCallback(int t)

Remove a callback at ticks remaining

  • Parameters: t — Callback trigger ticks remaining
  • Returns: The callback returned

Clone this wiki locally