Sword API
Overview
The sword system manages player weapon progression through various skins, tiers, and upgrades. It handles the creation and validation of sword items with custom properties, damage values, and visual appearances.
Sword Item Management
Item Retrieval
ItemStack getSwordItemFromPlayer(Player player)
Description: Gets the current sword item for a player based on their progression
Parameters:
player- Target playerReturns: ItemStack representing the player's current sword
Usage: Equipment updates, inventory management, display purposes
Item Validation
boolean isItemSword(ItemStack item)
Description: Checks if an ItemStack is a valid EdDungeons sword
Parameters:
item- ItemStack to validateReturns: True if the item is an EdDungeons sword, false otherwise
Usage: Event handling, inventory filtering, item validation
Usage Examples
Basic Sword Operations
EdDungeonsSwordAPI swordAPI = EdDungeonsAPI.getInstance().getSwordAPI();
// Get player's current sword
ItemStack playerSword = swordAPI.getSwordItemFromPlayer(player);
if (playerSword != null) {
player.getInventory().setItemInMainHand(playerSword);
player.sendMessage("§aSword updated!");
} else {
player.sendMessage("§cNo sword available for your level!");
}
// Check if an item is a sword
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (swordAPI.isItemSword(heldItem)) {
player.sendMessage("§6You are holding an EdDungeons sword!");
} else {
player.sendMessage("§7This is not an EdDungeons sword.");
}Last updated
Was this helpful?