For an advanced effect, you can use functions to do this.
publicclassSayHelloEffectimplementsCustomEffect { @Overridepublic @NotNullCustomEffectDataeffectData() {returnnewCustomEffectData("sayhelloeffect","Say hello effect!",0,false,true); }// Called when effect ended with no problems by itself @OverridepublicvoideffectEnd(AppliedEffectData data) {data.getOfflinePlayer().getPlayer().sendMessage("Goodbye!"); }// Called when effect is interrupted for some reason // (Like player death, milk or plugin) @OverridepublicvoideffectInterrupted(AppliedEffectData data,EffectInterruptionReason reason) {data.getOfflinePlayer().getPlayer().sendMessage("Effect has been interrupted because of "+reason.toString()); } @OverridepublicvoidsecondPassed(AppliedEffectData data) {data.getOfflinePlayer().getPlayer().sendMessage(String.valueOf(data.getDuration())); }}
Don't forget to register it and you are good to go.