Class Skript

java.lang.Object
ch.njol.skript.Skript
All Implemented Interfaces:
Listener

public final class Skript extends Object implements Listener
Skript - A Bukkit plugin to modify how Minecraft behaves without having to write a single line of code (You'll likely be writing some code though if you're reading this =P)

Use this class to extend this plugin's functionality by adding more conditions, effects, expressions, etc.

If your plugin.yml contains 'depend: [Skript]' then your plugin will not start at all if Skript is not present. Add 'softdepend: [Skript]' to your plugin.yml if you want your plugin to work even if Skript isn't present, but want to make sure that Skript gets loaded before your plugin.

If you use 'softdepend' you can test whether Skript is loaded with 'Bukkit.getPluginManager().getPlugin("Skript") != null'

Once you made sure that Skript is loaded you can use Skript.getInstance() whenever you need a reference to the plugin, but you likely won't need it since all API methods are static.

See Also:
  • Field Details Link icon

    • message_invalid_reload Link icon

      public static final Message message_invalid_reload
    • message_finished_loading Link icon

      public static final Message message_finished_loading
    • message_no_errors Link icon

      public static final Message message_no_errors
    • message_no_scripts Link icon

      public static final Message message_no_scripts
    • SCRIPTSFOLDER Link icon

      public static final String SCRIPTSFOLDER
      See Also:
    • EPSILON Link icon

      public static final double EPSILON
      A small value, useful for comparing doubles or floats.

      E.g. to test whether two floating-point numbers are equal:

       Math.abs(a - b) < Skript.EPSILON
       

      or whether a location is within a specific radius of another location:

       location.distanceSquared(center) - radius * radius < Skript.EPSILON
       
      See Also:
    • EPSILON_MULT Link icon

      public static final double EPSILON_MULT
      A value a bit larger than 1
      See Also:
    • UEH Link icon

      public static final Thread.UncaughtExceptionHandler UEH
  • Constructor Details Link icon

  • Method Details Link icon

    • getSkriptInstance Link icon

      public static Skript getSkriptInstance()
      Get an instance of Skript
      Returns:
      Instance of Skript
      See Also:
    • getInstance Link icon

      @Deprecated public static SkriptPlugin getInstance()
      Deprecated.
      Gets an instance of SkriptPlugin
      Returns:
      Instance of SkriptPlugin
    • getSkriptPluginInstance Link icon

      public static SkriptPlugin getSkriptPluginInstance()
    • updateMinecraftVersion Link icon

      public static void updateMinecraftVersion()
      Check minecraft version and assign it to minecraftVersion field This method is created to update MC version before onEnable method To fix Utils.HEX_SUPPORTED being assigned before minecraftVersion is properly assigned
    • getVersion Link icon

      public static Version getVersion()
    • getServerPlatform Link icon

      public static ServerPlatform getServerPlatform()
    • isHookEnabled Link icon

      public static boolean isHookEnabled(Class<? extends ch.njol.skript.hooks.Hook<?>> hook)
      Checks whether a hook has been enabled.
      Parameters:
      hook - The hook to check.
      Returns:
      Whether the hook is enabled.
      See Also:
    • isFinishedLoadingHooks Link icon

      public static boolean isFinishedLoadingHooks()
      Returns:
      whether hooks have been loaded, and if disableHookRegistration(Class[]) won't error because of this.
    • disableHookRegistration Link icon

      @SafeVarargs public static void disableHookRegistration(Class<? extends ch.njol.skript.hooks.Hook<?>>... hooks)
      Disables the registration for the given hook classes. If Skript has been enabled, this method will throw an API exception. It should be used in something like JavaPlugin.onLoad().
      Parameters:
      hooks - The hooks to disable the registration of.
      See Also:
    • experiments Link icon

      public static ExperimentRegistry experiments()
      Returns:
      The manager for experimental, optional features.
    • setInstance Link icon

      public static void setInstance(Skript instance)
    • getScriptsFolder Link icon

      public File getScriptsFolder()
      Returns:
      The folder containing all Scripts.
    • getMinecraftVersion Link icon

      public static Version getMinecraftVersion()
    • isRunningMinecraft Link icon

      public static boolean isRunningMinecraft(int major, int minor)
      Returns:
      Whether this server is running Minecraft major.minor or higher
    • isRunningMinecraft Link icon

      public static boolean isRunningMinecraft(int major, int minor, int revision)
    • isRunningMinecraft Link icon

      public static boolean isRunningMinecraft(Version v)
    • classExists Link icon

      public static boolean classExists(String className)
      Tests whether a given class exists in the classpath.
      Parameters:
      className - The canonical name of the class
      Returns:
      Whether the given class exists.
    • methodExists Link icon

      public static boolean methodExists(Class<?> c, String methodName, Class<?>... parameterTypes)
      Tests whether a method exists in the given class.
      Parameters:
      c - The class
      methodName - The name of the method
      parameterTypes - The parameter types of the method
      Returns:
      Whether the given method exists.
    • methodExists Link icon

      public static boolean methodExists(Class<?> c, String methodName, Class<?>[] parameterTypes, Class<?> returnType)
      Tests whether a method exists in the given class, and whether the return type matches the expected one.

      Note that this method doesn't work properly if multiple methods with the same name and parameters exist but have different return types.

      Parameters:
      c - The class
      methodName - The name of the method
      parameterTypes - The parameter types of the method
      returnType - The expected return type
      Returns:
      Whether the given method exists.
    • fieldExists Link icon

      public static boolean fieldExists(Class<?> c, String fieldName)
      Tests whether a field exists in the given class.
      Parameters:
      c - The class
      fieldName - The name of the field
      Returns:
      Whether the given field exists.
    • outdatedError Link icon

      public static void outdatedError()
    • outdatedError Link icon

      public static void outdatedError(Exception e)
    • toString Link icon

      public static String toString(double n)
    • newThread Link icon

      public static Thread newThread(Runnable r, String name)
      Creates a new Thread and sets its UncaughtExceptionHandler. The Thread is not started automatically.
    • isAcceptRegistrations Link icon

      public static boolean isAcceptRegistrations()
    • checkAcceptRegistrations Link icon

      public static void checkAcceptRegistrations()
    • registerAddon Link icon

      public static SkriptAddon registerAddon(JavaPlugin p)
      Registers an addon to Skript. This is currently not required for addons to work, but the returned SkriptAddon provides useful methods for registering syntax elements and adding new strings to Skript's localization system (e.g. the required "types.[type]" strings for registered classes).
      Parameters:
      p - The plugin
    • getAddon Link icon

      @Nullable public static @Nullable SkriptAddon getAddon(JavaPlugin p)
    • getAddon Link icon

      @Nullable public static @Nullable SkriptAddon getAddon(String name)
    • getAddons Link icon

      public static Collection<SkriptAddon> getAddons()
    • registerCondition Link icon

      public static <E extends Condition> void registerCondition(Class<E> condition, String... patterns) throws IllegalArgumentException
      registers a Condition.
      Parameters:
      condition - The condition's class
      patterns - Skript patterns to match this condition
      Throws:
      IllegalArgumentException
    • registerEffect Link icon

      public static <E extends Effect> void registerEffect(Class<E> effect, String... patterns) throws IllegalArgumentException
      Registers an Effect.
      Parameters:
      effect - The effect's class
      patterns - Skript patterns to match this effect
      Throws:
      IllegalArgumentException
    • registerSection Link icon

      public static <E extends Section> void registerSection(Class<E> section, String... patterns) throws IllegalArgumentException
      Registers a Section.
      Parameters:
      section - The section's class
      patterns - Skript patterns to match this section
      Throws:
      IllegalArgumentException
      See Also:
    • getStatements Link icon

      public static Collection<SyntaxElementInfo<? extends Statement>> getStatements()
    • getConditions Link icon

      public static Collection<SyntaxElementInfo<? extends Condition>> getConditions()
    • getEffects Link icon

      public static Collection<SyntaxElementInfo<? extends Effect>> getEffects()
    • getSections Link icon

      public static Collection<SyntaxElementInfo<? extends Section>> getSections()
    • registerExpression Link icon

      public static <E extends Expression<T>, T> void registerExpression(Class<E> c, Class<T> returnType, ExpressionType type, String... patterns) throws IllegalArgumentException
      Registers an expression.
      Parameters:
      c - The expression's class
      returnType - The superclass of all values returned by the expression
      type - The expression's type. This is used to determine in which order to try to parse expressions.
      patterns - Skript patterns that match this expression
      Throws:
      IllegalArgumentException - if returnType is not a normal class
    • getExpressions Link icon

      public static Iterator<ExpressionInfo<?,?>> getExpressions()
    • getExpressions Link icon

      public static Iterator<ExpressionInfo<?,?>> getExpressions(Class<?>... returnTypes)
    • registerEvent Link icon

      public static <E extends SkriptEvent> SkriptEventInfo<E> registerEvent(String name, Class<E> c, Class<? extends Event> event, String... patterns)
      Registers an event.
      Parameters:
      name - Capitalised name of the event without leading "On" which is added automatically (Start the name with an asterisk to prevent this). Used for error messages and the documentation.
      c - The event's class
      event - The Bukkit event this event applies to
      patterns - Skript patterns to match this event
      Returns:
      A SkriptEventInfo representing the registered event. Used to generate Skript's documentation.
    • registerEvent Link icon

      public static <E extends SkriptEvent> SkriptEventInfo<E> registerEvent(String name, Class<E> c, Class<? extends Event>[] events, String... patterns)
      Registers an event.
      Parameters:
      name - The name of the event, used for error messages
      c - The event's class
      events - The Bukkit events this event applies to
      patterns - Skript patterns to match this event
      Returns:
      A SkriptEventInfo representing the registered event. Used to generate Skript's documentation.
    • registerStructure Link icon

      public static <E extends Structure> void registerStructure(Class<E> c, String... patterns)
    • registerSimpleStructure Link icon

      public static <E extends Structure> void registerSimpleStructure(Class<E> c, String... patterns)
    • registerStructure Link icon

      public static <E extends Structure> void registerStructure(Class<E> c, EntryValidator entryValidator, String... patterns)
    • getEvents Link icon

      public static Collection<SkriptEventInfo<?>> getEvents()
    • getStructures Link icon

      public static List<StructureInfo<? extends Structure>> getStructures()
    • dispatchCommand Link icon

      public static boolean dispatchCommand(CommandSender sender, String command)
      Dispatches a command with calling command events
      Parameters:
      sender -
      command -
      Returns:
      Whether the command was run
    • logNormal Link icon

      public static boolean logNormal()
    • logHigh Link icon

      public static boolean logHigh()
    • logVeryHigh Link icon

      public static boolean logVeryHigh()
    • debug Link icon

      public static boolean debug()
    • testing Link icon

      public static boolean testing()
    • log Link icon

      public static boolean log(Verbosity minVerb)
    • debug Link icon

      public static void debug(String info)
    • info Link icon

      public static void info(String info)
      See Also:
    • warning Link icon

      public static void warning(String warning)
      See Also:
    • error Link icon

      public static void error(@Nullable @Nullable String error)
      See Also:
    • error Link icon

      public static void error(String error, ErrorQuality quality)
      Use this in SyntaxElement.init(Expression[], int, Kleenean, ch.njol.skript.lang.SkriptParser.ParseResult) (and other methods that are called during the parsing) to log errors with a specific ErrorQuality.
      Parameters:
      error -
      quality -
    • exception Link icon

      public static EmptyStacktraceException exception(String... info)
      Used if something happens that shouldn't happen
      Parameters:
      info - Description of the error and additional information
      Returns:
      an EmptyStacktraceException to throw if code execution should terminate.
    • exception Link icon

      public static EmptyStacktraceException exception(@Nullable @Nullable Throwable cause, String... info)
    • exception Link icon

      public static EmptyStacktraceException exception(@Nullable @Nullable Throwable cause, @Nullable @Nullable Thread thread, String... info)
    • exception Link icon

      public static EmptyStacktraceException exception(@Nullable @Nullable Throwable cause, @Nullable @Nullable TriggerItem item, String... info)
    • markErrored Link icon

      public static void markErrored()
      Mark that an exception has occurred at some point during runtime. Only used for Skript's testing system.
    • exception Link icon

      public static EmptyStacktraceException exception(@Nullable @Nullable Throwable cause, @Nullable @Nullable Thread thread, @Nullable @Nullable TriggerItem item, String... info)
      Used if something happens that shouldn't happen
      Parameters:
      cause - exception that shouldn't occur
      info - Description of the error and additional information
      Returns:
      an EmptyStacktraceException to throw if code execution should terminate.
    • getSkriptPrefix Link icon

      public static String getSkriptPrefix()
    • info Link icon

      public static void info(CommandSender sender, String info)
    • broadcast Link icon

      public static void broadcast(String message, String permission)
      Parameters:
      message -
      permission -
      See Also:
    • adminBroadcast Link icon

      public static void adminBroadcast(String message)
    • message Link icon

      public static void message(CommandSender sender, String info)
      Similar to info(CommandSender, String) but no [Skript] prefix is added.
      Parameters:
      sender -
      info -
    • error Link icon

      public static void error(CommandSender sender, String error)
    • getUpdater Link icon

      @Nullable public @Nullable SkriptUpdater getUpdater()
      Gets the updater instance currently used by Skript.
      Returns:
      SkriptUpdater instance.