SamsFishing · Developers
Developer API
Hook into SamsFishing from your own plugin!
1 min read · Updated
The API is public on GitHub: Sam1qkk/SamsFishing-API.
repositories { maven { url = 'https://jitpack.io' } }
dependencies { compileOnly 'com.github.Sam1qkk:SamsFishing-API:1.1.0' }SamsFishingAPI fishing = SamsFishingProvider.get(); // null without SamsFishing
fishing.addXp(player, 50);
ItemStack pike = fishing.createCatch("pike", 92.5, player);
fishing.addPearls(player, 500);| Methods | For |
|---|---|
catchIds, createCatch, catchId, catchSize, rarity, worth | Fish |
gearIds, createGear, gearId | Rods, baits, hooks, lines, totems |
totalCaught, speciesCaught, personalBest | Records |
level, xp, addXp | Fishing levels |
pearls, addPearls, takePearls | Pearls |
skillPoints, skillLevel | Skill tree |
runningEvents, partyMembers | Seasonal events, parties |
runningCompetition, startCompetition | Competitions |
| Event | When |
|---|---|
FishHookedEvent | A fish bites, before the minigame (cancellable) |
FishCaughtEvent | A fish was landed |
FishEatenEvent | A fish was eaten |
SeaCreatureKilledEvent | A sea creature was beaten |
FishingLevelUpEvent | A new fishing level |
CompetitionStartEvent, CompetitionEndEvent | A competition starts or ends |
Addons
An addon is a jar in plugins/SamsFishing/addons/. SamsFishing loads it on startup (before the resource pack is built, so it can add files to it), calls reload() on /fishing reload and disable() on shutdown. Addons use SamsFishing for listeners, tasks and data, so they need no plugin.yml.
# addon.yml
name: MyAddon
version: '1.0.0'
main: com.example.myaddon.MyAddonpublic final class MyAddon implements SamsFishingAddon {
@Override
public void enable(SamsFishing plugin) {
plugin.getServer().getPluginManager().registerEvents(new MyListener(plugin), plugin);
// add files to every resource pack SamsFishing builds:
plugin.packBuilder().addContributor(root -> { /* write into root */ });
}
@Override
public void disable() {
}
}Compile against the SamsFishing jar (compileOnly). Each addon gets its own class loader whose parent is SamsFishing's, so it sees SamsFishing and Paper but not other addons.
