Business Logic - Kirastur/BossbarCountdown GitHub Wiki
Context
This plugin is designed for timed quests, e.g. "collect 15 wood in 5 minutes" and works in conjunction with different quest plugins. When the quest plugin starts the quests (resp. the objective), it monitors the quest for two finalization situations (events):
- The player has collected his 15 woord in time. Then the quest plugin can cancel the Bossbar and continues with normal quest progress
- The Bossbar has reached its end value. Then the Bossbar notifys the quest plugin about the timeout. The questplugin cancels the quest and send the player back to start.
Key features of the BossbarCountdown plugin are:
- Start a countdown
- Display the countdown progress as Bossbar
- Perform a predefined action when the countdown is finished
- Cancel the countdown if a superior logic decides that the countdown is no longer needed
If the agents logs out during countdown, the Bossbar gets deleted without any notification.
Invocation
The BossbarCountdown has no integrated trigger to start a Bossbar on its own. A BossbarCountdown must be started from an external source, e.g. by using the /bbcd
command or using the API.
Action
The Bossbar has a start-value, an end-value and a speed. At runtime, you can perform the following changes:
- Change the current progress-value
- Change the speed the progress gets decreased or increased
- Change the title of the Bossbar
- Pause the countdown and continue (unpause) with the countdown
- Show and hide the Bossbar
Final
If the progress has reached the end-value the following steps are executed:
- A custom event is sent
- The defined command is executed (with the server console as CommandSender)
- The Bossbar removes itself from the player
Cancel
As long as the Bossbar has not reached the end-value, you can cancel the Bossbar. This removes the Bossbar from the player so he has no chance any more to get the final tasks executed.
Templates
The Bossbars are organzied in Templates. A Template defines:
- The layout of the Bossbar (color, title etc.)
- The start-value, end-value and countdown-speed
- The action which should be performed when the goal (end-value) is reached
In contrast to the "classic" minecraft bossbar, where a bossbar can be assigned to multiple players, a BossbarCountdown can only assigned to a single player. Of course you can assign the same template to different players, but each player will have its individual contdown progress.
At the same time, the same template can be assigent to the same player only once, so the combination of TemplateName and PlayerName is unique.
Value Range
In classic minecraft, a bossbar has a fixed range from 0.0 to 1.0. But a BossbarCountdown can use every scala you want. You can set e.g. the left border to "5.0" and the right boder to "-1.2". The other values (progress, speed) then use this scala. We are planning a Placeholder API integration, so you can read the current progress without any conversion in the future.
It is fully supported to set the scala as "left < right" or "left > right". You can also use a positive or negative speed to move the progress in the one or the other direction.
The goal (end-value) can sit at any point of the scala (e.g. left border, right border oder in the middle). As soon as the progress has reached the end-value, the final steps are executed.
If you manually set the progress to any point behind the end-value, this is handled as if the end-value was reached. You cannot set the progress to a point outside the BossbarCountdown-range, in this case the progress will crapped to the left or right border.