Problems when writing addon for Skript.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

mmcheng55

Member
Apr 17, 2022
1
0
1
25
I am having some issues with calling the Skript API. I was writing a new effect called SupplyChestClickedEffect and it did not work. Spigot are able to call the onEnable method and I did not get any error when I was using the Skript API, but it just did not work. Nothing happened even the addon is not registered. Here are my source codes:

M04Plugin.java
Code:
package tech.mmcheng55.plugin;

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAddon;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import tech.mmcheng55.java.addon.effects.SupplyChestClickedEffect;

import java.io.IOException;

public class M04Plugin extends JavaPlugin {
    private static M04Plugin instance;
    private static SkriptAddon addonInstance;

    public M04Plugin() {
        if (instance == null) {
            instance = this;
        } else {
            throw new IllegalStateException();
        }
    }

    public static M04Plugin getInstance() {
        if (instance == null) {
            throw new IllegalStateException();
        }
        return instance;
    }

    public static SkriptAddon getAddonInstance() {
        if (addonInstance == null) {
            addonInstance = Skript.registerAddon(getInstance());
            Bukkit.getLogger().info(addonInstance.toString());
        }
        return addonInstance;
    }

    @Override
    public void onEnable() {
        Skript.registerEffect(SupplyChestClickedEffect.class, "supply %player% at %block%");

        try {
            getAddonInstance().loadClasses("tech.mmcheng55.java.addon", "effects");
        } catch (IOException err) {
            Bukkit.getLogger().info(err.getMessage());
            err.printStackTrace();
        }
        Bukkit.getLogger().info("[LOADED]!!PRJP[QWEUR9WEURFPASJ");
    }
}

SupplyChestClickedEvent.java:
Code:
package tech.mmcheng55.java.addon.effects;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import tech.mmcheng55.addon.elements.KtSupplyChestClickedEffect;

public class SupplyChestClickedEffect extends Effect {
    static {
        Skript.registerEffect(SupplyChestClickedEffect.class,  "supply %player% at %block%");
    }

    @Override
    protected void execute(@NotNull Event event) {
        KtSupplyChestClickedEffect.Companion.execute(event);
    }

    @NotNull
    @Override
    public String toString(@Nullable Event event, boolean debug) {
        return KtSupplyChestClickedEffect.Companion.toString(event, debug);
    }

    @Override
    public boolean init(@NotNull Expression<?>[] expressions, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
        return KtSupplyChestClickedEffect.Companion.init(expressions, matchedPattern, isDelayed, parseResult);
    }
}
 
Last edited: