ActionBarAPI+: Advanced Action Bar Framework for Minecraft Forge your perfect action bars with style, control, and endless possibilities. Introduction ActionBarAPI+ is a comprehensive library for Minecraft servers that provides control over Minecraft's built-in action bar system. This API allows developers to create, manage, and customize action bars with various styles, colors, and behaviors.
I created this API for myself and for my own projects, but I'm sharing it with the community for those who might find it useful. While it works on Minecraft versions 1.10-1.21, please note that not every feature has been thoroughly tested across all versions. As an open-source project, contributions are welcome to improve and extend its functionality.
There is no guarantee that there will be no bugs or issues. I created this while planning to optimize it and fix any issues that may appear only while I use it on other projects and plugins. I will make honest and reasonable attempts to fix any reported issues. After all, the project is open-source so you may contribute if you have anything in mind. Read the Disclaimer for more info.
Features
Send temporary or permanent action bars to players
Apply various visual styles (rolling, rainbow, flashing, gradient, typewriter, wave)
Customize colors and sounds
Global action bars for all players
Modify existing action bars
Pause and resume action bars
Listen to action bar events
Compatible with Minecraft versions 1.10-1.21
Installation Adding as a dependency There is no Maven or Gradle Deployment at the moment.
Manual Installation
Download the latest release from the spigot page.
Add the JAR file to your project's dependencies/libraries in your IDE.
Initialize like shown below
Ensure the JAR file is in your plugins folder.
Use the name "ActionBarAPI-Plus" for plugin.yml depend.
/** * Sends a temporary action bar to a player * @param player The player to send the action bar to * @param message The message to display * @param duration The duration in ticks (20 ticks = 1 second) * @param style The style of the action bar * @param colors List of color names to use * @param sound The sound to play (can be null) */ ActionBarAPI.
sendActionBar(Player player,
String message,
int duration, reception.
Styles style, List
<String
> colors, Sound sound
);
Permanent Action Bars
Code (Java):
/** * Starts a permanent action bar for a player * @param player The player to send the action bar to * @param message The message to display * @param style The style of the action bar * @param colors List of color names to use * @param sound The sound to play (can be null) */ ActionBarAPI.
startActionBar(Player player,
String message, reception.
Styles style, List
<String
> colors, Sound sound
);
Global Action Bars
Code (Java):
/** * Sends a temporary global action bar to all online players */ ActionBarAPI.
sendGlobalActionBar(String message,
int duration, reception.
Styles style, List
<String
> colors, Sound sound
); /** * Starts a permanent global action bar for all online players */ ActionBarAPI.
startGlobalActionBar(String message, reception.
Styles style, List
<String
> colors, Sound sound
);
Stopping Action Bars
Code (Java):
/** * Stops an active action bar for the specified player * @return true if an action bar was stopped, false if no action bar was active */ ActionBarAPI.
stopActionBar(Player player
);
Modifying Action Bars
Code (Java):
/** * Modifies an active action bar for the specified player * @return true if an action bar was modified, false if no action bar was active */ ActionBarAPI.
modifyActionBar(Player player,
String newMessage
);
Styles
Code (Java):
reception.
Styles.
rolling// Text rolls in from the right reception.
Styles.
rainbow// Text cycles through rainbow colors reception.
Styles.
flashing// Text flashes between colors reception.
Styles.
gradient// Text displays a color gradient reception.
Styles.
typewriter// Text appears character by character reception.
Styles.
wave// Text displays a wave effect
Events The API fires various events that you can listen to:
ActionBarSentEvent - Fired when an action bar is sent to a player
ActionBarStartedEvent - Fired when a permanent action bar is started
ActionBarTaskEndedEvent - Fired when an action bar task ends naturally
ActionBarTaskModifiedEvent - Fired when an action bar is modified
ActionBarTaskPausedEvent - Fired when an action bar is paused
ActionBarTaskResumedEvent - Fired when a paused action bar is resumed
ActionBarTaskStoppedEvent - Fired when an action bar is stopped manually
Bukkit.
getPluginManager().
registerEvents(this,
this); new ActionBarAPI
(this);
}
// !!! // This is just a Usage example, it assumes player full health initially // and does not handle regen event // and does not handle player death either. // Although those could be implemented similarly to this. // !!!
@EventHandler
publicvoid onPlayerJoin
(PlayerJoinEvent event
){ Player player
= event.
getPlayer(); ActionBarAPI.
sendActionBar(player,
"Welcome to the server",
100, reception.
Styles.
rainbow,
Arrays.
asList(/*Leave empty because rainbow style ignores provided colors and just uses rainbow*/),
Sound.
ENTITY_PLAYER_LEVELUP ); }
public UUID welcomeEventID
; String health
="Health: ❤❤❤❤❤❤❤❤❤❤";
@EventHandler
publicvoid ActionBarSentEvent
(ActionBarSentEvent event
){ // Confirm this is the event sent on player join if(event.
getMessage().
equals("Welcome to the server")){ welcomeEventID
= event.
getTaskId();// store ID of event } }
@EventHandler
publicvoid ActionBarTaskEndedEvent
(ActionBarTaskEndedEvent event
){ // check if what has ended is the welcome message task if(event.
getTaskId()==welcomeEventID
){ // we confirmed the welcome message has ended, we can start health bar task. ActionBarAPI.
startActionBar( event.
getPlayer(),
health,
reception.
Styles.
flashing,
Arrays.
asList("RED",
"WHITE"),
Sound.
ENTITY_PLAYER_LEVELUP); } }
@EventHandler
publicvoid playerHurt
(EntityDamageEvent event
){ if(!(event.
getEntity()instanceof Player
))return; Player player
=(Player
) event.
getEntity();
// calculate remaining health after damage (in heart units) one heart = 2 health points double currentHealth
= player.
getHealth(); double damageAmount
= event.
getFinalDamage(); double healthAfterDamage
=Math.
max(0, currentHealth
- damageAmount
);// make sure result isnt negative (otherwise player is dead) int heartsAfterDamage
=(int)Math.
floor(healthAfterDamage
/2.0); // I do not have a half heart emoji so in case of half heart, we just truncate to no heart
Bukkit.
getScheduler().
runTask(this,
()->{ // build until heartsafterdamage is fulfilled StringBuilder newhealth
=new StringBuilder
(); for(int i
=0; i
< heartsAfterDamage
; i
++){ newhealth.
append("❤"); }
// modify already started action bar ActionBarAPI.
modifyActionBar(player,
"Health: "+ newhealth.
toString()); }); }
importcom.codingguru.actionBarAPI.events.*; importorg.bukkit.event.EventHandler; importorg.bukkit.event.Listener; publicclass ActionBarListener
implements Listener
{ @EventHandler
publicvoid onActionBarSent
(ActionBarSentEvent event
){ System.
out.
println("Action bar sent to "+ event.
getPlayer().
getName()+": "+ event.
getMessage()); } @EventHandler
publicvoid onActionBarTaskEnded
(ActionBarTaskEndedEvent event
){ System.
out.
println("Action bar ended for "+ event.
getPlayer().
getName()); } @EventHandler
publicvoid onActionBarTaskModified
(ActionBarTaskModifiedEvent event
){ System.
out.
println("Action bar modified for "+ event.
getPlayer().
getName()+ " from \""+ event.
getOldMessage()+"\" to \""+ event.
getNewMessage()+"\""); } }
Testing The plugin includes a test command that demonstrates (mostly) all the features of the API:
Code (Text):
/actionbarapiplus runtest
This command requires the permission
actionbarapiplus.runtest and will run a comprehensive test of all API features.
Warning: This test will cancel all running action bar tasks for all players on the server and may cause lag spikes. It is not recommended to run this on a production server (Run it on a dev server instead)
Compatibility ActionBarAPI+ is designed to work with Minecraft versions 1.10-1.21. However, not all features have been thoroughly tested on all versions. If you encounter any issues, please report them on the GitHub repository.
Known Limitations
The API may conflict with other plugins that use the action bar at the same time
Global action bars can impact server performance with many players online
Contributing Contributions are welcome! If you'd like to contribute to the project, please:
Submit a pull request
Give feedback or suggestions
Report any bugs or issues
License This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer This API was created for personal use and is shared as-is without warranty. While efforts have been made to ensure functionality, you may encounter bugs or issues. Use at your own risk.
For custom plugins on your own server, this API can be very useful. However, it's not recommended for plugins intended for public release due to potential conflicts with other action bar implementations.