### Set and reset height overlay with HeightOverlay Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/examples.md Shows how to enable the height overlay mod for players using HeightOverlay.setCurrentMap() with either a player UUID or for all players, and reset it with HeightOverlay.reset(). The example sets the map and height when a game starts and resets when it ends, with options for specific players or the entire server. ```java public class Game { // Find a suitable place in your code where you like to invoke the height limit mod hooks, // preferably when the game starts or players have been teleported to the right world. public void onGameStart(Collection players) { final String map = "Lion Valley"; final int height = 85; boolean specificPlayers = true; // You have two approaches here, the height overlay can either be set for the entire server; or just specific players. // Setting for specific players could be done like below if (specificPlayers) { for (Player player : players) { HeightOverlay.setCurrentMap(player.getUniqueId(), map, height); } } else { // Or if you would rather set the height overlay hook to apply for every player online, you would just leave out the UUID parameter. HeightOverlay.setCurrentMap(map, height); } } public void onGameEnded(Collection players) { // Just like with setting the current map and height, you also have an option to reset for every player or specific players. boolean specificPlayers = true; if (specificPlayers) { for (Player player : players) { HeightOverlay.reset(player.getUniqueId()); } } else { HeightOverlay.reset(); } } } ``` -------------------------------- ### Usage example Source: https://github.com/badlionclient/badlionclientmodapi Example of accessing the API and its managers from application code, including sending raw data to the client. ```APIDOC ## Usage example ### Description Example of accessing the API and its managers from application code, including sending raw data to the client. ### Code ```java import net.badlion.modapicommon.AbstractBadlionApi; public class ApiUsage { public void inspect() { AbstractBadlionApi api = AbstractBadlionApi.getInstance(); // Manager access (implementation-specific or null before plugin init) api.getWaypointManager(); api.getCosmeticManager(); api.getSurvivalManager(); api.getTeamMarkerManager(); // Sending raw data to the client (GSON instances are shared) com.google.gson.JsonObject payload = new com.google.gson.JsonObject(); payload.addProperty("example", true); api.getPluginMessageSender().sendData("exampleType", payload); } } ``` ``` -------------------------------- ### Nick integration usage example Source: https://github.com/badlionclient/badlionclientmodapi Example of integrating Cosmetics.disableNametagCosmetics and enableNametagCosmetics into a Bukkit NickManager. ```java import net.badlion.modapicommon.cosmetics.Cosmetics; import org.bukkit.entity.Player; public class NickManager { public void addUserNick(Player player) { // ... your own nick logic Cosmetics.disableNametagCosmetics(player.getUniqueId()); } public void removeUserNick(Player player) { // ... your own nick logic Cosmetics.enableNametagCosmetics(player.getUniqueId()); } } ``` -------------------------------- ### Example JSON: limits and mod/feature control Source: https://github.com/badlionclient/badlionclientmodapi Shows a configuration object with click limits and mod disallow/feature toggles. Uses keys like clicksPerSecondLimitRight, clicksPerSecondLimit, modsDisallowed, and extra_data with disabled flags. Forced-feature examples include Schematica printerEnabled.forced and Animations removeHitDelay.forced. ```json { "clicksPerSecondLimitRight": 20, "clicksPerSecondLimit": 10, "modsDisallowed": { "Waypoints": { "disabled": true }, "MiniMap": { "disabled": true }, "ToggleSneak": { "disabled": false, "extra_data": { "inventorySneak": { "disabled": true } } }, "ToggleSprint": { "disabled": false, "extra_data": { "flySpeed": { "disabled": true } } } } } ``` -------------------------------- ### survival.json features example Source: https://github.com/badlionclient/badlionclientmodapi Example of the survival.json configuration file for Bukkit 1.17+ servers. The features array accepts SurvivalFeature enum names; unknown names are ignored on load. Changes are written on debounced updates and pushed live without restart. ```json { "features": ["SHOW_ENDERCHEST_INVENTORY", "SEARCH_BAR"] } ``` -------------------------------- ### Error handling on proxy platforms Source: https://github.com/badlionclient/badlionclientmodapi Example of catching UnsupportedOperationException when running on BungeeCord or Velocity. ```java import net.badlion.modapicommon.cosmetics.Cosmetics; import java.util.UUID; public class GuardedCosmetics { public void hideNametag(UUID uuid) { try { Cosmetics.disableNametagCosmetics(uuid); } catch (UnsupportedOperationException ex) { // thrown when running on BungeeCord / Velocity log(ex.getMessage()); } } } ``` -------------------------------- ### Explicit per-player handling example Source: https://github.com/badlionclient/badlionclientmodapi Example showing how to set and reset the height overlay for a specific player using their UUID. ```java import net.badlion.modapicommon.mods.HeightOverlay; import java.util.UUID; public class SwitchingMaps { public void moveToMap(UUID player, String mapName, int maxHeight) { HeightOverlay.setCurrentMap(player, mapName, maxHeight); } public void leaveMap(UUID player) { HeightOverlay.reset(player); } } ``` -------------------------------- ### Example config disabling mods and limiting CPS Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/readme.md Place this JSON into plugins/BadlionClientModAPI/config.json. Invalid JSON will prevent the plugin from loading. This config disables Waypoints and MiniMap, blocks inventorySneak and flySpeed features, and limits right-click CPS to 20 and left-click CPS to 10. Values of 0 or below for CPS fields mean no limitation. ```json { "clicksPerSecondLimitRight": 20, "clicksPerSecondLimit": 10, "modsDisallowed": { "Waypoints": { "disabled": true }, "MiniMap": { "disabled": true }, "ToggleSneak": { "disabled": false, "extra_data": { "inventorySneak": { "disabled": true } } }, "ToggleSprint": { "disabled": false, "extra_data": { "flySpeed": { "disabled": true } } } } } ``` -------------------------------- ### Per-game height overlay usage example Source: https://github.com/badlionclient/badlionclientmodapi Example from examples.md showing how to set and reset the height overlay for all players and per-player during a game lifecycle. ```java import net.badlion.modapicommon.mods.HeightOverlay; import org.bukkit.entity.Player; import java.util.Collection; public class Game { public void onGameStart(Collection players) { final String map = "Lion Valley"; final int height = 85; // Per-player variant for (Player player : players) { HeightOverlay.setCurrentMap(player.getUniqueId(), map, height); } // Server-wide variant (omit the UUID) HeightOverlay.setCurrentMap(map, height); } public void onGameEnded(Collection players) { for (Player player : players) { HeightOverlay.reset(player.getUniqueId()); } HeightOverlay.reset(); } } ``` -------------------------------- ### Usage example: building against the plugin classes Source: https://github.com/badlionclient/badlionclientmodapi Shows how to access the Badlion plugin API from a Bukkit plugin that depends on bukkit-common / bukkit-1.17. Obtains the WaypointManager, TimerApi, BukkitBadlionApi, and SurvivalManager from an AbstractBukkitBadlionPlugin instance. ```java import net.badlion.bukkitapi.AbstractBukkitBadlionPlugin; import net.badlion.bukkitapi.waypoints.WaypointManager; // From inside a Bukkit plugin that depends on bukkit-common / bukkit-1.17 public class MyPlugin extends JavaPlugin { private AbstractBukkitBadlionPlugin badlionPlugin; void tieIn(AbstractBukkitBadlionPlugin badlionPlugin) { this.badlionPlugin = badlionPlugin; WaypointManager waypoints = badlionPlugin.getWaypointManager(); badlionPlugin.getTimerApi(); // TimerApiImpl badlionPlugin.getBadlionApi(); // BukkitBadlionApi badlionPlugin.getSurvivalManager(); // survival features state } } ``` -------------------------------- ### Catch RuntimeException from Notification.Builder.build() Source: https://github.com/badlionclient/badlionclientmodapi Both title and description must be set before build(); otherwise a RuntimeException is thrown. The example catches the unchecked exception when description is missing. ```java try { Notification notification = Notification.newNotification().setTitle("t").build(); } catch (RuntimeException ex) { // "Description of notification must be set!" } ``` -------------------------------- ### Whitelist AutoText commands Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/readme.md Instead of disabling the AutoText mod, this config whitelists specific commands that players are allowed to use. The example allows /warp and /help. ```json { "modsDisallowed": { "AutoText": { "disabled": false, "settings": { "whitelistedCommands": [ "/warp", "/help" ] } } } } ``` -------------------------------- ### Welcome notification usage example Source: https://github.com/badlionclient/badlionclientmodapi Sends a welcome notification to a player on join using Notifications.sendNotification. Requires a PlayerJoinEvent listener and imports from net.badlion.modapicommon. The notification is built with title, description, duration, and level. ```java import net.badlion.modapicommon.mods.Notifications; import net.badlion.modapicommon.utility.Notification; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; public class PlayerListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { final Notification notification = Notification.newNotification() .setTitle("Welcome!") .setDescription("Welcome to our server, " + event.getPlayer().getName() + ".") .setDurationSeconds(4) .setLevel(Notification.Level.INFO) .build(); Notifications.sendNotification(event.getPlayer().getUniqueId(), notification); } } ``` -------------------------------- ### GuardedWaypointCreator example Source: https://github.com/badlionclient/badlionclientmodapi Example showing error handling when calling createWaypoint on unsupported platforms like Bungee or Velocity, where it throws UnsupportedOperationException with a message like 'Waypoint mod hooks are not supported on bungee!'. ```java import net.badlion.modapicommon.mods.Waypoints; import net.badlion.modapicommon.utility.Location; public class GuardedWaypointCreator { public void create(UUID player) { try { Waypoints.createWaypoint(player, Location.of("world", 100, 64, 100), "Spawn", false); } catch (UnsupportedOperationException ex) { // "Waypoint mod hooks are not supported on bungee!" (or velocity) log(ex.getMessage()); } } } ``` -------------------------------- ### PlayerDeathListener example Source: https://github.com/badlionclient/badlionclientmodapi Example listener that creates a waypoint at a player's death location and stores it for later deletion. Shows usage of Waypoints.createWaypoint and Waypoints.deleteWaypoint with a stored Waypoint. ```java import net.badlion.modapicommon.mods.Waypoints; import net.badlion.modapicommon.utility.Location; import net.badlion.modapicommon.utility.Waypoint; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; import java.util.*; public class PlayerDeathListener implements Listener { private final Map> waypoints = new HashMap<>(); @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { final org.bukkit.entity.Player player = event.getEntity(); final org.bukkit.Location deathLocation = player.getLocation(); final Location waypointLocation = Location.of( deathLocation.getWorld().getName(), deathLocation.getBlockX(), deathLocation.getBlockY(), deathLocation.getBlockZ()); final Waypoint waypoint = Waypoints.createWaypoint( player.getUniqueId(), waypointLocation, player.getName() + "'s Last Death", true); this.waypoints.computeIfAbsent(player.getUniqueId(), k -> new ArrayList<>()).add(waypoint); } // Deletion requires the stored Waypoint (or its id) public void removeDeathWaypoint(UUID uuid, Waypoint waypoint) { Waypoints.deleteWaypoint(uuid, waypoint.getId()); } } ``` -------------------------------- ### Running mod hooks from a Bungee plugin Source: https://github.com/badlionclient/badlionclientmodapi Shows how to use message-based hooks like TNTTime.setFuseOffset on a Bungee proxy. Requires the BadlionClientModAPI Bungee plugin to be installed on the same proxy; its constructor registers the AbstractBadlionApi singleton. ```java import net.badlion.bungeeapi.BungeeBadlionPlugin; import net.badlion.modapicommon.mods.TNTTime; import net.md_5.bungee.api.plugin.Plugin; public class MyBungeeAddon extends Plugin { // The BadlionClientModAPI bungee plugin must be installed on the same proxy; // its constructor registers the AbstractBadlionApi singleton. public void start() { // Message-based hooks work on the proxy: TNTTime.setFuseOffset(40); } } ``` -------------------------------- ### Global offset with negative values usage example Source: https://github.com/badlionclient/badlionclientmodapi Example class that applies a -20 tick fuse offset globally (making the fuse 20 ticks faster than vanilla) and resets it for all players. ```java import net.badlion.modapicommon.mods.TNTTime; public class GlobalTnt { public void applyFasterFuse() { // 20 ticks faster than vanilla (1 second) TNTTime.setFuseOffset(-20); } public void clearAll() { TNTTime.resetFuseOffset(); } } ``` -------------------------------- ### Error handling for unsupported platforms Source: https://github.com/badlionclient/badlionclientmodapi Example showing how to catch UnsupportedOperationException when calling TeamMarker.sendLocations on Bungee/Velocity, where the manager is UnsupportedTeamMarkerManager and throws this exception. ```java import net.badlion.modapicommon.mods.TeamMarker; import net.badlion.modapicommon.utility.TeamMemberLocation; import java.util.Collections; import java.util.UUID; public class TeamUpdater { public void update(UUID recipient, UUID teammate) { try { TeamMarker.sendLocations(recipient, Collections.singletonList( new TeamMemberLocation(teammate, 0x55FFFF, 10.5, 64.0, -20.25))); } catch (UnsupportedOperationException ex) { // "Team Marker mod hooks are not supported on bungee!" — also thrown on velocity log(ex.getMessage()); } } } ``` -------------------------------- ### Per-world fuse offset usage example Source: https://github.com/badlionclient/badlionclientmodapi Example listener that applies a +40 tick fuse offset in a specific world and resets it in the normal world. Uses the player-specific overloads of setFuseOffset and resetFuseOffset. ```java import net.badlion.modapicommon.mods.TNTTime; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerChangedWorldEvent; public class PlayerListener implements Listener { @EventHandler public void onChangedWorld(PlayerChangedWorldEvent event) { if ("tnt-example-world".equals(event.getPlayer().getWorld().getName())) { // Extra 40 ticks on top of vanilla 80 -> 120 tick fuse TNTTime.setFuseOffset(event.getPlayer().getUniqueId(), 40); } else if ("world".equals(event.getPlayer().getWorld().getName())) { // Back to normal world: remove the offset TNTTime.resetFuseOffset(event.getPlayer().getUniqueId()); } } } ``` -------------------------------- ### Periodic team updates with TeamMarkerTask Source: https://github.com/badlionclient/badlionclientmodapi BukkitRunnable example that sends team member locations on a repeating task faster than 3 seconds; the client drops points after 5 seconds without updates. Uses TeamMarker.sendLocations and TeamMemberLocation constructor. ```java import net.badlion.modapicommon.mods.TeamMarker; import net.badlion.modapicommon.utility.TeamMemberLocation; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; import java.util.List; // Send on a repeating task faster than 3s; the client drops points after 5s without updates public class TeamMarkerTask extends BukkitRunnable { @Override public void run() { for (Team team : Plugin.getTeamManager().getTeams()) { // example team source List locations = new ArrayList<>(); for (Player player : team.getMembers()) { org.bukkit.Location location = player.getLocation(); locations.add(new TeamMemberLocation( player.getUniqueId(), team.getColor(), location.getX(), location.getY(), location.getZ())); } for (Player player : team.getMembers()) { TeamMarker.sendLocations(player.getUniqueId(), locations); } } } } ``` -------------------------------- ### Set and reset TNT fuse offset with TNTTime Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/examples.md Uses TNTTime.setFuseOffset() to add a positive or negative offset to the TNT fuse time for a player, and TNTTime.resetFuseOffset() to clear it. The example listens for a player changing worlds and applies the offset only in a specific world, resetting it when the player returns to the normal world. ```java public class PlayerListener implements Listener { @EventHandler public void onChangedWorld(PlayerChangedWorldEvent event) { boolean positiveOffset = true; // Player changed to a world where the TNT fuse time is slower, let's apply that for the Badlion TNTTime mod. if ("tnt-example-world".equals(event.getPlayer().getWorld().getName())) { if (positiveOffset) { // This would set the fuse offset in TNT time to be an extra 40 ticks, outover vanilla 80 ticks. TNTTime.setFuseOffset(event.getPlayer().getUniqueId(), 40); } else { // You could also make the TNT time offset quicker, by instead providing a negative offset value. // The fuse time would now be 1 second (20 ticks) faster. TNTTime.setFuseOffset(event.getPlayer().getUniqueId(), -20); } } else if ("world".equals(event.getPlayer().getWorld().getName())) { // When the player is back in the normal world we want to reset the fuse offset for the player, which can be easily done like below. TNTTime.resetFuseOffset(event.getPlayer().getUniqueId()); } } } ``` -------------------------------- ### Timer interface Source: https://github.com/badlionclient/badlionclientmodapi The Timer interface represents a countdown timer that can be configured with a name, item, time, and receivers. It provides methods to get and set timer properties, manage receivers, and reset the countdown. ```APIDOC ## Timer interface ### Description The Timer interface represents a countdown timer that can be configured with a name, item, time, and receivers. It provides methods to get and set timer properties, manage receivers, and reset the countdown. ### Methods - `long getId()` - Returns the unique timer id. - `String getName()` - Returns the text displayed in the client. - `void setName(String name)` - Sets the text displayed in the client. - `ItemStack getItem()` - Returns the icon. - `void setItem(ItemStack item)` - Sets the icon; `setItem(null)` is not allowed. - `boolean isRepeating()` - Returns whether the timer repeats when reaching 0. - `void setRepeating(boolean repeating)` - Sets whether the timer repeats when reaching 0. - `long getTime()` - Returns the countdown in ticks. - `void setTime(long time)` - Sets the countdown in ticks; implies a call to `reset()`. - `long getMillis()` - Returns the countdown in milliseconds. - `void setTime(long time, TimeUnit timeUnit)` - Sets the countdown in milliseconds; also implies `reset()`. - `void addReceiver(Player player)` - Adds a receiver; disconnecting players are auto-removed. - `void removeReceiver(Player player)` - Manually removes a receiver. - `void clearReceivers()` - Removes all receivers. - `Collection getReceivers()` - Returns a thread-safe receiver collection. - `void reset()` - Resets countdown to `getTime()` value. ``` -------------------------------- ### Accessing API and managers from application code Source: https://github.com/badlionclient/badlionclientmodapi Shows how to obtain the AbstractBadlionApi instance and access its managers. Managers return null before plugin initialization. Also demonstrates sending raw data to the client via the plugin message sender, sharing GSON instances. ```java import net.badlion.modapicommon.AbstractBadlionApi; public class ApiUsage { public void inspect() { AbstractBadlionApi api = AbstractBadlionApi.getInstance(); // Manager access (implementation-specific or null before plugin init) api.getWaypointManager(); api.getCosmeticManager(); api.getSurvivalManager(); api.getTeamMarkerManager(); // Sending raw data to the client (GSON instances are shared) com.google.gson.JsonObject payload = new com.google.gson.JsonObject(); payload.addProperty("example", true); api.getPluginMessageSender().sendData("exampleType", payload); } } ``` -------------------------------- ### getInstance() Source: https://github.com/badlionclient/badlionclientmodapi Returns the current Badlion API instance. Returns null if no platform plugin has constructed one yet. ```APIDOC ## getInstance() ### Description Returns the current Badlion API instance. Returns null if no platform plugin has constructed one yet. ### Method Static method ### Signature ```java public static AbstractBadlionApi getInstance() ``` ### Returns - `AbstractBadlionApi` - The current Badlion API instance; `null` if no platform plugin has constructed one yet ``` -------------------------------- ### loadConfig(File file) abstract method Source: https://github.com/badlionclient/badlionclientmodapi Loads the Badlion API configuration. FileNotFoundException is handled internally by each implementation (a default config is written); other IOException cases propagate. JSON syntax errors cause Gson's JsonSyntaxException (a RuntimeException) to escape, which can abort plugin enablement. ```java public abstract void loadConfig(File file) throws IOException; ``` -------------------------------- ### loadConfig(File file) throws IOException Source: https://github.com/badlionclient/badlionclientmodapi Loads the Badlion API configuration. FileNotFoundException is handled internally by each implementation (a default config is written); other IOException cases propagate. JSON syntax errors in an existing config cause Gson's JsonSyntaxException (a RuntimeException) to escape. ```APIDOC ## loadConfig(File file) throws IOException ### Description Loads the Badlion API configuration. FileNotFoundException is handled internally by each implementation (a default config is written); other IOException cases propagate. JSON syntax errors in an existing config cause Gson's JsonSyntaxException (a RuntimeException) to escape. ### Method Abstract method ### Signature ```java public abstract void loadConfig(File file) throws IOException; ``` ### Parameters - `file` (File) - Required - Config file to load ``` -------------------------------- ### Notification.Builder.build() Source: https://github.com/badlionclient/badlionclientmodapi Finishes building the notification. Throws RuntimeException if title or description is missing. ```APIDOC ## Notification.Builder.build() ### Description Finishes building the notification. Throws RuntimeException if title or description is missing. ### Method builder method ### Endpoint Notification.Builder.build() ### Parameters None ### Response #### Success Response - **Notification** - The built notification. #### Error Response - **RuntimeException** - If title or description is missing. ``` -------------------------------- ### saveConfig(Config config, File file) abstract method Source: https://github.com/badlionclient/badlionclientmodapi Saves the given configuration to the specified file. ```java public abstract void saveConfig(Config config, File file); ``` -------------------------------- ### getBadlionConfig() Source: https://github.com/badlionclient/badlionclientmodapi Returns the loaded net.badlion.modapicommon.Config instance. ```APIDOC ## getBadlionConfig() ### Description Returns the loaded net.badlion.modapicommon.Config instance. ### Method Abstract method ### Signature ```java public abstract Config getBadlionConfig(); ``` ### Returns - `Config` - The loaded `net.badlion.modapicommon.Config` instance ``` -------------------------------- ### getBadlionConfig() abstract method Source: https://github.com/badlionclient/badlionclientmodapi Returns the loaded net.badlion.modapicommon.Config instance. ```java public abstract Config getBadlionConfig(); ``` -------------------------------- ### Waypoints class with global counter Source: https://github.com/badlionclient/badlionclientmodapi The Waypoints class maintains a static counter for assigning sequential IDs to created waypoints, starting at 0. This counter is shared across all players in the process. ```java public class Waypoints { private static int currentIndexId = 0; ``` -------------------------------- ### Notification.Builder.build() Source: https://github.com/badlionclient/badlionclientmodapi Builds a Notification instance. Throws RuntimeException if required fields are not set before calling build(). ```APIDOC ## Notification.Builder.build() ### Description Builds a Notification instance. Throws RuntimeException if required fields are not set before calling build(). ### Method build() ### Exceptions - **RuntimeException** - Thrown when `setTitle(...)` was never called before `build()` (message: "Title of notification must be set!"). - **RuntimeException** - Thrown when `setDescription(...)` was never called before `build()` (message: "Description of notification must be set!"). ### Request Example ```java try { Notification notification = Notification.newNotification().setTitle("t").build(); } catch (RuntimeException ex) { // "Description of notification must be set!" } ``` ``` -------------------------------- ### Send notifications with buttons using Notifications class Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/examples.md Java listener that sends a simple notification and a notification with buttons on player join. The first notification displays for 4 seconds with INFO level. The second, sent after a 5-second delay, includes two buttons: one opens the Badlion rules URL, the other runs the /help command. Uses Notification.newNotification() builder and Notifications.sendNotification(). ```java public class PlayerListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { // A simple notification would be constructed like this, where it would show a notification // for the player for 4 seconds with the text as provided below. final Notification notification = Notification.newNotification() .setTitle("Welcome!") .setDescription("Welcome to our server, " + event.getPlayer().getName() + ".") .setDurationSeconds(4) .setLevel(Notification.Level.INFO) .build(); // And the notification would be sent like: Notifications.sendNotification(event.getPlayer().getUniqueId(), notification); // Our notifications can also include buttons with click events, say you want // a button to bring the player to your rules page, or perform a command. Bukkit.getScheduler().runTaskLater(this.plugin, () -> { // What this code will do is create a notification where the user is presented with // two buttons, the first one will bring up a selection menu to open the URL provided, // where the second one will execute a command for the player. final Notification helpNotification = Notification.newNotification() .setTitle("Good to know") .setDescription("We remind you to check our rules, and to look for help if needed!") .setDurationSeconds(5) .setLevel(Notification.Level.INFO) .addButton(new NotificationButton("Read rules", NotificationButton.Action.OPEN_URL, "https://www.badlion.net/wiki/rules")) .addButton(new NotificationButton("Get help", NotificationButton.Action.RUN_COMMAND, "/help")) .build(); Notifications.sendNotification(event.getPlayer().getUniqueId(), helpNotification); }, 5 * 20); // Run this task after 5 seconds. } } ``` -------------------------------- ### AbstractBukkitBadlionPlugin constructor wiring managers Source: https://github.com/badlionclient/badlionclientmodapi Base class constructor that initializes the singleton API, timer engine, waypoint manager, cosmetic manager, and team marker manager. Subclasses must call setMessageSender(...) and setSurvivalManager(...) after construction. ```java public AbstractBukkitBadlionPlugin() { this.badlionApi = new BukkitBadlionApi(this); this.timerApi = new TimerApiImpl(this); this.waypointManager = new WaypointManager(this); this.badlionApi.setWaypointManager(this.waypointManager); this.cosmeticManager = new CosmeticManager(); this.badlionApi.setCosmeticManager(this.cosmeticManager); this.badlionApi.setTeamMarkerManager(new TeamMarkerManager(this)); } ``` -------------------------------- ### TimerApi.getInstance() Source: https://github.com/badlionclient/badlionclientmodapi Returns the global TimerApi instance. ```APIDOC ## TimerApi.getInstance() ### Description Returns the global TimerApi instance. ### Method getInstance ### Parameters None ### Response Returns the TimerApi instance. ``` -------------------------------- ### AbstractBadlionApi protected constructor Source: https://github.com/badlionclient/badlionclientmodapi Protected constructor that registers the instance as the global singleton. Called by platform subclasses (BukkitBadlionApi, BungeeBadlionApi, VelocityBadlionApi) during plugin construction. ```java protected AbstractBadlionApi() { AbstractBadlionApi.instance = this; } ``` -------------------------------- ### getInstance() static method Source: https://github.com/badlionclient/badlionclientmodapi Returns the current Badlion API instance, or null if no platform plugin has constructed one yet. ```java public static AbstractBadlionApi getInstance() { return AbstractBadlionApi.instance; } ``` -------------------------------- ### BungeeBadlionPlugin constructor Source: https://github.com/badlionclient/badlionclientmodapi Registers the BungeeBadlionApi singleton and sets unsupported managers for waypoints, cosmetics, survival, and team markers. These managers throw UnsupportedOperationException on hook calls because the proxy cannot run Bukkit-dependent features. ```java public class BungeeBadlionPlugin extends Plugin { private final BungeeBadlionApi badlionApi; private final BungeePluginMessageSender messageSender; public BungeeBadlionPlugin() { super(); this.badlionApi = new BungeeBadlionApi(this); this.messageSender = new BungeePluginMessageSender(this); this.badlionApi.setWaypointManager(new UnsupportedWaypointManager()); this.badlionApi.setCosmeticManager(new UnsupportedCosmeticManager()); this.badlionApi.setSurvivalManager(new UnsupportedSurvivalManager()); this.badlionApi.setTeamMarkerManager(new UnsupportedTeamMarkerManager()); } ``` -------------------------------- ### SurvivalApi static facade methods Source: https://github.com/badlionclient/badlionclientmodapi Static facade over the registered AbstractSurvivalManager. Functional only on Bukkit 1.17+; on legacy Bukkit and proxies all methods throw UnsupportedOperationException. ```java public class SurvivalApi { public static void enableAllFeatures() { AbstractBadlionApi.getInstance().getSurvivalManager().enableAllFeatures(); } public static void disableAllFeatures() { AbstractBadlionApi.getInstance().getSurvivalManager().disableAllFeatures(); } public static void enableFeature(SurvivalFeature feature) { AbstractBadlionApi.getInstance().getSurvivalManager().enableFeature(feature); } public static void disableFeature(SurvivalFeature feature) { AbstractBadlionApi.getInstance().getSurvivalManager().disableFeature(feature); } public static Set getEnabledFeatures() { return AbstractBadlionApi.getInstance().getSurvivalManager().getEnabledFeatures(); } } ``` -------------------------------- ### BukkitBadlionPlugin for MC 1.17+ (bukkit-1.17 module) Source: https://github.com/badlionclient/badlionclientmodapi Plugin constructor and onEnable that set up the full survival API: SurvivalManager, SurvivalGui, EnderchestListener, and the /survivalapi command (permission badlion.survival per plugin.yml). The command executor is set via Objects.requireNonNull(this.getCommand("survivalapi")).setExecutor(new SurvivalCommand(this)). ```java public class BukkitBadlionPlugin extends AbstractBukkitBadlionPlugin { public BukkitBadlionPlugin() { this.setMessageSender(new BukkitPluginMessageSender(this)); this.setSurvivalManager(new SurvivalManager(this)); } @Override public void onEnable() { super.onEnable(); this.survivalGui = new SurvivalGui(this); this.getServer().getPluginManager().registerEvents(new EnderchestListener(this), this); Objects.requireNonNull(this.getCommand("survivalapi")).setExecutor(new SurvivalCommand(this)); } public SurvivalGui getSurvivalGui() { return this.survivalGui; } } ``` -------------------------------- ### Enable Schematica printer mode Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/readme.md Allows the Schematica printer mode on your server. By default, printer mode cannot be enabled on servers; this API configuration forces it to be enabled. ```json { "modsDisallowed": { "Schematica": { "disabled": false, "extra_data": { "printerEnabled": { "forced": true } } } } } ``` -------------------------------- ### Forced features (Schematica printer, 1.8 hit delay) Source: https://github.com/badlionclient/badlionclientmodapi Shows how to force-enable Schematica's printer and Animations' removeHitDelay via extra_data with "forced": true. The client interprets these flags; a JSON syntax error in config.json aborts plugin startup on each platform. ```json { "modsDisallowed": { "Schematica": { "disabled": false, "extra_data": { "printerEnabled": { "forced": true } } }, "Animations": { "disabled": false, "extra_data": { "removeHitDelay": { "forced": true } } } } } ``` -------------------------------- ### onProxyInitialization with @Subscribe Source: https://github.com/badlionclient/badlionclientmodapi Event handler for proxy initialization. Loads config from config.json and registers PlayerListener only if config loads successfully. Placeholder comments indicate data folder creation and additional logic. ```java @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { ...create data folder... this.badlionApi.loadConfig(new File(this.getDataFolder(), "config.json")); // Only register the listener if the config loads successfully this.getProxy().getEventManager().register(this, new PlayerListener(this)); ... } ``` -------------------------------- ### Create and delete waypoints with Waypoints API Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/examples.md Uses `net.badlion.modapicommon.mods.Waypoints` to create waypoints remotely from a server, provided the user allows it. Creates a waypoint at a player's death location in a `PlayerDeathEvent` listenerainer, stores it in a map, and shows deletion via `Waypoints.deleteWaypoint()` using a stored waypoint ID. ```java /** * You can hook into our waypoints mod as well to remotely create waypoints for players. * This example will show how you could add a waypoint for a player of their death location. */ public class PlayerDeathListener implements Listener { // A map we will use in this example for keeping track of player waypoints. private final Map> waypoints = new HashMap<>(); @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { final Player player = event.getEntity(); final org.bukkit.Location deathLocation = player.getLocation(); // Here we create the location object for our waypoint, // which is going to be the location of the player when they died. final Location waypointLocation = Location.of( deathLocation.getWorld().getName(), deathLocation.getBlockX(), deathLocation.getBlockY(), deathLocation.getBlockZ()); // A simple boolean for whether the player is permitted to add this // waypoint into their waypoint mod, to keep it permanently. boolean allowedToAdd = true; // Create a waypoint for the player who died, with the name "PlayerName's Last Death" final Waypoint waypoint = Waypoints.createWaypoint( player.getUniqueId(), // A uuid of the player this action is for waypointLocation, // The location of the waypoint player.getName() + "'s Last Death", // The name of the waypoint allowedToAdd); // We can then get the list of waypoints this player has from the map we // made earlier If it does not exist, we're creating a new list value in // our map using computeIfAbsent(). And then we store the object we got from // creating the waypoint, so we can keep track of it for later use if necessary. this.waypoints.computeIfAbsent(player.getUniqueId(), key -> new ArrayList<>()).add(waypoint); } // We can also delete a waypoint if we need from the player. For this, you // must have stored an instance of the created waypoint to retrieve its ID. Or just a reference to the ID public void removeDeathWaypoint(UUID uuid, Waypoint waypoint) { Waypoints.deleteWaypoint(uuid, waypoint.getId()); } } ``` -------------------------------- ### saveConfig(Config config, File file) Source: https://github.com/badlionclient/badlionclientmodapi Saves the given configuration to the specified file. ```APIDOC ## saveConfig(Config config, File file) ### Description Saves the given configuration to the specified file. ### Method Abstract method ### Signature ```java public abstract void saveConfig(Config config, File file); ``` ### Parameters - `config` (Config) - Required - Configuration to save - `file` (File) - Required - Output file ``` -------------------------------- ### Handle UnsupportedOperationException on unsupported platforms Source: https://github.com/badlionclient/badlionclientmodapi Shows error handling when enabling a Survival feature on unsupported platforms. Catches UnsupportedOperationException with messages like "Survival API is not supported on MC prior to 1.17!", "... on bungee!", or "... on velocity!". ```java import net.badlion.modapicommon.survival.SurvivalApi; import net.badlion.modapicommon.survival.SurvivalFeature; public class GuardedSurvival { public void enable() { try { SurvivalApi.enableFeature(SurvivalFeature.BREEDING_TIMER); } catch (UnsupportedOperationException ex) { // e.g. "Survival API is not supported on MC prior to 1.17!" // "Survival API is not supported on bungee!" // "Survival API is not supported on velocity!" log(ex.getMessage()); } } } ``` -------------------------------- ### Create and inspect a waypoint with Waypoints.createWaypoint Source: https://github.com/badlionclient/badlionclientmodapi Builds a waypoint for a player using the Waypoints API, then prints its properties. The waypoint is created with allowToAdd set to false and sentBefore initially false; setSentBefore(true) marks it as sent before returning. ```java import net.badlion.modapicommon.mods.Waypoints; import net.badlion.modapicommon.utility.Location; import net.badlion.modapicommon.utility.Waypoint; import java.util.UUID; public class WaypointLifecycle { public Waypoint createAndInspect(UUID player) { Waypoint waypoint = Waypoints.createWaypoint( player, Location.of("lobby", 12.5, 64.0, -8.0), "&aSpawn", false); // Inspect the created object System.out.println("id=" + waypoint.getId()); System.out.println("name=" + waypoint.getName()); System.out.println("world=" + waypoint.getLocation().getWorld()); System.out.println("allowToAdd=" + waypoint.isAllowToAdd()); System.out.println("sentBefore=" + waypoint.isSentBefore()); waypoint.setSentBefore(true); return waypoint; } } ``` -------------------------------- ### getPluginMessageSender() abstract method Source: https://github.com/badlionclient/badlionclientmodapi Returns the platform's plugin-message sender used to deliver mod data to clients. ```java public abstract AbstractPluginMessageSender getPluginMessageSender(); ``` -------------------------------- ### Full disable plus feature block (config.json) Source: https://github.com/badlionclient/badlionclientmodapi Shows a complete config.json that disables Waypoints and MiniMap, keeps ToggleSneak enabled but disables its inventorySneak feature via extra_data. The extra_data feature flags accept "disabled" and/or "forced" booleans depending on the feature. ```json { "clicksPerSecondLimitRight": 20, "clicksPerSecondLimit": 10, "modsDisallowed": { "Waypoints": { "disabled": true }, "MiniMap": { "disabled": true }, "ToggleSneak": { "disabled": false, "extra_data": { "inventorySneak": { "disabled": true } } } } } ``` -------------------------------- ### Send team member locations with TeamMarker Source: https://github.com/badlionclient/badlionclientmodapi/blob/master/examples.md Use this BukkitRunnable task to periodically send team member locations to players. The client removes locations after 5 seconds of no updates, so run the task faster than 3 seconds. The color must be a hex value and can differ per player; the receiving player's own location is ignored by the client. ```java // Since we need to send the locations on a regular basis to update the locations it's best to put the logic in a task // We recommend running it faster than 3 seconds since the client removes the locations after 5 seconds of no updates public class TeamMarkerTask extends BukkitRunnable { @Override public void run() { // This is just an example, there may be other ways you keep track of teams TeamManager teamManager = Plugin.getTeamManager(); // Loop over all teams to update the locations for (Team team : teamManager.getTeams()) { List locations = new ArrayList<>(); // First we loop over all players in this team // We do not need to worry about having the player receiving it being in the list too since the client ignored that location for (Player player : team.getMembers()) { Location location = player.getLocation(); // Add the location for this member into the list locations.add( new TeamMemberLocation( player.getUniqueId(), team.getColor(), // This color has to be the in Hex value, can be different for each player location.getX(), location.getY(), location.getZ() ) ); } // Loop over all the players again and send the list for (Player player : team.getMembers()) { TeamMarker.sendLocations(player.getUniqueId(), locations); } } } } ``` -------------------------------- ### SurvivalFeature.getLore() Source: https://github.com/badlionclient/badlionclientmodapi Returns the GUI lore lines for the survival feature. ```APIDOC ## SurvivalFeature.getLore() ### Description Returns the GUI lore lines for the survival feature. ### Method `getLore()` ### Return Type `List` ### Returns - **List** - GUI lore lines (repo placeholder `"..."`). ``` -------------------------------- ### getPluginMessageSender() Source: https://github.com/badlionclient/badlionclientmodapi Returns the platform's plugin-message sender used to deliver mod data to clients. ```APIDOC ## getPluginMessageSender() ### Description Returns the platform's plugin-message sender used to deliver mod data to clients. ### Method Abstract method ### Signature ```java public abstract AbstractPluginMessageSender getPluginMessageSender(); ``` ### Returns - `AbstractPluginMessageSender` - The platform's plugin-message sender used to deliver mod data to clients ``` -------------------------------- ### setSurvivalManager / getSurvivalManager Source: https://github.com/badlionclient/badlionclientmodapi Registers and retrieves the survival manager implementation. The setter is called by the platform plugin constructor, and the getter returns null until then. ```APIDOC ## setSurvivalManager / getSurvivalManager ### Description Registers and retrieves the survival manager implementation. The setter is called by the platform plugin constructor, and the getter returns null until then. ### Method setSurvivalManager / getSurvivalManager ### Parameters #### survivalManager - **survivalManager** (AbstractSurvivalManager) - Required - The survival manager implementation to register ### Response #### getSurvivalManager - Returns the registered AbstractSurvivalManager, or null if not set. ``` -------------------------------- ### Toggle Survival features at runtime Source: https://github.com/badlionclient/badlionclientmodapi Shows how to enable and disable Survival features during kit start/end and print enabled features. Uses SurvivalApi.enableFeature, disableFeature, disableAllFeatures, and getEnabledFeatures. ```java import net.badlion.modapicommon.survival.SurvivalApi; import net.badlion.modapicommon.survival.SurvivalFeature; public class SurvivalToggles { public void onKitStart() { SurvivalApi.enableFeature(SurvivalFeature.SHOW_ENDERCHEST_INVENTORY); SurvivalApi.enableFeature(SurvivalFeature.SEARCH_BAR); } public void onKitEnd() { SurvivalApi.disableFeature(SurvivalFeature.SHOW_ENDERCHEST_INVENTORY); SurvivalApi.disableAllFeatures(); } public void printEnabled() { for (SurvivalFeature feature : SurvivalApi.getEnabledFeatures()) { System.out.println(feature.name() + " -> " + feature.getName()); } } } ``` -------------------------------- ### setSurvivalManager / getSurvivalManager Source: https://github.com/badlionclient/badlionclientmodapi Registers and retrieves the survival manager implementation. Returns null until the platform plugin constructor calls the setter. ```java public void setSurvivalManager(AbstractSurvivalManager survivalManager) public AbstractSurvivalManager getSurvivalManager() ``` -------------------------------- ### AbstractBukkitBadlionPlugin required setter signatures Source: https://github.com/badlionclient/badlionclientmodapi Protected methods that subclasses must call to provide the message sender and survival manager. These are abstract requirements for the base plugin class. ```java protected void setMessageSender(AbstractBukkitPluginMessageSender messageSender) protected void setSurvivalManager(AbstractBukkitSurvivalManager survivalManager) ``` -------------------------------- ### setWaypointManager / getWaypointManager Source: https://github.com/badlionclient/badlionclientmodapi Registers and retrieves the waypoint manager implementation. Returns null until the platform plugin constructor calls the setter. ```java public void setWaypointManager(AbstractWaypointManager waypointManager) public AbstractWaypointManager getWaypointManager() ``` -------------------------------- ### setWaypointManager / getWaypointManager Source: https://github.com/badlionclient/badlionclientmodapi Registers and retrieves the waypoint manager implementation. The setter is called by the platform plugin constructor, and the getter returns null until then. ```APIDOC ## setWaypointManager / getWaypointManager ### Description Registers and retrieves the waypoint manager implementation. The setter is called by the platform plugin constructor, and the getter returns null until then. ### Method setWaypointManager / getWaypointManager ### Parameters #### waypointManager - **waypointManager** (AbstractWaypointManager) - Required - The waypoint manager implementation to register ### Response #### getWaypointManager - Returns the registered AbstractWaypointManager, or null if not set. ``` -------------------------------- ### NotificationButton.Action enum Source: https://github.com/badlionclient/badlionclientmodapi Defines button actions: OPEN_URL, RUN_COMMAND, SUGGEST_COMMAND. Used with NotificationButton constructor. ```java public enum Action { OPEN_URL, RUN_COMMAND, SUGGEST_COMMAND } ```