Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<p align="center">
<a href="https://github.com/Falcon-MC/PluginAPI/actions/workflows/ci.yml"><img src="https://github.com/Falcon-MC/PluginAPI/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
<img src="https://img.shields.io/badge/api-v1.3.3-blue" alt="API">
<img src="https://img.shields.io/badge/api-v1.4.0-blue" alt="API">
<img src="https://img.shields.io/badge/language-C%2B%2B17%20%7C%20C%23%20%7C%20Java%20%7C%20Wasm-00599C" alt="Languages">
<img src="https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey" alt="Platform">
</p>
Expand Down Expand Up @@ -135,7 +135,7 @@ A C# plugin is a `net8.0` class library that references `Falcon.PluginAPI` and s
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Falcon.PluginAPI" Version="1.3.3" />
<PackageReference Include="Falcon.PluginAPI" Version="1.4.0" />
</ItemGroup>
</Project>
```
Expand Down Expand Up @@ -191,7 +191,7 @@ A Java plugin is a Java 22 jar that depends on `falcon-plugin-api` with the `pro
<dependency>
<groupId>io.github.falcon-mc</groupId>
<artifactId>falcon-plugin-api</artifactId>
<version>1.3.3</version>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
```
Expand Down Expand Up @@ -220,7 +220,7 @@ full class name and `jar` defaults to `<name>.jar`:
{
"name": "MyPlugin",
"version": "1.0.0",
"api-version": "1.3.3",
"api-version": "1.4.0",
"main": "myplugin.MyPlugin",
"runtime": "java",
"jar": "MyPlugin.jar"
Expand Down
26 changes: 26 additions & 0 deletions dotnet/Falcon.PluginAPI/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,32 @@ public void SendTitle(string title, string subtitle = "")
}
}

/// <summary>
/// Shows a boss bar and returns its id. The newest bar of a player is displayed, the others wait behind it, and
/// a raid bar replaces them all while it is up. Percent goes from 0 to 1. Colors: 0 pink, 1 blue, 2 red,
/// 3 green, 4 yellow, 5 purple, 6 rebecca purple, 7 white.
/// </summary>
public uint AddBossBar(string title, float percent = 1.0f, uint color = 5)
{
fixed (byte* text = NativeApi.Utf8(title))
{
return NativeApi.Table->playerAddBossBar(_handle, text, percent, color);
}
}

public bool UpdateBossBar(uint bar, string title, float percent, uint color = 5)
{
fixed (byte* text = NativeApi.Utf8(title))
{
return NativeApi.Table->playerUpdateBossBar(_handle, bar, text, percent, color) != 0;
}
}

public bool RemoveBossBar(uint bar)
{
return NativeApi.Table->playerRemoveBossBar(_handle, bar) != 0;
}

public void SendActionBar(string message)
{
fixed (byte* text = NativeApi.Utf8(message))
Expand Down
2 changes: 1 addition & 1 deletion examples/java/HelloPlugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "HelloPlugin",
"version": "1.0.0",
"api-version": "1.3.3",
"api-version": "1.4.0",
"main": "falcon.examples.hello.HelloPlugin",
"runtime": "java",
"jar": "HelloPlugin.jar",
Expand Down
2 changes: 1 addition & 1 deletion examples/java/HelloPlugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<properties>
<maven.compiler.release>22</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<falcon.api.version>1.3.3</falcon.api.version>
<falcon.api.version>1.4.0</falcon.api.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.falcon-mc</groupId>
<artifactId>falcon-plugin-api</artifactId>
<version>1.3.3</version>
<version>1.4.0</version>
<packaging>jar</packaging>

<name>Falcon Plugin API</name>
Expand Down
21 changes: 21 additions & 0 deletions java/src/main/java/falcon/api/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,27 @@ public void sendTitle(String title, String subtitle) {
}
}

/**
* Shows a boss bar and returns its id. The newest bar of a player is displayed, the others wait behind it, and a
* raid bar replaces them all while it is up. Percent goes from 0 to 1. Colors: 0 pink, 1 blue, 2 red, 3 green,
* 4 yellow, 5 purple, 6 rebecca purple, 7 white.
*/
public int addBossBar(String title, float percent, int color) {
try (Arena arena = Arena.ofConfined()) {
return api().playerAddBossBar(mHandle, Interop.text(arena, title), percent, color);
}
}

public boolean updateBossBar(int bar, String title, float percent, int color) {
try (Arena arena = Arena.ofConfined()) {
return api().playerUpdateBossBar(mHandle, bar, Interop.text(arena, title), percent, color) != 0;
}
}

public boolean removeBossBar(int bar) {
return api().playerRemoveBossBar(mHandle, bar) != 0;
}

public void sendActionBar(String message) {
try (Arena arena = Arena.ofConfined()) {
api().playerSendActionBar(mHandle, Interop.text(arena, message));
Expand Down
17 changes: 17 additions & 0 deletions native/include/falcon/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ namespace falcon {
detail::api().playerSendTitle(mHandle, title.c_str(), subtitle.c_str());
}

/**
* Shows a boss bar and returns its id. The newest bar of a player is displayed, the others wait behind it, and
* a raid bar replaces them all while it is up. Percent goes from 0 to 1. Colors: 0 pink, 1 blue, 2 red,
* 3 green, 4 yellow, 5 purple, 6 rebecca purple, 7 white.
*/
uint32_t addBossBar(const std::string &title, float percent = 1.0f, uint32_t color = 5) const {
return detail::api().playerAddBossBar(mHandle, title.c_str(), percent, color);
}

bool updateBossBar(uint32_t bar, const std::string &title, float percent, uint32_t color = 5) const {
return detail::api().playerUpdateBossBar(mHandle, bar, title.c_str(), percent, color) != 0;
}

bool removeBossBar(uint32_t bar) const {
return detail::api().playerRemoveBossBar(mHandle, bar) != 0;
}

void sendActionBar(const std::string &message) const {
detail::api().playerSendActionBar(mHandle, message.c_str());
}
Expand Down
8 changes: 6 additions & 2 deletions native/include/falcon/falcon_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ extern "C" {
#endif

#define FALCON_API_VERSION_MAJOR 1
#define FALCON_API_VERSION_MINOR 3
#define FALCON_API_VERSION_PATCH 3
#define FALCON_API_VERSION_MINOR 4
#define FALCON_API_VERSION_PATCH 0
#define FALCON_PLUGIN_ENTRY_NAME "falcon_plugin_entry"

typedef struct FalconPlugin FalconPlugin;
Expand Down Expand Up @@ -433,6 +433,10 @@ typedef struct FalconServerApi {
void (*entitySetInvisible)(FalconEntity *entity, int invisible);

int32_t (*playerProtocolVersion)(FalconPlayer *player);

uint32_t (*playerAddBossBar)(FalconPlayer *player, const char *title, float percent, uint32_t color);
int (*playerUpdateBossBar)(FalconPlayer *player, uint32_t bar, const char *title, float percent, uint32_t color);
int (*playerRemoveBossBar)(FalconPlayer *player, uint32_t bar);
} FalconServerApi;

typedef int (*FalconPluginEntry)(const FalconServerApi *api, FalconPlugin *plugin, FalconPluginCallbacks *callbacks);
Expand Down
3 changes: 3 additions & 0 deletions wasm/falcon.wit
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ interface players {
player-address: func(player: player) -> string;
player-send-title: func(player: player, title: string, subtitle: string);
player-send-action-bar: func(player: player, message: string);
player-add-boss-bar: func(player: player, title: string, percent: f32, color: u32) -> u32;
player-update-boss-bar: func(player: player, bar: u32, title: string, percent: f32, color: u32) -> bool;
player-remove-boss-bar: func(player: player, bar: u32) -> bool;
player-food: func(player: player) -> f32;
player-set-food: func(player: player, food: f32);
player-xp-level: func(player: player) -> s32;
Expand Down
Loading