Skip to content

Rewrite: Results what are they?

Joe Sorensen edited this page Mar 5, 2022 · 1 revision

Almost every single API method on Aurora returns a Result instance. Results are used to more effectively communicate the outcome of doing things to transports and commands, so they can give more detailed feedback to users. Almost every method that returns a Result details what the possible values are, and the message field is there to indicate problems. Let's take an example:


In digital.murl.aurora.effects.Effects, we can see this method:

    /**
     * Creates and inits a new effect with a randomly generated id
     *
     * @param effectName The effect type
     * @param params     The params to pass to the effect init method
     * @return A result with the outcome of creating the effect. If the outcome is {@code SUCCESS}, the {@code message} is the new effect's id.
     */
    public static Result createEffect(String effectName, Map<String, Object> params) {
        if (!Plugin.plugin.isEnabled()) return pluginNotLoaded();

        return EffectManager.createEffect(effectName, params);
    }

In this case, we're creating a new Effect with no explicit id. The message field indicates that the id of said effect, as stated in the javadocs.