XiaoMoMi Plugins
δΈ­ζ–‡η»΄εŸΊ
CustomFishing
CustomFishing
  • Plugin Wiki
    • 🎣 CustomFishing
      • 🧭 How to Configure Each File
      • ❓️ Common questions
      • βš–οΈ Weight System [MUST READ]
      • πŸ“„ Format
        • πŸ›’ Market
        • ✨ Effect
        • πŸŽ‰ Event
        • ✏️ Text
        • 🎁 Item
        • πŸ¦– Entity
        • 🧊 Block
        • πŸ† Loot
        • πŸ—Ώ Totem
        • πŸ•ΉοΈ MiniGame
          • Accruate click
          • Accruate click v2
          • Accruate click v3
          • Hold
          • Hold v2
          • Tension
          • Click
          • Dance
        • πŸ… Competition
      • βœ… Condition
      • πŸ’ͺ Action
      • πŸ…ΏοΈ Placeholder & Expression
      • 🀝 Compatibility
        • ItemsAdder
        • MythicMobs
        • Oraxen
        • EcoItems
        • Nexo
        • MMOItems
        • NeigeItems
        • ExecutableItems
        • mcMMO Treasure
        • Supported levelers
        • AdvancedEnchantments
        • EcoEnchants
        • BattlePass
        • BetonQuest 2.0
        • ClueScrolls
        • RealisticSeasons
        • Quests
        • TypeWriter
        • Zaphkiel
        • AuraSkills
      • 🐚 Command & Permission
      • πŸ“Š Import & Export Data
      • ⌨️ API
        • Events
        • Basic Operations
        • Integration Provider
        • Custom Hook Logics
        • Custom Games
Powered by GitBook
On this page
  • Create context
  • Get plugin instance
  • Build an item instance
  • Get effect modifier
  • Create new effect instance
  • Apply the modifier
  • Get the loot at a certain location
  • Convert loot into an itemStack
  • Get the itemStack from FishingLootSpawnEvent
  1. Plugin Wiki
  2. 🎣 CustomFishing
  3. ⌨️ API

Basic Operations

Create context

Player player = Bukkit.getPlayer("player");
Context<Player> context = Context.player(player);
// You can create it with null, but please be careful not to use it in any place 
// where a player is needed, such as checking permissions, sending messages
Context<Player> context = Context.player(null);

Get plugin instance

BukkitCustomFishingPlugin api = BukkitCustomFishingPlugin.getInstance()

Build an item instance

ItemStack itemStack = api.getItemManager().buildInternal(context, "rubbish");

Get effect modifier

Optional<EffectModifier> optional = api.getEffectManager().getEffectModifier("beginner_rod", MechanicType.ROD);
if (optional.isPresent()) {
    EffectModifier modifier = optional.get();
}

Create new effect instance

Effect effect = Effect.newInstance();

Apply the modifier

// There are three stages in total
// CAST: Determines what fishing mechanics are available (such as lava fishing)
// LOOT: Affects the weight of the next loot
// FISHING: Determines loot-related properties, such as size, score, and game difficulty
modifier.apply(effect, FishingEffectApplyEvent.Stage.CAST, context);

Get the loot at a certain location

context.arg(ContextKeys.LOCATION, player.getLocation()); // sets the player location
context.arg(ContextKeys.OTHER_LOCATION, custom_location); // sets the custom location, in most cases, it's the hook's
context.arg(ContextKeys.SURROUNDING, "water");
Loot loot = api.getLootManager().getNextLoot(effect, context); 

Convert loot into an itemStack

if (loot.type() == LootType.ITEM) {
    ItemStack itemStack = api.getItemManager().buildInternal(context, loot.id());
}

Get the itemStack from FishingLootSpawnEvent

@EventHandler
public void onLootSpawn(FishingLootSpawnEvent event) {
    if (event.getEntity() instanceof Item item) {
        ItemStack itemStack = item.getItemStack();
    }
}
PreviousEventsNextIntegration Provider