ScriptManager.sk

Created by FireMan9534

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.

#ScriptManager made by FireMan9534_TW | Discord: Fire_Man9534#4598 | plugin: skript
#(un)loading message not sending to players dont have permission
#save your tps
#settings
options:
  prefix: &7[&e&lSM&7]
  full prefix: &7[&e&lScriptManager&7]
  full name: &e&lScriptManager
  permission: skript.admin
  permission message: &7[&e&lSM&7] &cYou dont have permission to do this!
  v: 1.5
#not options like setting
options:
  i: inventory
  tg: metadata tag "scriptmanager::gui" of
  tg2: metadata tag "scriptmanager::mode" of
  ss: set slot
  sm: scriptmanager
on load:
  close {@i} for all players where [{@tg} player input is set]
  delete {@tg} all offline players
  delete {@tg2} all offline players
  delete {{@sm}::*}
  wait 1 tick
  if {{@sm}::load} = true:
    delete {{@sm}::load}
  else:
    set {_m} to "{@prefix} {@full name} &aLoaded. &7Made by FireMan9534_TW"
    send {_m} to all players where [player input have permission "{@permission}"]
    send {_m} to console
on unload:
  close {@i} for all players where [{@tg} player input is set]
  delete {@tg} all offline players
  delete {@tg2} all offline players
  delete {{@sm}::*}
  wait 1 tick
  if script is loaded:
    set {_m} to "{@prefix} {@full name} &aReloaded. &7Made by FireMan9534_TW"
    set {{@sm}::load} to true
  else:
    set {_m} to "{@prefix} {@full name} &7Unloaded."
  send {_m} to all players where [player input have permission "{@permission}"]
  send {_m} to console
command /{@sm} [<text>]:
  permission: {@permission}
  permission message: {@permission message}
  aliases: /sm, /scriptm, /smanager
  trigger:
    {@sm}_gui(player)
function scriptmanager_gui(p: player):
  set {_scripts::*} to all scripts where [input is not "%script%.sk" or "-%script%.sk"]
  if {@tg} {_p} is not set:
    close {@i} for {_p}
    set {@tg} {_p} to chest {@i} named "{@full prefix} &3Made by FireMan9534_TW" with 6 rows
    set {_set} to false
    play sound "ui.toast.in" for {_p}
  delete {{@sm}::script::%{_p}%::*}
  loop {_scripts::*}:
    set {_t} to "%loop-value%"
    if {_t} start with "-":
      replace first "-" with "" in {_t}
    else if {_t} contains "/-":
      replace all "/-" with "/" in {_t}
    set {{@sm}::script::%{_p}%::%loop-index%} to subtext of {_t} from 1 to (length of {_t} - 3)
    set {{@sm}::script::%{_p}%::%loop-index%::f} to loop-value
  if {{@sm}::page::%{_p}%} is not set:
    set {{@sm}::page::%{_p}%} to 1
  set {_l} to (1 + (36 * ({{@sm}::page::%{_p}%} - 1)))
  if {{@sm}::script::%{_p}%::%{_l}%} is not set:
    set {{@sm}::page::%{_p}%} to 1
  set {_page} to {{@sm}::page::%{_p}%}
  loop 36 times:
    set {_l} to (loop-number + (36 * ({_page} - 1)))
    if {{@sm}::script::%{_p}%::%{_l}%} is set:
      set {_sn} to {{@sm}::script::%{_p}%::%{_l}%}
      if "%enabled scripts%" contains {{@sm}::script::%{_p}%::%{_l}%::f}:
        if {{@sm}::script::%{_p}%::%{_l}%} contains "/":
          replace all "/" with "&e&l/&a" in {_sn}
        {@ss} loop-number - 1 of {@tg} {_p} to lime dye with lore "&7Left click to &areload" and "&7Right click to &cdisable" named "&a%{_sn}%"
      else if "%disabled scripts%" contains {{@sm}::script::%{_p}%::%{_l}%::f}:
        if {{@sm}::script::%{_p}%::%{_l}%} contains "/":
          replace all "/" with "&e&l/&c" in {_sn}
        {@ss} loop-number - 1 of {@tg} {_p} to gray dye with lore "&7Left click to &aenable" named "&c%{_sn}%"
    else:
      {@ss} loop-number - 1 of {@tg} {_p} to air
  set {_e} to amount of ({_scripts::*} where [script input is loaded])
  set {_d} to amount of {_scripts::*} - {_e}
  {@ss} 45 of {@tg} {_p} to light green wool with lore "&bLeft click to reload all enabled scripts" and "&aMiddle click to enable all scripts" and "&cRight click to disable all scripts" named "&bAll scripts"
  {@ss} 46 of {@tg} {_p} to red wool with lore "&cMake sure server can bear!" and "&7Also reset scripts list(if you added or removed any script)" named "&cReload all scripts(command)"
  if {@tg2} {_p} is true:
    {@ss} 48 of {@tg} {_p} to orange stained glass pane with lore "&6Skript Command" and "&7Click to toggle" named "&eM&6o&ed&6e"
  else:
    {@ss} 48 of {@tg} {_p} to yellow stained glass pane with lore "&eScriptManager" and "&7Click to toggle" named "&6M&eo&6d&ee"
  {@ss} 49 of {@tg} {_p} to lever named "&eRefresh"
  {@ss} 50 of {@tg} {_p} to paper with lore " &bStatus" and "  &6Scripts" and "   &aEnabled&7: &b%{_e}%" and "   &cDisabled&7: &b%{_d}%" and "   &bTotal&7: &b%amount of {_scripts::*}%" and "  &eTPS&7: &e%tps from last 1 minute%, %tps from last 5 minutes%, %tps from last 15 minutes%" and " &bVersion" and "  &aMinecraft&7: &b%minecraft version%" and "  &bBukkit&7: &b%bukkit version%" and "  &6Skript&7: &b%skript version%" named "&3Info"
  {@ss} 51 of {@tg} {_p} to light blue wool named "&bReload {@full name}"
  {@ss} 52 of {@tg} {_p} to light gray wool with lore "&7To enable again:" and "&7/skript enable %script%" named "&cDisable {@full name}"
  {@ss} 53 of {@tg} {_p} to barrier named "&cClose"
  if {_page} > 1:
    {@ss} 39 of {@tg} {_p} to arrow with lore "&b%{_page} - 1%" named "&b<<< Previous page"
  else:
    {@ss} 39 of {@tg} {_p} to air
  set {_c} to ( 1 + ({_page} * 36 ))
  if {{@sm}::script::%{_p}%::%{_c}%} is set:
    {@ss} 41 of {@tg} {_p} to arrow with lore "&b%{_page} + 1%" named "&bNext page >>>"
  else:
    {@ss} 41 of {@tg} {_p} to air
  {@ss} 40 of {@tg} {_p} to book with lore "&b%{_page}%" named "&ePage"
  if {_set} = false:
    open {@tg} {_p} for {_p}
function scriptmanager_gui_click(p: player, s: number, c: number, cl: number):
  if {_s} <= 36:
    if {{@sm}::page::%{_p}%} > 1:
      set {_s} to {_s} + (36 * ({{@sm}::page::%{_p}%} - 1))
    if {{@sm}::script::%{_p}%::%{_s}%} is set:
      if {_cl} = 1:
        set {_time} to now
        play sound "block.stone_button.click_on" for {_p}
        if script {{@sm}::script::%{_p}%::%{_s}%} is loaded:
          send "{@prefix} &bReloading %{{@sm}::script::%{_p}%::%{_s}%}% &b..." to {_p}
          if {@tg2} {_p} is not true:
            reload script {{@sm}::script::%{_p}%::%{_s}%}
          else:
            execute {_p} command "skript:skript reload %{{@sm}::script::%{_p}%::%{_s}%}%"
          set {_time} to difference between {_time} and now
          send "{@prefix} &aReloaded %{{@sm}::script::%{_p}%::%{_s}%}% &7(%{_time}%&7)" to {_p}
          play sound "entity.experience_orb.pickup" for {_p}
        else:
          send "{@prefix} &bEnabling %{{@sm}::script::%{_p}%::%{_s}%}% &b..." to {_p}
          if {@tg2} {_p} is not true:
            enable script {{@sm}::script::%{_p}%::%{_s}%}
          else:
            execute {_p} command "skript:skript enable %{{@sm}::script::%{_p}%::%{_s}%}%"
          set {_time} to difference between {_time} and now
          send "{@prefix} &aEnabled %{{@sm}::script::%{_p}%::%{_s}%}% &7(%{_time}%&7)" to {_p}
          play sound "entity.experience_orb.pickup" for {_p}
      else if {_cl} = 2 or 3:
        if script {{@sm}::script::%{_p}%::%{_s}%} is loaded:
          send "{@prefix} &bDisabling %{{@sm}::script::%{_p}%::%{_s}%}% &b..." to {_p}
          set {_time} to now
          if {@tg2} {_p} is not true:
            disable script {{@sm}::script::%{_p}%::%{_s}%}
          else:
            execute {_p} command "skript:skript disable %{{@sm}::script::%{_p}%::%{_s}%}%"
          set {_time} to difference between {_time} and now
          send "{@prefix} &cDisabled %{{@sm}::script::%{_p}%::%{_s}%}% &7(%{_time}%&7)" to {_p}
          play sound "entity.experience_orb.pickup" for {_p}
    {@sm}_gui({_p})
  else if {_s} >= 37:
    if {_s} = 46:
      set {_time} to now
      if {_cl} = 1:
        send "{@prefix} &bReloading all enabled scripts..." to {_p}
        set {_a} to amount of ({{@sm}::script::%{_p}%::*} where [script input is loaded])
        if {@tg2} {_p} is not true:
          loop {{@sm}::script::%{_p}%::*} where [script input is loaded]:
            play sound "block.stone_button.click_on" for {_p}
            add 1 to {_aa}
            if {@tg} {_p} is set:
              {@sm}_gui({_p})
              set slot 45 of {@tg} {_p} to white glass pane with lore "&b%{_aa}%&7/&b%{_a}% &e%100 * {_aa} / {_a}%%%" named "&bReloading all enabled scripts..."
              wait 1 tick
            reload script "%loop-value%"
        else:
          loop {{@sm}::script::%{_p}%::*} where [script input is loaded]:
            play sound "block.stone_button.click_on" for {_p}
            add 1 to {_aa}
            if {@tg} {_p} is set:
              {@sm}_gui({_p})
              set slot 45 of {@tg} {_p} to white glass pane with lore "&b%{_aa}%&7/&b%{_a}% &e%100 * {_aa} / {_a}%%%" named "&bReloading all enabled scripts..."
              wait 1 tick
            execute {_p} command "skript:skript reload %loop-value%"
        set {_time} to difference between {_time} and now
        wait 1 tick
        send "{@prefix} &bReloaded &aall enabled scripts &7(%{_time}%&7)" to {_p}
        play sound "entity.experience_orb.pickup" for {_p}
      else if {_cl} = 3:
        play sound "block.stone_button.click_on" for {_p}
        send "{@prefix} &bEnabling all disabled scripts..." to {_p}
        set {_a} to amount of ({{@sm}::script::%{_p}%::*} where [script input is not loaded])
        if {@tg2} {_p} is not true:
          loop {{@sm}::script::%{_p}%::*} where [script input is not loaded]:
            play sound "block.stone_button.click_on" for {_p}
            add 1 to {_aa}
            if {@tg} {_p} is set:
              {@sm}_gui({_p})
              set slot 45 of {@tg} {_p} to white glass pane with lore "&b%{_aa}%&7/&b%{_a}% &e%100 * {_aa} / {_a}%%%" named "&bEnabling all disabled scripts..."
              wait 1 tick
            enable script "%loop-value%"
        else:
          loop {{@sm}::script::%{_p}%::*} where [script input is not loaded]:
            play sound "block.stone_button.click_on" for {_p}
            add 1 to {_aa}
            if {@tg} {_p} is set:
              {@sm}_gui({_p})
              set slot 45 of {@tg} {_p} to white glass pane with lore "&b%{_aa}%&7/&b%{_a}% &e%100 * {_aa} / {_a}%%%" named "&bEnabling all disabled scripts..."
              wait 1 tick
            execute {_p} command "skript:skript enable %loop-value%"
        set {_time} to difference between {_time} and now
        send "{@prefix} &aEnabled all disabled scripts &7(%{_time}%&7)" to {_p}
        play sound "entity.experience_orb.pickup" for {_p}
      else if {_cl} = 2:
        play sound "block.stone_button.click_on" for {_p}
        send "{@prefix} &bDisabling all enabled scripts..." to {_p}
        set {_a} to amount of ({{@sm}::script::%{_p}%::*} where [script input is loaded])
        if {@tg2} {_p} is not true:
          loop {{@sm}::script::%{_p}%::*} where [script input is loaded]:
            play sound "block.stone_button.click_on" for {_p}
            add 1 to {_aa}
            if {@tg} {_p} is set:
              {@sm}_gui({_p})
              set slot 45 of {@tg} {_p} to white glass pane with lore "&b%{_aa}%&7/&b%{_a}% &e%100 * {_aa} / {_a}%%%" named "&bDisabling all enabled scripts..."
              wait 1 tick
            disable script "%loop-value%"
        else:
          loop {{@sm}::script::%{_p}%::*} where [script input is loaded]:
            play sound "block.stone_button.click_on" for {_p}
            add 1 to {_aa}
            if {@tg} {_p} is set:
              {@sm}_gui({_p})
              set slot 45 of {@tg} {_p} to white glass pane with lore "&b%{_aa}%&7/&b%{_a}% &e%100 * {_aa} / {_a}%%%" named "&bDisabling all enabled scripts..."
              wait 1 tick
            execute {_p} command "skript:skript disable %loop-value%"
        set {_time} to difference between {_time} and now
        send "{@prefix} &cDisabled &aall enabled scripts &7(%{_time}%&7)" to {_p}
        play sound "entity.experience_orb.pickup" for {_p}
      {@sm}_gui({_p})
    else if {_s} = 47:
      if line 1 of lore of slot 46 of {@tg} {_p} is "&c[&6&l!&c] &7&lAre you sure? &c[&6&l!&c]":
        play sound "block.stone_button.click_on" for {_p}
        send "{@prefix} &cReloading all scripts.." to {_p}
        set {_time} to now
        if {@tg2} {_p} is not true:
          execute console command "skript reload scripts"
        else:
          execute {_p} command "skript reload scripts"
        set {_time} to difference between {_time} and now
        send "{@prefix} &aAll scripts reloaded! &7(%{_time}%&7)" to {_p}
        execute {_p} command "skript:scriptmanager"
        play sound "entity.experience_orb.pickup" for {_p}
      else:
        set lore of slot 46 of {@tg} {_p} to "&c[&6&l!&c] &7&lAre you sure? &c[&6&l!&c]"
    else if {_s} = 53:
      if line 1 of lore of slot 52 of {@tg} {_p} is "&c[&6&l!&c] &7&lAre you sure? &c[&6&l!&c]":
        play sound "block.stone_button.click_on" for {_p}
        if {@tg2} {_p} is not true:
          disable script script
        else:
          execute {_p} command "skript:skript reload %script%"
        send "{@prefix} &7Disabled {@full name}&7, To enable again: /skript enable %script%" to {_p}
        play sound "entity.experience_orb.pickup" for {_p}
      else:
        set lore of slot 52 of {@tg} {_p} to "&c[&6&l!&c] &7&lAre you sure? &c[&6&l!&c]"
    else if {_s} = 52:
      if line 1 of lore of slot 51 of {@tg} {_p} is "&c[&6&l!&c] &7&lAre you sure? &c[&6&l!&c]":
        play sound "block.stone_button.click_on" for {_p}
        send "{@prefix} &bReloading {@full name}&7... &7 Will auto reopen gui for you after reload" to {_p}
        if {@tg2} {_p} is not true:
          reload script script
        else:
          execute {_p} command "skript:skript reload %script%"
        execute {_p} command "skript:scriptmanager"
        play sound "entity.experience_orb.pickup" for {_p}
      else:
        set lore of slot 51 of {@tg} {_p} to "&c[&6&l!&c] &7&lAre you sure? &c[&6&l!&c]"
    else if {_s} = 54:
      close {@i} for {_p}
    else if {_s} = 49:
      if {@tg2} {_p} is true:
        delete {@tg2} {_p}
        play sound "block.piston.extend" for {_p}
      else:
        set {@tg2} {_p} to true
        play sound "block.piston.contract" for {_p}
      {@sm}_gui({_p})
    else if {_s} = 50:
      {@sm}_gui({_p})
      play sound "ui.toast.in" for {_p}
    else if {_s} = 42:
      if {{@sm}::page::%{_p}%} * 36 + 1 <= amount of {{@sm}::script::%{_p}%::*}:
        add 1 to {{@sm}::page::%{_p}%}
        {@sm}_gui({_p})
        play sound "ui.toast.in" for {_p}
    else if {_s} = 40:
      if {{@sm}::page::%{_p}%} > 1:
        remove 1 from {{@sm}::page::%{_p}%}
        {@sm}_gui({_p})
        play sound "ui.toast.in" for {_p}
on {@i} click:
  if {@tg} player is set:
    cancel event
    if event-{@i} is {@tg} player:
      if click type is left mouse button:
        set {_click} to 1
      else if click type is right mouse button:
        set {_click} to 2
      else if click type is middle mouse button:
        set {_click} to 3
      else:
        set {_click} to 1
      wait 1 tick
      {@sm}_gui_click(player, index of event-slot + 1, "%amount of {{@sm}::script::%player%::*}%" parsed as number, {_click})
on {@i} close:
  if event-{@i} is {@tg} player:
    delete {@tg} player
    delete {{@sm}::script::%player%::*}
    delete {{@sm}::page::%player%}
    delete {@tg2} player
    play sound "ui.toast.out" for player