### YAML Example for Fishing Profile
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
An example of a `fishing` profile configuration. It uses the `FISHING` trigger type and defines XP ranges for catching items, with an empty blacklist in this case.
```yaml
fishing:
type: FISHING
xp_modifier:
default:
min: 1.0
max: 5.0
custom:
COD:
min: 1.0
max: 2.0
filter:
type: BLACKLIST
list: []
```
--------------------------------
### YAML Example: Console Command Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Provides examples of using the 'command' handler to execute commands as the console, including placeholders like {player} and {level}.
```yaml
- "command give {player} diamond 1"
- "command broadcast {player} leveled up their tool!"
```
--------------------------------
### YAML Example for Block Mining Profile
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
An example of a `block_mining` profile configuration. It uses the `BLOCK_BREAK` trigger type and includes a blacklist for decorative blocks to prevent players from gaining XP from breaking them.
```yaml
block_mining:
type: BLOCK_BREAK
xp_modifier:
default:
min: 0.5
max: 1.5
custom:
DIAMOND_ORE:
min: 5.0
max: 10.0
filter:
type: BLACKLIST
list:
- "FIRE"
- "TORCH"
- "GRASS"
# ... (filters out decorative blocks)
```
--------------------------------
### Complete LevelTools Integration Example in Java
Source: https://context7.com/byteful/leveltools/llms.txt
A comprehensive example of integrating LevelTools into a Minecraft plugin. It demonstrates hooking into the LevelTools API, handling potential null instances, and provides an example of checking item levels to grant bonuses.
```java
import me.byteful.plugin.leveltools.LevelToolsPlugin;
import me.byteful.plugin.leveltools.api.item.LevelToolsItem;
import me.byteful.plugin.leveltools.util.LevelToolsUtil;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class MyLevelToolsAddon extends JavaPlugin {
private LevelToolsPlugin levelTools;
@Override
public void onEnable() {
// Get LevelTools instance
levelTools = LevelToolsPlugin.getInstance();
if (levelTools == null) {
getLogger().severe("LevelTools not found! Disabling...");
getServer().getPluginManager().disablePlugin(this);
return;
}
getLogger().info("Successfully hooked into LevelTools!");
// Register event listeners
getServer().getPluginManager().registerEvents(
new MyLevelUpListener(), this);
}
// Example: Give bonus rewards for high-level items
public void giveHighLevelBonus(Player player) {
ItemStack handItem = LevelToolsUtil.getHand(player);
if (LevelToolsUtil.isSupportedTool(handItem.getType())) {
LevelToolsItem tool = LevelToolsUtil.createLevelToolsItem(handItem);
if (tool.getLevel() >= 100) {
player.sendMessage("§6Maximum level reached! Bonus applied!");
// Give special rewards
}
}
}
}
```
--------------------------------
### LevelTools Java API Usage Examples
Source: https://github.com/byteful/leveltools/blob/main/README.md
Demonstrates how to interact with the LevelTools API in Java. Includes examples for creating a LevelToolsItem, setting its level and XP, and updating the player's main hand item. Also shows how to listen for and modify level and XP increase events.
```java
// Items
ItemStack hand = player.getInventory().getItemInMainHand();
LevelToolsItem tool = LevelToolsUtil.createLevelToolsItem(hand);
tool.setLevel(69);
tool.setXp(420);
player.getInventory().setItemInMainHand(tool.getItemStack());
// Events
@EventHandler
public void onLevelEvent(LevelToolsLevelIncreaseEvent event) {
event.setNewLevel(69);
}
@EventHandler
public void onXPEvent(LevelToolsXPIncreaseEvent event) {
event.setNewXp(420);
}
```
--------------------------------
### YAML Example for Combat Profile
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
An example of a `combat` profile configuration. It uses the `ENTITY_KILL` trigger type with a custom XP modifier for Blazes and a blacklist to prevent XP gain from killing players.
```yaml
combat:
type: ENTITY_KILL
xp_modifier:
default:
min: 1.0
max: 2.5
custom:
BLAZE:
min: 5.0
max: 7.5
filter:
type: BLACKLIST
list:
- "PLAYER" # Prevent PvP XP farming
```
--------------------------------
### YAML Example for Custom Farming Profile
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
Demonstrates creating a custom `farming` profile. This profile uses the `BLOCK_BREAK` trigger and a whitelist to grant XP only for breaking specific crops like Wheat, Potatoes, and Carrots.
```yaml
profiles:
farming:
type: BLOCK_BREAK
xp_modifier:
default:
min: 1.0
max: 2.0
custom:
WHEAT:
min: 2.0
max: 4.0
POTATOES:
min: 2.0
max: 4.0
CARROTS:
min: 2.0
max: 4.0
filter:
type: WHITELIST
list:
- "WHEAT"
- "POTATOES"
- "CARROTS"
- "BEETROOTS"
- "NETHER_WART"
```
--------------------------------
### Custom XP Formula Example (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
Shows how to override the global XP formula for a specific item profile ('legendary_swords') by defining a `level_xp_formula`. This example makes leveling legendary swords harder.
```yaml
legendary_swords:
materials:
- NETHERITE_SWORD
trigger_profile: combat
reward_profile: swords
display_profile: default
max_level: 200
level_xp_formula: "500 + {current_level} * 250" # Harder to level
```
--------------------------------
### YAML Example: Player Command Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Demonstrates how to execute commands from the player's perspective using the 'player-command' handler.
```yaml
- "player-command spawn"
```
--------------------------------
### YAML Example: Player OP Command Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Shows the usage of 'player-opcommand' for executing commands as the player with temporary OP permissions, advising caution.
```yaml
- "player-opcommand specialplugin enchant"
```
--------------------------------
### YAML Example: Incremental Enchantment Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Shows how to use 'enchant3' to add to the existing enchantment level of an item.
```yaml
- "enchant3 efficiency 1"
```
--------------------------------
### YAML Example: Custom Elite Swords Profile
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
An example of a custom reward profile named 'elite_swords', showcasing a combination of enchantments, attribute bonuses, and console commands triggered at different player levels.
```yaml
profiles:
elite_swords:
levels:
1:
- "enchant2 sharpness 1"
10:
- "enchant2 sharpness 5"
- "attribute generic.attack_speed 0.2"
25:
- "enchant2 fire_aspect 2"
- "command broadcast &6{player} &eunlocked &cFire Aspect&e!"
50:
- "enchant2 sharpness 7"
- "attribute generic.attack_damage 2"
- "command give {player} experience_bottle 10"
```
--------------------------------
### YAML Example: Enchantment Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Demonstrates how to apply enchantments to an item using the 'enchant' handler. This handler overrides existing enchantment levels.
```yaml
- "enchant efficiency 3"
```
--------------------------------
### Profile Inheritance Example (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
Demonstrates how to use the `extends` option to inherit settings from a parent profile ('pickaxes') and override specific options like materials and max_level for a new profile ('netherite_pickaxes').
```yaml
profiles:
pickaxes:
materials:
- WOODEN_PICKAXE
- STONE_PICKAXE
- IRON_PICKAXE
- GOLDEN_PICKAXE
- DIAMOND_PICKAXE
trigger_profile: block_mining
reward_profile: tools
display_profile: default
max_level: 100
netherite_pickaxes:
extends: pickaxes
materials:
- NETHERITE_PICKAXE
max_level: 150 # Override max level
```
--------------------------------
### Material Restriction Error Example (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
Illustrates a common error where a material is assigned to multiple item profiles, which LevelTools prohibits. This example shows how duplicate material entries will cause the plugin to fail loading.
```yaml
# This will cause an error:
pickaxes:
materials:
- DIAMOND_PICKAXE # Duplicate!
special_pickaxes:
materials:
- DIAMOND_PICKAXE # Error: already in pickaxes profile
```
--------------------------------
### YAML Configuration for Minimal Display Profile
Source: https://github.com/byteful/leveltools/wiki/Display-Profiles
An example of a 'minimal' display profile focused on an action bar only. It disables item name and lore modifications, providing a concise XP progress update.
```yaml
profiles:
minimal:
name:
enabled: false
text: ""
action_bar:
enabled: true
text: "&7Lv.&f{level} &8| &e{xp_formatted}&7/&e{max_xp_formatted}"
lore:
enabled: false
lines: []
progress_bar:
total_bars: 10
bar_symbol: '|'
prefix_symbol: ''
suffix_symbol: ''
prefix_color: '7'
suffix_color: '7'
completed_color: 'a'
placeholder_color: '8'
```
--------------------------------
### YAML Example: Item Attribute Modification Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Illustrates how to modify item attributes using the 'attribute' handler, referencing valid attributes from external resources.
```yaml
- "attribute generic.attack_speed 0.5"
- "attribute generic.attack_damage 2"
```
--------------------------------
### YAML Example: Conditional Enchantment Reward
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Illustrates the use of 'enchant2' for applying enchantments only if the new level is higher than the current one, preventing accidental downgrades.
```yaml
- "enchant2 efficiency 3"
```
--------------------------------
### Listening to XP Gain Events with LevelTools API (Java)
Source: https://context7.com/byteful/leveltools/llms.txt
Provides an example of a listener for the LevelToolsXPIncreaseEvent. This enables developers to hook into XP gain events to modify the amount of XP gained, apply multipliers, cancel XP gains in certain worlds, or track XP progression for statistics.
```java
import me.byteful.plugin.leveltools.api.event.LevelToolsXPIncreaseEvent;
import me.byteful.plugin.leveltools.api.item.LevelToolsItem;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class XPGainListener implements Listener {
@EventHandler
public void onXPGain(LevelToolsXPIncreaseEvent event) {
Player player = event.getPlayer();
LevelToolsItem item = event.getItem();
double initialXp = event.getInitialXp();
// Apply XP multiplier (e.g., 2x XP boost)
double boostedXp = initialXp * 2.0;
event.setNewXp(boostedXp);
// Check if XP was modified
if (event.isModified()) {
player.sendMessage("§aXP Boost applied! +" + boostedXp + " XP");
}
// Cancel XP gain in specific conditions
if (player.getWorld().getName().equals("no_xp_world")) {
event.setCancelled(true);
}
// Track XP gains for statistics
// ... store data to database
}
}
```
--------------------------------
### Custom Hoes Profile Creation (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
An example of creating a custom item profile for hoes. It requires defining corresponding trigger and reward profiles first, then links hoes to a 'farming' trigger and a custom 'hoes' reward profile.
```yaml
profiles:
hoes:
materials:
- WOODEN_HOE
- STONE_HOE
- IRON_HOE
- GOLDEN_HOE
- DIAMOND_HOE
- NETHERITE_HOE
trigger_profile: farming
reward_profile: hoes
display_profile: default
max_level: 50
```
--------------------------------
### PlaceholderAPI Integration - YAML & Java
Source: https://context7.com/byteful/leveltools/llms.txt
Enables the use of LevelTools specific placeholders within other plugins that support PlaceholderAPI, such as scoreboards or chat messages. The YAML configuration shows example placeholder usage, while the Java code demonstrates how to programmatically set these placeholders for players. Available placeholders include level, XP, progress bar, item profile, and max level.
```yaml
# Example scoreboard configuration using placeholders
scoreboard:
title: "&6&lMy Server"
lines:
- "&eYour Tool Level: &6%leveltools_level%"
- "&eXP: &a%leveltools_xp%&7/&a%leveltools_max_xp%"
- "&eProgress: %leveltools_progress_bar%"
- "&eProfile: &b%leveltools_item_profile%"
- "&eMax Level: &c%leveltools_max_level%"
```
```java
// Using PlaceholderAPI in code
import me.clip.placeholderapi.PlaceholderAPI;
Player player = // ... get player
String message = PlaceholderAPI.setPlaceholders(player,
"&eYour tool is level %leveltools_level%");
player.sendMessage(message);
// Available placeholders:
// %leveltools_level% - Current item level
// %leveltools_xp% - Current XP amount
// %leveltools_max_xp% - XP required for next level
// %leveltools_progress_bar% - Visual progress bar
// %leveltools_item_profile% - Item's profile ID
// %leveltools_max_level% - Maximum achievable level
```
--------------------------------
### YAML Configuration for Combat Display Profile
Source: https://github.com/byteful/leveltools/wiki/Display-Profiles
An example of a custom display profile named 'combat_display' designed for combat items. It features a customized item name, action bar message, and lore format.
```yaml
profiles:
combat_display:
name:
enabled: true
text: "&c{item} &7[&6Lv.{level}&7]"
action_bar:
enabled: true
text: "&c+XP &7| {progress_bar}"
lore:
enabled: true
lines:
- "&8Combat Tool"
- ""
- "&7Level: &f{level}"
- "&7XP: &f{xp_formatted}/{max_xp_formatted}"
progress_bar:
total_bars: 20
bar_symbol: '='
prefix_symbol: '['
suffix_symbol: ']'
prefix_color: '7'
suffix_color: '7'
completed_color: 'c'
placeholder_color: '8'
```
--------------------------------
### Configure Item Profiles - YAML
Source: https://context7.com/byteful/leveltools/llms.txt
Defines which in-game materials are eligible for leveling and links them to specific trigger, reward, and display profiles. This configuration allows for granular control over item leveling, including setting a maximum level for each profile. Example profiles demonstrate custom configurations for tools and armor.
```yaml
# item_profiles.yml
profiles:
# Custom farming hoe profile
farming_hoes:
materials:
- WOODEN_HOE
- STONE_HOE
- IRON_HOE
- DIAMOND_HOE
- NETHERITE_HOE
trigger_profile: crop_harvesting
reward_profile: farming_rewards
display_profile: farming_display
max_level: 75
# Armor profile with inheritance
diamond_armor:
materials:
- DIAMOND_HELMET
- DIAMOND_CHESTPLATE
- DIAMOND_LEGGINGS
- DIAMOND_BOOTS
trigger_profile: damage_taken
reward_profile: armor_rewards
display_profile: default
max_level: 50
```
--------------------------------
### Custom Tridents Profile Creation (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
An example for creating a custom item profile for tridents. It assigns the TRIDENT material to the 'combat' trigger and a custom 'tridents' reward profile, with a maximum level of 75.
```yaml
profiles:
tridents:
materials:
- TRIDENT
trigger_profile: combat
reward_profile: tridents # Create in reward_profiles.yml
display_profile: default
max_level: 75
```
--------------------------------
### YAML Configuration for Filter Lists
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
Controls which items (blocks, entities, etc.) are subject to the trigger profile. It supports either a BLACKLIST (excluding specified items) or a WHITELIST (only including specified items).
```yaml
filter:
type: BLACKLIST # or WHITELIST
list:
- "STONE"
- "DIRT"
```
--------------------------------
### YAML Configuration for XP Modifiers
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
Specifies how XP is awarded. Includes a default range for all actions and allows for custom XP ranges for specific blocks or entities. The actual XP granted is a random value within the defined min/max range.
```yaml
xp_modifier:
default:
min: 0.5 # Minimum XP
max: 1.5 # Maximum XP
custom:
DIAMOND_ORE:
min: 5.0
max: 10.0
```
--------------------------------
### Check Item Support and Get Profile - Java
Source: https://context7.com/byteful/leveltools/llms.txt
Validates if a material or ItemStack is supported by the LevelTools system and retrieves its associated item profile. This involves checking if the tool can be leveled and then accessing its configuration such as ID, max level, and associated profiles. Dependencies include the LevelToolsUtil class.
```java
import me.byteful.plugin.leveltools.util.LevelToolsUtil;
import me.byteful.plugin.leveltools.profile.item.ItemProfile;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
// Check if a material is supported
Material material = Material.DIAMOND_PICKAXE;
boolean isSupported = LevelToolsUtil.isSupportedTool(material);
if (isSupported) {
// Get the item's profile configuration
ItemProfile profile = LevelToolsUtil.getItemProfile(material);
if (profile != null) {
String profileId = profile.getId();
int maxLevel = profile.getMaxLevel();
String triggerProfile = profile.getTriggerProfile();
String rewardProfile = profile.getRewardProfile();
String displayProfile = profile.getDisplayProfile();
System.out.println("Profile: " + profileId);
System.out.println("Max Level: " + maxLevel);
System.out.println("Trigger: " + triggerProfile);
}
}
// Check an item in hand
ItemStack item = player.getInventory().getItemInMainHand();
if (LevelToolsUtil.isSupportedTool(item.getType())) {
LevelToolsItem tool = LevelToolsUtil.createLevelToolsItem(item);
// ... work with the tool
}
```
--------------------------------
### YAML Structure for Trigger Profiles
Source: https://github.com/byteful/leveltools/wiki/Trigger-Profiles
Defines the overall structure for trigger profiles, including profile ID, trigger type, XP modifiers, and filtering options. This YAML configuration dictates how XP is awarded based on player actions.
```yaml
profiles:
profile_id:
type: BLOCK_BREAK # Trigger type
xp_modifier: # XP amounts
default:
min: 1.0
max: 2.0
custom:
DIAMOND_ORE:
min: 5.0
max: 10.0
filter: # Whitelist/blacklist
type: BLACKLIST
list:
- "STONE"
```
--------------------------------
### Main Configuration Settings
Source: https://context7.com/byteful/leveltools/llms.txt
Contains global settings for the LevelTools plugin, including the XP formula for leveling, anvil combination behavior, block data storage method, and sound effects. This file also allows for disabling the plugin in specific worlds and configuring the update checker.
```yaml
# config.yml
# XP formula for leveling (global default, can be overridden per profile)
level_xp_formula: "100 + {current_level} * 100" # Linear scaling
# Examples:
# - "100 * {current_level}" - Simple linear
# - "100 * ({current_level} ^ 1.5)" - Exponential growth
# - "500 + {current_level} * 50" - With base offset
# Anvil combination behavior
anvil_combine: "ADD_BOTH" # ADD_BOTH, HIGHER_OF_BOTH, LOWER_OF_BOTH
# Block data storage method
block_data_storage:
type: SQLITE # SQLITE or LEGACY_TEXT
# Prevent XP from player-placed blocks
playerPlacedBlocks: false
# Level-up sound effect
level_up_sound:
sound: "ENTITY_PLAYER_LEVELUP"
pitch: 1.0
volume: 1.0
# Hide attribute lore (recommended for clean appearance)
hide_attributes: true
# Disabled worlds (plugin inactive in these worlds)
disabled_worlds:
- "creative_world"
- "lobby"
# Update checker
update:
start: true
periodically: true
```
--------------------------------
### LevelTools Admin Commands
Source: https://context7.com/byteful/leveltools/llms.txt
Provides a list of administrative commands for managing the LevelTools plugin. These commands allow for reloading configuration, resetting player item data, setting item XP and levels, and displaying debug information or help menus. Permissions are required to use these commands.
```bash
# Reload plugin configuration
/leveltools reload
# Reset specific player's hand item
/leveltools reset PlayerName
# Reset all leveled items for a player
/leveltools reset PlayerName --all
# Set hand item XP
/leveltools xp 1000.5
# Set hand item level
/leveltools level 50
# Increase hand item level by 1
/leveltools levelup
# Show debug information
/leveltools debug
# Display help menu
/leveltools help
# Permissions:
# - leveltools.admin - Required for all admin commands
```
--------------------------------
### Add LevelTools Dependency for Gradle
Source: https://github.com/byteful/leveltools/blob/main/README.md
Integrate the LevelTools plugin into your Spigot project using Gradle. This snippet shows how to add the necessary repository and dependency to your build.gradle file. Ensure you replace 'Tag' with the desired version number.
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly 'com.github.byteful:LevelTools:Tag' // Replace Tag with the version. (Ex: v2.0.0)
}
```
--------------------------------
### Display Profiles for Leveled Items
Source: https://context7.com/byteful/leveltools/llms.txt
Customizes the appearance of leveled items, including their names, lore, and action bar messages. This configuration allows for dynamic display of item level, XP progress, and other details using placeholders. The `display_profiles.yml` file defines these visual aspects.
```yaml
# display_profiles.yml
profiles:
epic_display:
name:
enabled: true
text: "&6&l{item} &7[&e{level}&7]"
action_bar:
enabled: true
text: "{progress_bar} &e{xp_formatted}&7/&e{max_xp_formatted} &7XP"
lore:
enabled: true
lines:
- ""
- "&7═══════════════════"
- "&6⚔ &eLevel: &b{level}"
- "&6⭐ &eXP: &a{xp_formatted}&7/&a{max_xp_formatted}"
- ""
- "{progress_bar}"
- "&7═══════════════════"
progress_bar:
total_bars: 20
bar_symbol: '█'
prefix_symbol: '['
suffix_symbol: ']'
prefix_color: '7'
suffix_color: '7'
completed_color: 'a'
placeholder_color: '8'
# Available placeholders:
# {level} - Item level
# {xp} - Current XP (raw number)
# {max_xp} - Max XP needed (raw number)
# {xp_formatted} - XP with K/M/B suffixes
# {max_xp_formatted} - Max XP with K/M/B suffixes
# {progress_bar} - Visual progress bar
# {item} - Original item name (Paper only)
```
--------------------------------
### Configure Trigger Profiles - YAML
Source: https://context7.com/byteful/leveltools/llms.txt
Defines the specific actions or events that cause items to gain experience points. This configuration allows for customization of how different item types gain XP, linking player actions to experience gain. This section is a placeholder for trigger profile configurations.
```yaml
# This section would detail trigger profiles, e.g.:
# trigger_profiles:
# crop_harvesting:
# type: BLOCK_BREAK
# conditions:
# - material: wheat_block
# - material: carrot
# xp_per_action: 10
```
--------------------------------
### Item Profile Structure (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
Defines the basic structure for an item profile, including materials, trigger, reward, display profiles, and max level. This is the foundational configuration for leveling up specific items.
```yaml
profiles:
profile_id:
materials:
- DIAMOND_PICKAXE
- IRON_PICKAXE
trigger_profile: block_mining
reward_profile: tools
display_profile: default
max_level: 100
```
--------------------------------
### Add LevelTools Dependency for Maven
Source: https://github.com/byteful/leveltools/blob/main/README.md
Integrate the LevelTools plugin into your Spigot project using Maven. This snippet details how to configure your pom.xml to include the Jitpack repository and the LevelTools dependency. Remember to substitute 'Tag' with the specific version.
```xml
jitpack.io
https://jitpack.io
com.github.byteful
LevelTools
Tag
```
--------------------------------
### Listening to Level Increase Events with LevelTools API (Java)
Source: https://context7.com/byteful/leveltools/llms.txt
Shows how to implement a listener for the LevelToolsLevelIncreaseEvent. This allows developers to intercept and modify level-up events, cancel them under specific conditions, or trigger custom rewards and actions when an item levels up.
```java
import me.byteful.plugin.leveltools.api.event.LevelToolsLevelIncreaseEvent;
import me.byteful.plugin.leveltools.api.item.LevelToolsItem;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class LevelUpListener implements Listener {
@EventHandler
public void onLevelIncrease(LevelToolsLevelIncreaseEvent event) {
Player player = event.getPlayer();
LevelToolsItem item = event.getItem();
int newLevel = event.getNewLevel();
// Cancel the level up for specific conditions
if (newLevel > 100) {
event.setCancelled(true);
player.sendMessage("§cMaximum level reached!");
return;
}
// Modify the new level (e.g., double level gains)
event.setNewLevel(newLevel * 2);
// Custom rewards or actions
if (newLevel % 10 == 0) {
player.sendMessage("§6Milestone! You reached level " + newLevel);
// Give bonus rewards
}
}
}
```
--------------------------------
### Manipulating Leveled Items with LevelTools API (Java)
Source: https://context7.com/byteful/leveltools/llms.txt
Demonstrates how to create, read, and modify LevelToolsItem properties such as level, XP, enchantments, and attributes using the LevelTools API. This snippet assumes access to a Player instance and uses utility methods for item manipulation.
```java
import me.byteful.plugin.leveltools.api.item.LevelToolsItem;
import me.byteful.plugin.leveltools.util.LevelToolsUtil;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
// Get the player's main hand item
Player player = // ... get player instance
ItemStack handItem = LevelToolsUtil.getHand(player);
// Create a LevelToolsItem wrapper
LevelToolsItem tool = LevelToolsUtil.createLevelToolsItem(handItem);
// Read current stats
int currentLevel = tool.getLevel();
double currentXp = tool.getXp();
double maxXp = tool.getMaxXp(); // XP needed for next level
// Modify the item
tool.setLevel(50);
tool.setXp(1000.0);
// Apply enchantment (e.g., Efficiency 5)
tool.enchant(Enchantment.EFFICIENCY, 5);
// Modify item attributes (e.g., increase attack speed)
tool.modifyAttribute("generic.attack_speed", 2.0);
// Save the modified item back to player's inventory
LevelToolsUtil.setHand(player, tool.getItemStack());
```
--------------------------------
### Default Fishing Rods Profile (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
A default item profile configuration for fishing rods. It specifies the fishing rod material and links it to the 'fishing' trigger, 'fishing_rods' reward, and 'default' display profiles, with a maximum level of 50.
```yaml
fishing_rods:
materials:
- FISHING_ROD
trigger_profile: fishing
reward_profile: fishing_rods
display_profile: default
max_level: 50
```
--------------------------------
### YAML Structure for Display Profiles
Source: https://github.com/byteful/leveltools/wiki/Display-Profiles
Defines the hierarchical structure for display profiles in LevelTools. It includes sections for item name, action bar, lore, and progress bar customization, along with placeholder usage.
```yaml
profiles:
profile_id:
name:
enabled: false
text: "{item} &7- &b{level}"
action_bar:
enabled: true
text: "{progress_bar} &e{xp_formatted}&6/&e{max_xp_formatted}"
lore:
enabled: true
lines:
- ""
- "&eLevel: &6{level}"
- ""
- "{progress_bar} &e{xp_formatted}&6/&e{max_xp_formatted}"
progress_bar:
total_bars: 50
bar_symbol: '|'
prefix_symbol: '['
suffix_symbol: ']'
prefix_color: '8'
suffix_color: '8'
completed_color: 'e'
placeholder_color: '7'
```
--------------------------------
### Reward Profiles for Leveling
Source: https://context7.com/byteful/leveltools/llms.txt
Specifies the rewards granted to players at different item levels. Rewards can include enchantments, custom commands (executed as console, player, or operator), and attribute modifications. The `reward_profiles.yml` file structures these rewards by level.
```yaml
# reward_profiles.yml
profiles:
custom_pickaxe_rewards:
levels:
1:
- "enchant2 efficiency 1"
- "command say {player} reached level 1!"
5:
- "enchant2 efficiency 2"
- "enchant2 unbreaking 1"
10:
- "enchant2 efficiency 3"
- "enchant2 fortune 1"
- "attribute generic.attack_damage 2"
25:
- "enchant2 efficiency 5"
- "enchant2 fortune 3"
- "enchant2 mending 1"
- "player-command say I reached level 25!"
50:
- "enchant3 efficiency 5" # Adds to existing level
- "player-opcommand give @s diamond 10"
# Reward handlers:
# - "command " - Run as console
# - "player-command " - Run as player
# - "player-opcommand " - Run as player with OP
# - "enchant " - Set enchantment (override)
# - "enchant2 " - Set if higher than existing
# - "enchant3 " - Add to existing level
# - "attribute " - Modify item attribute
```
--------------------------------
### Gradle Dependency for LevelTools
Source: https://context7.com/byteful/leveltools/llms.txt
Add LevelTools as a Gradle dependency to your project. This involves configuring the Jitpack repository and declaring the dependency.
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly 'com.github.byteful:LevelTools:v2.0.0'
}
```
--------------------------------
### Trigger Profiles for XP Gain
Source: https://context7.com/byteful/leveltools/llms.txt
Defines various actions that trigger XP gain, such as breaking blocks or killing entities. Each trigger type has configurable XP modifiers and optional filters to specify which blocks or entities are included or excluded. The 'item_usage' trigger is specifically for right-clicking.
```yaml
profiles:
# Block breaking trigger
block_mining:
type: BLOCK_BREAK
xp_modifier:
default:
min: 0.5
max: 1.5
custom:
DIAMOND_ORE:
min: 10.0
max: 15.0
ANCIENT_DEBRIS:
min: 25.0
max: 50.0
filter:
type: BLACKLIST # or WHITELIST
list:
- "DIRT"
- "GRASS_BLOCK"
# Entity killing trigger
mob_hunting:
type: ENTITY_KILL
xp_modifier:
default:
min: 2.0
max: 5.0
custom:
ENDER_DRAGON:
min: 500.0
max: 1000.0
WITHER:
min: 300.0
max: 600.0
filter:
type: BLACKLIST
list:
- "PLAYER"
# Right-click trigger
item_usage:
type: RIGHT_CLICK
xp_modifier:
default:
min: 0.1
max: 0.5
click_mode: ON_BLOCK # ANY, ON_BLOCK, ON_ENTITY, ON_AIR
```
--------------------------------
### YAML Structure for Reward Profiles
Source: https://github.com/byteful/leveltools/wiki/Reward-Profiles
Defines the hierarchical structure for reward profiles, including profile IDs, levels, and associated rewards. This YAML configuration is essential for setting up custom reward systems.
```yaml
profiles:
profile_id:
levels:
1:
- "enchant2 efficiency 1"
5:
- "enchant2 efficiency 2"
- "command broadcast {player} reached level 5!"
10:
- "enchant2 efficiency 3"
- "attribute generic.attack_speed 0.5"
```
--------------------------------
### Accessing LevelTools API in Java Plugin
Source: https://context7.com/byteful/leveltools/llms.txt
Integrate LevelTools into your Spigot/Bukkit plugin by declaring it as a dependency in plugin.yml and accessing its API instance in your Java code. You can then retrieve managers for profiles, triggers, and block data.
```yaml
name: MyPlugin
version: 1.0.0
depend: [LevelTools]
```
```java
import me.byteful.plugin.leveltools.LevelToolsPlugin;
import me.byteful.plugin.leveltools.api.profile.ProfileManager;
import me.byteful.plugin.leveltools.api.trigger.TriggerRegistry;
import me.byteful.plugin.leveltools.api.block.BlockDataManager;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
LevelToolsPlugin levelTools = LevelToolsPlugin.getInstance();
// Access managers
ProfileManager profileManager = levelTools.getProfileManager();
TriggerRegistry triggerRegistry = levelTools.getTriggerRegistry();
BlockDataManager blockDataManager = levelTools.getBlockDataManager();
// Use the API
// ...
}
}
```
--------------------------------
### Maven Dependency for LevelTools
Source: https://context7.com/byteful/leveltools/llms.txt
Add LevelTools as a Maven dependency to your project. This requires configuring the Jitpack repository and specifying the LevelTools artifact.
```xml
jitpack.io
https://jitpack.io
com.github.byteful
LevelTools
v2.0.0
provided
```
--------------------------------
### Default Pickaxes Profile (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
A default item profile configuration for pickaxes. It lists all types of pickaxes and links them to the 'block_mining' trigger, 'tools' reward, and 'default' display profiles, with a maximum level of 100.
```yaml
pickaxes:
materials:
- WOODEN_PICKAXE
- STONE_PICKAXE
- IRON_PICKAXE
- GOLDEN_PICKAXE
- DIAMOND_PICKAXE
- NETHERITE_PICKAXE
trigger_profile: block_mining
reward_profile: tools
display_profile: default
max_level: 100
```
--------------------------------
### Default Bows Profile (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
A default item profile configuration for bows. It includes bows and crossbows and links them to the 'combat' trigger, 'bows' reward, and 'default' display profiles, with a maximum level of 100.
```yaml
bows:
materials:
- BOW
- CROSSBOW
trigger_profile: combat
reward_profile: bows
display_profile: default
max_level: 100
```
--------------------------------
### Register Custom Triggers - Java
Source: https://context7.com/byteful/leveltools/llms.txt
Allows developers to register custom triggers for items to gain experience. This involves implementing the 'Trigger' interface and providing methods for trigger type and handling logic. The custom trigger is then registered with the LevelTools plugin's TriggerRegistry. Dependencies include LevelToolsPlugin, Trigger, TriggerContext, TriggerRegistry, and TriggerType.
```java
import me.byteful.plugin.leveltools.LevelToolsPlugin;
import me.byteful.plugin.leveltools.api.trigger.Trigger;
import me.byteful.plugin.leveltools.api.trigger.TriggerContext;
import me.byteful.plugin.leveltools.api.trigger.TriggerRegistry;
import me.byteful.plugin.leveltools.api.trigger.TriggerType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
// Custom trigger implementation
public class MovementTrigger implements Trigger {
@Override
public TriggerType getType() {
return TriggerType.RIGHT_CLICK; // Or define custom enum
}
@Override
public void handle(TriggerContext context) {
// Implementation details
}
}
// Register the custom trigger
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
LevelToolsPlugin levelTools = LevelToolsPlugin.getInstance();
TriggerRegistry registry = levelTools.getTriggerRegistry();
// Register custom trigger
registry.register(new MovementTrigger());
// Check if trigger exists
if (registry.has(TriggerType.BLOCK_BREAK)) {
Trigger blockBreakTrigger = registry.get(TriggerType.BLOCK_BREAK);
// ... use trigger
}
// Get all registered triggers
Collection allTriggers = registry.getAll();
}
}
```
--------------------------------
### Default Swords Profile (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
A default item profile configuration for swords. It lists all sword types and connects them to the 'combat' trigger, 'swords' reward, and 'default' display profiles, with a maximum level of 100.
```yaml
swords:
materials:
- WOODEN_SWORD
- STONE_SWORD
- IRON_SWORD
- GOLDEN_SWORD
- DIAMOND_SWORD
- NETHERITE_SWORD
trigger_profile: combat
reward_profile: swords
display_profile: default
max_level: 100
```
--------------------------------
### Default Axes Profile (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
A default item profile configuration for axes. It includes all axe types and associates them with the 'block_mining' trigger, 'tools' reward, and 'default' display profiles, setting a max level of 100.
```yaml
axes:
materials:
- WOODEN_AXE
- STONE_AXE
- IRON_AXE
- GOLDEN_AXE
- DIAMOND_AXE
- NETHERITE_AXE
trigger_profile: block_mining
reward_profile: tools
display_profile: default
max_level: 100
```
--------------------------------
### Default Shovels Profile (YAML)
Source: https://github.com/byteful/leveltools/wiki/Item-Profiles
A default item profile configuration for shovels. It specifies all shovel types and links them to the 'block_mining' trigger, 'tools' reward, and 'default' display profiles, with a maximum level of 100.
```yaml
shovels:
materials:
- WOODEN_SHOVEL
- STONE_SHOVEL
- IRON_SHOVEL
- GOLDEN_SHOVEL
- DIAMOND_SHOVEL
- NETHERITE_SHOVEL
trigger_profile: block_mining
reward_profile: tools
display_profile: default
max_level: 100
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.