Example Plugin
A complete, runnable Bukkit plugin that registers a custom MyPet skill end-to-end.
MyPet-APIExamplePlugin is the canonical reference implementation for third-party plugins that integrate with the MyPet API. It exercises the full custom-skill registration path — both the legacy registerSkill call and the newer registerUpgradeParser call introduced in MyPet 4.0.
The example skill is Glow: when a pet lands a hit, there's a chance the target gets the vanilla Minecraft GLOWING potion effect. Two upgrade parameters scale per skilltree level: chance (0–100) and duration (in ticks).
What it demonstrates
The whole plugin is two API calls in ExamplePlugin#onEnable:
SkillManager skills = MyPetApi.getSkillManager();
skills.registerSkill(GlowImpl.class);
skills.registerUpgradeParser(Glow.class, UpgradeSchema.builder()
.integer("chance").label("Chance %").suffix("%").cumulative()
.integer("duration").label("Duration (s)").cumulative()
.build(), json -> new GlowUpgrade()
.chance(UpgradeParsers.parseInteger(UpgradeParsers.get(json, "chance")))
.duration(UpgradeParsers.parseInteger(UpgradeParsers.get(json, "duration"))));registerSkill(GlowImpl.class)— tells MyPet to instantiate oneGlowImplper pet. Supported since MyPet 1.x.registerUpgradeParser(Glow.class, schema, ...)— teaches the skilltree JSON loader how to read aSkills.Glow.Upgrades.<level>block out of any.st.jsonfile. Introduced in MyPet 4.0. The middleUpgradeSchemaargument is required: it describes the upgrade fields to the web editor soGlowgets a typed editing form in/mypet editorlike any built-in skill. Without the call, the loader logsUnknown skill 'Glow'and silently skips the upgrade entries — the pet still gets aGlowImpl, but it never receives upgrades, so it never fires.
The skill identifier ("Glow") is read from the @SkillName annotation on Glow.class — there is no hand-typed string to keep in sync. The parser's return type is also type-checked: register Glow.class with a lambda that returns the wrong upgrade type and the call won't compile.
Upgrade schemas
The second argument to registerUpgradeParser is an UpgradeSchema describing your skill's upgrade fields. It is required — the web editor uses it to render a typed editing form and to validate skilltrees, so custom skills work in /mypet editor automatically. Field names must be the exact JSON keys your parser reads.
number(name)/integer(name)— signed modifier strings ("+5","-2.5")bool(name)— booleansenumOf(name, MyEnum.class)— fixed value setsgroup(name, g -> ...)— one level of nested fieldsPer field:
.label("Chance %")(English fallback shown in the editor),.suffix("%"),.cumulative()(adds a running-total display)
Labels localize through MyPet's locale files: the editor looks up Editor.Skill.<SkillName>.<field> in every loaded language bundle, and the skill's display name uses the existing Name.Skill.<SkillName> key.
Repository layout
The skill-related files below are the focus of this page. The example plugin also includes a custom requirement, leash flag, event listener, and command — see the example plugin's README for those.
ExamplePlugin.java
Bukkit plugin entry point. The two API calls above are the entire onEnable.
skills/Glow.java
Skill interface. Carries @SkillName("Glow"). Extends Skill, OnHitSkill. Declares the upgrade-aware getters.
skills/GlowImpl.java
Skill implementation. Constructed once per pet via the (Pet) constructor. State lives on UpgradeComputer fields so applied/unapplied upgrades automatically update the effective values.
upgrades/GlowUpgrade.java
Data carrier — one instance per Upgrades.<level> block. Annotated @SkillName("Glow") so MyPet's level-up dispatch matches it to the live Glow skill on the pet.
resources/plugin.yml
Bukkit plugin descriptor. softdepend: [MyPet] is mandatory.
resources/glow-example.st.json
Sample skilltree referencing both the new Glow skill and a built-in Damage skill — a good integration smoke test.
Building
The example consumes the MyPet API as a published snapshot, so it builds standalone:
Output JAR: build/libs/MyPetAPIExample-1.0.0.jar.
Because 4.0.1-SNAPSHOT is a moving version, Gradle caches it for 24 hours. To pick up a freshly-published API change immediately, run ./gradlew build --refresh-dependencies.
Running
Using it as a template
For your own plugin:
Fork or clone the repository.
Rename the
dev.userderezzed.mypetapiexamplepackage to your own.Replace
Glow/GlowImpl/GlowUpgradewith your skill (keeping the four-class structure).Update
@SkillName(...)everywhere it appears — it must match between the interface, the upgrade class, and the JSON key in any.st.jsonreferring to the skill.Update
plugin.ymlwith your plugin name and main class.
The build script is already wired against https://repo.userderezzed.dev/snapshots, so no changes are needed to consume the MyPet API.
softdepend: [MyPet] is mandatory in your plugin.yml. Without it, MyPetApi.getSkillManager() in onEnable will throw IllegalStateException because MyPet hasn't loaded yet. Guard early-access paths with MyPetApi.isReady() if you need to call into MyPet from a non-onEnable context.
Last updated
Was this helpful?
