java.lang.Object
io.github.thebusybiscuit.slimefun4.implementation.items.androids.Script

public final class Script extends Object
A Script represents runnable code for a ProgrammableAndroid.
Author:
TheBusyBiscuit
  • Method Details

    • getName

      @Nonnull public String getName()
      This returns the name of this Script.
      Returns:
      The name
    • getAuthor

      @Nonnull public String getAuthor()
      This returns the author of this Script. The author is the person who initially created and uploaded this Script.
      Returns:
      The author of this Script
    • getSourceCode

      @Nonnull public String getSourceCode()
      This method returns the actual code of this Script. It is basically a String describing the order of Instructions that shall be executed.
      Returns:
      The code for this Script
    • isAuthor

      public boolean isAuthor(@Nonnull OfflinePlayer p)
      This method determines whether the given OfflinePlayer is the author of this Script.
      Parameters:
      p - The OfflinePlayer to check for
      Returns:
      Whether the given OfflinePlayer is the author of this Script.
    • canRate

      public boolean canRate(@Nonnull Player p)
      This method checks whether a given Player is able to leave a rating for this Script. A Player is unable to rate his own Script or a Script he already rated before.
      Parameters:
      p - The Player to check for
      Returns:
      Whether the given Player is able to rate this Script
    • getUpvotes

      public int getUpvotes()
      This method returns the amount of upvotes this Script has received.
      Returns:
      The amount of upvotes
    • getDownvotes

      public int getDownvotes()
      This method returns the amount of downvotes this Script has received.
      Returns:
      The amount of downvotes
    • getDownloads

      public int getDownloads()
      This returns how often this Script has been downloaded.
      Returns:
      The amount of downloads for this Script.
    • getRating

      public float getRating()
      This returns the "rating" of this Script. This value is calculated from the up- and downvotes this Script received.
      Returns:
      The rating for this Script
    • download

      public void download()
      This method increases the amount of downloads by one.
    • rate

      public void rate(@Nonnull Player p, boolean positive)
    • getUploadedScripts

      @Nonnull public static List<Script> getUploadedScripts(@Nonnull AndroidType androidType)
    • upload

      @ParametersAreNonnullByDefault public static void upload(Player p, AndroidType androidType, int id, String name, String code)