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.

This is not registering.

Discussion in 'Java' started by AdminTools, Mar 13, 2023.

  1. AdminTools

    AdminTools Member

    Joined:
    Nov 14, 2020
    Messages:
    2
    Likes Received:
    0
    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 (Text):
    1. @Override
    2.     public void onEnable() {
    3.         instance = this;
    4.         PluginManager pm = getServer().getPluginManager();
    5.         ConsoleCommandSender console = getServer().getConsoleSender();
    6.  
    7.         console.sendMessage(ChatColor.LIGHT_PURPLE + "RealTime is being loaded....");
    8.         if (!pm.isPluginEnabled("Skript")) {
    9.             getLogger().warning("Skript is not enabled, but not required. Ignoring.");
    10.         } else {
    11.             addon = Skript.registerAddon(this);
    12.             try {
    13.                 addon.loadClasses("me.devlongscript.realtime", "elements");
    14.                 console.sendMessage(ChatColor.LIGHT_PURPLE + "Successfully loaded skript addon.");
    15.             } catch (IOException e) {
    16.                 getLogger().warning("A error occurred while loading the skript addon. Not required, so continuing." + e.getStackTrace());
    17.             }
    18.  
    19.         }
    20.  
    21.  
    22.         getCommand("time").setExecutor(this);
    23.         getCommand("time").setTabCompleter(this);
    24.         console.sendMessage(ChatColor.LIGHT_PURPLE + "  _____            _ _______ _                ");
    25.         console.sendMessage(ChatColor.LIGHT_PURPLE + " |  __ \\          | |__   __(_)               ");
    26.         console.sendMessage(ChatColor.LIGHT_PURPLE + " | |__) |___  __ _| |  | |   _ _ __ ___   ___ ");
    27.         console.sendMessage(ChatColor.LIGHT_PURPLE + " |  _  // _ \\/ _` | |  | |  | | '_ ` _ \\ / _ \\");
    28.         console.sendMessage(ChatColor.LIGHT_PURPLE + " | | \\ \\  __/ (_| | |  | |  | | | | | | |  __/");
    29.         console.sendMessage(ChatColor.LIGHT_PURPLE + " |_|  \\_\\___|\\__,_|_|  |_|  |_|_| |_| |_|\\___|");
    30.         console.sendMessage(ChatColor.LIGHT_PURPLE + " Loaded version "+ getDescription().getVersion() + " . All configs are read.");
    31.     }
    And my expression.
    Code (Text):
    1. package me.devlongscript.realtime.elements.expressions;
    2.  
    3. import ch.njol.skript.Skript;
    4. import ch.njol.skript.lang.Expression;
    5. import ch.njol.skript.lang.ExpressionType;
    6. import ch.njol.skript.lang.SkriptParser;
    7. import ch.njol.skript.lang.util.SimpleExpression;
    8. import ch.njol.util.Kleenean;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Event;
    11. import org.jetbrains.annotations.Nullable;
    12. import me.devlongscript.realtime.GeneralStuff;
    13.  
    14. public class SkriptAPI extends SimpleExpression<String> {
    15.  
    16.     static {
    17.         Skript.registerExpression(SkriptAPI.class, String.class, ExpressionType.PROPERTY, "%player%['s] timezone");
    18.     }
    19.  
    20.     private Expression<Player> player;
    21.     private GeneralStuff generalStuff = new GeneralStuff();
    22.  
    23.     @Override
    24.     public Class<? extends String> getReturnType() {
    25.         return String.class;
    26.     }
    27.  
    28.     @Override
    29.     public boolean isSingle() {
    30.         return true;
    31.     }
    32.  
    33.     @Override
    34.     public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
    35.         player = (Expression<Player>) exprs[0];
    36.         return true;
    37.     }
    38.  
    39.     @Override
    40.     public String toString(@Nullable Event event, boolean debug) {
    41.         return "Getting timezone of player : " + player.toString(event, debug);
    42.     }
    43.  
    44.     @Override
    45.     @Nullable
    46.     protected String[] get(Event event) {
    47.  
    48.         Player p = player.getSingle(event);
    49.         if (p != null) {
    50.             return new String[] {
    51.                 generalStuff.GetTZMap().get(p.getUniqueId().toString())
    52.             };
    53.         }
    54.         return null;
    55.     }
    56. }
    57.  
    58.  
    And if my skripts wrong, here it is:
    Code (Text):
    1. on join:
    2.   set {ye} to player timezone
    3.   broadcast {ye}
     

Share This Page

Loading...