Developer API

Add ScreenFX to the dependencies of your paper-plugin.yml (or softdepend in plugin.yml), then:
ScreenFXAPI api = ScreenFX.api(); // also in the Bukkit ServicesManager
EffectHandle stun = api.play(player, "flashbang"); // a preset
EffectHandle scene = api.play(player, "cinematic", Duration.ofSeconds(10));
EffectHandle blur = api.apply(player, Key.key("minecraft:blur"), Duration.ofSeconds(5), "myplugin:stun");
stun.cancel(); // removes only what this handle added
api.clear(player, "myplugin:stun"); // stops a channel
api.stop(player, "cinematic"); // stops a preset
api.clearAll(player); // everything ScreenFX shows to the player
| Method | |
|---|---|
play(player, preset) · play(player, preset, duration) | start a preset (the duration overrides its own) |
apply(player, effect, duration, channel) | one effect on your own channel; Duration.ZERO = until cancelled |
stop(player, preset) · clear(player, channel) · clearAll(player) | stop runs; they return how many |
active(player) | the running handles, oldest first |
hasPack(player) | the player loaded the ScreenFX resource pack |
canSeeEffects(player) | Java 26.3+ client |
presets() · isPreset(id) | |
playScene(player, scene) | start a cutscene of scenes.yml; true if it starts |
stopScene(player) | end the player's cutscene; true if he was watching one |
watchingScene(player) | the cutscene the player watches, or null |
scenes() | ids of every cutscene |
startShow(show) · stopShow(show) | start a show of shows.yml (false if there is no such show) · stop it (false if it was not running) |
intensity(player) | the player's intensity: soft, normal or strong |
cameraMovement(player) | false if the player turned the camera movement off |
api.playScene(player, "intro");
api.startShow("party_time");
EffectHandle: player(), preset(), channel(), origin(), isActive(), remainingTicks(), cancel().
Every method can be called from any thread: the work moves to the player's thread by itself. Players who turned effects off, players with screenfx.exempt and clients that can't show effects are respected like for commands.
Events
| Event | |
|---|---|
ScreenFXPresetStartEvent | a preset starts (cancellable) |
ScreenFXPresetEndEvent | a preset ends, with the reason |
ScreenFXEffectApplyEvent | an effect is applied (cancellable) |
ScreenFXToggleEvent | a player turns effects or flashing effects on or off |
ScreenFXSceneStartEvent | a cutscene starts for a player (cancellable) |
ScreenFXSceneEndEvent | a cutscene ends for a player |
Ultimo aggiornamento: