1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problems when writing addon for Skript.

Discussion in 'Java' started by mmcheng55, Apr 17, 2022.

  1. mmcheng55

    mmcheng55 Member

    Joined:
    Apr 17, 2022
    Messages:
    1
    Likes Received:
    0
    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 (Text):
    1.  
    2.  
    3. package tech.mmcheng55.plugin;
    4.  
    5. import ch.njol.skript.Skript;
    6. import ch.njol.skript.SkriptAddon;
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9. import tech.mmcheng55.java.addon.effects.SupplyChestClickedEffect;
    10.  
    11. import java.io.IOException;
    12.  
    13. public class M04Plugin extends JavaPlugin {
    14.     private static M04Plugin instance;
    15.     private static SkriptAddon addonInstance;
    16.  
    17.     public M04Plugin() {
    18.         if (instance == null) {
    19.             instance = this;
    20.         } else {
    21.             throw new IllegalStateException();
    22.         }
    23.     }
    24.  
    25.     public static M04Plugin getInstance() {
    26.         if (instance == null) {
    27.             throw new IllegalStateException();
    28.         }
    29.         return instance;
    30.     }
    31.  
    32.     public static SkriptAddon getAddonInstance() {
    33.         if (addonInstance == null) {
    34.             addonInstance = Skript.registerAddon(getInstance());
    35.             Bukkit.getLogger().info(addonInstance.toString());
    36.         }
    37.         return addonInstance;
    38.     }
    39.  
    40.     @Override
    41.     public void onEnable() {
    42.         Skript.registerEffect(SupplyChestClickedEffect.class, "supply %player% at %block%");
    43.  
    44.         try {
    45.             getAddonInstance().loadClasses("tech.mmcheng55.java.addon", "effects");
    46.         } catch (IOException err) {
    47.             Bukkit.getLogger().info(err.getMessage());
    48.             err.printStackTrace();
    49.         }
    50.         Bukkit.getLogger().info("[LOADED]!!PRJP[QWEUR9WEURFPASJ");
    51.     }
    52. }
    53.  
    SupplyChestClickedEvent.java:
    Code (Text):
    1.  
    2. package tech.mmcheng55.java.addon.effects;
    3.  
    4. import ch.njol.skript.Skript;
    5. import ch.njol.skript.lang.Effect;
    6. import ch.njol.skript.lang.Expression;
    7. import ch.njol.skript.lang.ExpressionType;
    8. import ch.njol.skript.lang.SkriptParser;
    9. import ch.njol.util.Kleenean;
    10. import org.bukkit.event.Event;
    11. import org.jetbrains.annotations.NotNull;
    12. import org.jetbrains.annotations.Nullable;
    13. import tech.mmcheng55.addon.elements.KtSupplyChestClickedEffect;
    14.  
    15. public class SupplyChestClickedEffect extends Effect {
    16.     static {
    17.         Skript.registerEffect(SupplyChestClickedEffect.class,  "supply %player% at %block%");
    18.     }
    19.  
    20.     @Override
    21.     protected void execute(@NotNull Event event) {
    22.         KtSupplyChestClickedEffect.Companion.execute(event);
    23.     }
    24.  
    25.     @NotNull
    26.     @Override
    27.     public String toString(@Nullable Event event, boolean debug) {
    28.         return KtSupplyChestClickedEffect.Companion.toString(event, debug);
    29.     }
    30.  
    31.     @Override
    32.     public boolean init(@NotNull Expression<?>[] expressions, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
    33.         return KtSupplyChestClickedEffect.Companion.init(expressions, matchedPattern, isDelayed, parseResult);
    34.     }
    35. }
    36.  
     
    #1 mmcheng55, Apr 17, 2022
    Last edited: Apr 17, 2022

Share This Page

Loading...