-
Notifications
You must be signed in to change notification settings - Fork 0
Developer API
*** Registration Methods (For Addon Developers)**
- Other mods can call these methods during server startup or datapack loading to add their items and blocks to your skill restrictions.
registerUsageRestriction(String itemId, String skill, int requiredLevel) Locks an item (like a weapon or tool) from being held or used unless the player meets the required skill level.
registerInteractRestriction(String itemId, String skill, int requiredLevel) Locks specific right-click interactions with an item unless the player meets the required skill level.
registerCraftingRestriction(String itemId, String skill, int requiredLevel, float xpReward) Prevents an item from being crafted without the required skill level, and optionally grants XP when successfully crafted.
registerBlockRestriction(String blockId, String skill, int requiredLevel, float xpReward) Prevents a block from being broken/harvested without the required skill level, and optionally grants XP when broken.
*** Progression & XP Methods**
- Methods used to check player stats or award experience.
getPlayerLevel(Player player, String skillName) Safely retrieves a player's current level in a specific skill. Returns 0 if they have no data.
hasUnlockedPage(Player player, String skillName) Checks if a player has officially unlocked a skill tab. Vitality, Agility, Combat, and Defense are unlocked by default.
getTornPagesBalance(Player player) Returns how many unspent Torn Pages the player currently has.
grantCustomXp(ServerPlayer player, String skillName, float amount) The main method for giving a player XP. It automatically applies their personal XP multipliers, checks for level-ups, updates the server data, and instantly syncs the new values to the client and their party members.
canPlayerUseItem(ServerPlayer player, String itemId) The master check to see if a player is allowed to use an item. It automatically bypasses restrictions if the player is in Creative or Spectator mode.
*** Data Retrieval Methods**
- Methods used internally by the server to look up restrictions on the fly.
getCustomUsage(String itemId) / getCustomInteract(String itemId) / getCustomCrafting(String itemId) / getCustomBlockUsage(String blockId) Returns a map containing the specific skill requirements for a given item or block.
getCustomCraftingXp(String itemId) / getCustomBlockXp(String blockId) Returns the exact XP amount a player should be awarded for crafting an item or breaking a block.
getItemUsageRestrictions(String itemId) Fetches restriction data specifically loaded from Datapack JSON files rather than Java code.
Network Syncing Methods Methods used behind the scenes to keep the server and client communicating perfectly.
getAllCustomUsageRestrictions() / getAllCustomInteractRestrictions() / getAllCustomBlockRestrictions() Packages up every single custom restriction currently loaded in the server's RAM so they can be bundled into a network payload.
clearAllCustomRestrictionsForClient() Called exclusively on the client side when disconnecting from a server or receiving a new sync packet. It wipes the client's local memory to prevent ghost restrictions from persisting across different servers.