This is not registering.

  • 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!

AdminTools

Member
Nov 14, 2020
2
0
1
My code is not registering. I'm using Skript 2.6.4, using paper. I'm trying to make a skript addon and it just acts like my expression doesnt exist.

Heres my onEnable code.
Code:
@Override
    public void onEnable() {
        instance = this;
        PluginManager pm = getServer().getPluginManager();
        ConsoleCommandSender console = getServer().getConsoleSender();

        console.sendMessage(ChatColor.LIGHT_PURPLE + "RealTime is being loaded....");
        if (!pm.isPluginEnabled("Skript")) {
            getLogger().warning("Skript is not enabled, but not required. Ignoring.");
        } else {
            addon = Skript.registerAddon(this);
            try {
                addon.loadClasses("me.devlongscript.realtime", "elements");
                console.sendMessage(ChatColor.LIGHT_PURPLE + "Successfully loaded skript addon.");
            } catch (IOException e) {
                getLogger().warning("A error occurred while loading the skript addon. Not required, so continuing." + e.getStackTrace());
            }

        }


        getCommand("time").setExecutor(this);
        getCommand("time").setTabCompleter(this);
        console.sendMessage(ChatColor.LIGHT_PURPLE + "  _____            _ _______ _                ");
        console.sendMessage(ChatColor.LIGHT_PURPLE + " |  __ \\          | |__   __(_)               ");
        console.sendMessage(ChatColor.LIGHT_PURPLE + " | |__) |___  __ _| |  | |   _ _ __ ___   ___ ");
        console.sendMessage(ChatColor.LIGHT_PURPLE + " |  _  // _ \\/ _` | |  | |  | | '_ ` _ \\ / _ \\");
        console.sendMessage(ChatColor.LIGHT_PURPLE + " | | \\ \\  __/ (_| | |  | |  | | | | | | |  __/");
        console.sendMessage(ChatColor.LIGHT_PURPLE + " |_|  \\_\\___|\\__,_|_|  |_|  |_|_| |_| |_|\\___|");
        console.sendMessage(ChatColor.LIGHT_PURPLE + " Loaded version "+ getDescription().getVersion() + " . All configs are read.");
    }

And my expression.
Code:
package me.devlongscript.realtime.elements.expressions;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
import me.devlongscript.realtime.GeneralStuff;

public class SkriptAPI extends SimpleExpression<String> {

    static {
        Skript.registerExpression(SkriptAPI.class, String.class, ExpressionType.PROPERTY, "%player%['s] timezone");
    }

    private Expression<Player> player;
    private GeneralStuff generalStuff = new GeneralStuff();

    @Override
    public Class<? extends String> getReturnType() {
        return String.class;
    }

    @Override
    public boolean isSingle() {
        return true;
    }

    @Override
    public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
        player = (Expression<Player>) exprs[0];
        return true;
    }

    @Override
    public String toString(@Nullable Event event, boolean debug) {
        return "Getting timezone of player : " + player.toString(event, debug);
    }

    @Override
    @Nullable
    protected String[] get(Event event) {

        Player p = player.getSingle(event);
        if (p != null) {
            return new String[] {
                generalStuff.GetTZMap().get(p.getUniqueId().toString())
            };
        }
        return null;
    }
}

And if my skripts wrong, here it is:
Code:
on join:
  set {ye} to player timezone
  broadcast {ye}
 
I would investigate logs for any errors just in case. My best assumption is that Skript is failing because your `get` method is protected instead of public.