HyperScript
Docs

← All user-made scripts

Admin Panel

by SoloHandCoder HyperScript Team

Manage Players, Scripts and even your server! /admin To use!

# ==============================================================
#  AdminPanel.hs - an admin menu: players, announcements, server
# ==============================================================
#
# Requires: 1.7.70
# Tags: admin, moderation, gui, menu
#
# /admin    open the panel
#
# Players       every online player as a head. Click one for:
#               go to them, bring them here, heal, feed, game
#               mode, freeze, clear inventory, kill, kick, ban,
#               ban for a day, and a page of harmless trolls.
# Announce      a chat message, a title, an action bar or a boss
#               bar to everybody.
# Server        day and night, weather, heal and feed everybody,
#               clear the chat, slow mode.
# Scripts       every script as a button: green is loaded, red
#               did not load (with the mistake under its name),
#               grey is switched off. Click to switch it.
#
# Notes
#  - Whoever has the permission in "permission" below can use
#    all of it. Operators have it anyway.
#  - A reason, or the words of an announcement, are typed into
#    an anvil that opens by itself, with the question on top and
#    an empty box: type, then take the item out on the right.
#    Closing the anvil calls it off. On a Spigot server the
#    question is asked in chat instead.
#  - Kicks and bans are told to everybody with the permission.

options:
    permission: "adminpanel.use"
    prefix: "&8[&cAdmin&8] "

# Tells everybody who may use the panel what somebody did with it.
local function admin_log({_text}):
    loop all players:
        if loop-player has permission "{@permission}":
            send "{@prefix}&7%{_text}%" to loop-player

# ---- the first page ------------------------------------------

local function admin_main():
    set {_me} to player.name
    open gui with title "&8Admin panel" with 3 rows for player:
        border with "black_stained_glass_pane"
        slot 11 is "player_head" owned by {_me} named "&bPlayers" lore "&7Kick, ban, teleport, troll|&f%server.online_players% &7online":
            admin_players()
        slot 13 is "bell" named "&6Announce" lore "&7Chat, title, action bar, boss bar":
            admin_announce()
        slot 15 is "command_block" named "&eServer" lore "&7Time, weather, chat":
            admin_server()
        slot 17 is "writable_book" named "&aScripts" lore "&7Switch scripts on and off|&7and see which did not load":
            admin_scripts()
        slot 23 is "barrier" named "&cClose":
            close gui

# ---- the scripts ---------------------------------------------------
# Green is loaded, red did not load (the mistake is under its name),
# grey is switched off. Click one to switch it off or on.

local function admin_scripts():
    set {_self} to this script
    open gui with title "&8Scripts" with 6 rows for player:
        set {_files} to []
        for each {_file} in enabled scripts:
            append {_file} to {_files}
        for each {_file} in disabled scripts:
            append {_file} to {_files}
        set {_slot} to 0
        for each {_file} in page (gui page) of {_files} with 45 per page:
            add 1 to {_slot}
            set {_error} to error of script {_file}
            if script {_file} is disabled:
                slot {_slot} is "gray_dye" named "&7%{_file}%" lore "&7Switched off|&aClick to switch it on":
                    enable script {_file}
                    admin_log("%player.name% switched %{_file}% on")
                    wait 1 second
                    admin_scripts()
            else if {_file} is {_self}:
                slot {_slot} is "nether_star" named "&b%{_file}%" lore "&7This panel|&7It cannot switch itself off"
            else if {_error} is set:
                slot {_slot} is "red_dye" named "&c%{_file}%" lore "&cDid not load:|&f%{_error}%|&7Click to switch it off":
                    disable script {_file}
                    admin_log("%player.name% switched %{_file}% off")
                    wait 1 second
                    admin_scripts()
            else:
                slot {_slot} is "lime_dye" named "&a%{_file}%" lore "&aLoaded, no mistakes|&7Click to switch it off":
                    disable script {_file}
                    admin_log("%player.name% switched %{_file}% off")
                    wait 1 second
                    admin_scripts()
        if gui page > 1:
            slot 46 is "arrow" named "&ePrevious page":
                previous page
        slot 49 is "redstone" named "&cRead them all again" lore "&7After changing a file":
            execute console command "hyperscript reload"
            wait 1 second
            admin_scripts()
        slot 50 is "oak_door" named "&7Back":
            admin_main()
        if gui page < pages of {_files} with 45 per page:
            slot 54 is "arrow" named "&eNext page":
                next page

# ---- every online player, as a head --------------------------

local function admin_players():
    open gui with title "&8Players" with 6 rows for player:
        set {_names} to []
        loop all players:
            append loop-player to {_names}
        set {_slot} to 0
        for each {_name} in page (gui page) of {_names} with 45 per page:
            add 1 to {_slot}
            slot {_slot} is "player_head" owned by {_name} named "&b%{_name}%" lore "&7Click to manage":
                admin_player({_name})
        if gui page > 1:
            slot 46 is "arrow" named "&ePrevious page":
                previous page
        slot 50 is "oak_door" named "&7Back":
            admin_main()
        if gui page < pages of {_names} with 45 per page:
            slot 54 is "arrow" named "&eNext page":
                next page

# ---- one player ------------------------------------------------

local function admin_player({_target}):
    if {_target} is not online:
        send "{@prefix}&c%{_target}% has left."
        admin_players()
        stop
    set {_mode} to gamemode of {_target}
    set {_health} to round(health of {_target})
    open gui with title "&8Manage %{_target}%" with 5 rows for player:
        border with "black_stained_glass_pane"
        slot 5 is "player_head" owned by {_target} named "&b%{_target}%" lore "&7Health: &f%{_health}%&7/20|&7Game mode: &f%{_mode}%"
        slot 11 is "ender_pearl" named "&aGo to them":
            teleport player to location of {_target}
            close gui
        slot 12 is "ender_eye" named "&aBring them here":
            teleport {_target} to player's location
            send "{@prefix}&7You were brought to &f%player.name%&7." to {_target}
            close gui
        slot 13 is "golden_apple" named "&dHeal":
            heal {_target}
            send "{@prefix}&7Healed &f%{_target}%&7."
        slot 14 is "cooked_beef" named "&dFeed":
            feed {_target}
            send "{@prefix}&7Fed &f%{_target}%&7."
        slot 15 is "grass_block" named "&eGame mode" lore "&7Now: &f%{_mode}%|&7Click for the next one":
            if {_mode} is "survival":
                set gamemode of {_target} to creative
            else if {_mode} is "creative":
                set gamemode of {_target} to spectator
            else:
                set gamemode of {_target} to survival
            admin_player({_target})
        slot 16 is "packed_ice" named "&bFreeze or unfreeze":
            if {_target} is frozen:
                unfreeze {_target}
                send "{@prefix}&f%{_target}% &7can move again."
            else:
                freeze {_target}
                send "{@prefix}&f%{_target}% &7is frozen."
        slot 17 is "lava_bucket" named "&cClear inventory":
            clear inventory of {_target}
            admin_log("%player.name% cleared the inventory of %{_target}%")
        slot 29 is "iron_sword" named "&cKill":
            kill {_target}
            admin_log("%player.name% killed %{_target}%")
        slot 30 is "leather_boots" named "&cKick" lore "&7Asks for a reason":
            ask player "Reason for the kick" with anvil into {_reason}
            if {_reason} is not set or {_reason} is "":
                send "{@prefix}&7Called off."
                stop
            kick {_target} because "&cKicked: &f%{_reason}%"
            admin_log("%player.name% kicked %{_target}%: %{_reason}%")
        slot 31 is "clock" named "&cBan for a day" lore "&7Asks for a reason":
            ask player "Reason for the ban" with anvil into {_reason}
            if {_reason} is not set or {_reason} is "":
                send "{@prefix}&7Called off."
                stop
            ban {_target} for 1 day because "&cBanned for a day: &f%{_reason}%"
            admin_log("%player.name% banned %{_target}% for a day: %{_reason}%")
        slot 32 is "barrier" named "&4Ban for good" lore "&7Asks for a reason":
            ask player "Reason for the ban" with anvil into {_reason}
            if {_reason} is not set or {_reason} is "":
                send "{@prefix}&7Called off."
                stop
            ban {_target} because "&cBanned: &f%{_reason}%"
            admin_log("%player.name% banned %{_target}%: %{_reason}%")
        slot 33 is "paper" named "&eSend them a message" lore "&7Asks for the words":
            ask player "Message for %{_target}%" with anvil into {_words}
            if {_words} is not set or {_words} is "":
                stop
            send "{@prefix}&f%{_words}%" to {_target}
            send title "&c&lAdmin" with subtitle "&f%{_words}%" to {_target}
            send "{@prefix}&7Sent to &f%{_target}%&7."
        slot 35 is "tnt" named "&6Troll" lore "&7Harmless, mostly":
            admin_troll({_target})
        slot 41 is "oak_door" named "&7Back":
            admin_players()

# ---- trolls ----------------------------------------------------

local function admin_troll({_target}):
    if {_target} is not online:
        admin_players()
        stop
    open gui with title "&8Troll %{_target}%" with 3 rows for player:
        border with "black_stained_glass_pane"
        slot 11 is "firework_rocket" named "&dLaunch" lore "&7Into the air, with a soft landing":
            launch {_target} upward at speed 3 without fall damage
        slot 12 is "trident" named "&bLightning" lore "&7Looks real, hurts nobody":
            strike fake lightning at location of {_target}
        slot 13 is "flint_and_steel" named "&6Set on fire" lore "&7For three seconds":
            ignite {_target} for 3 seconds
        slot 14 is "ink_sac" named "&8Lights out" lore "&7Blind for ten seconds":
            apply blindness to {_target} for 10 seconds
        slot 15 is "pufferfish" named "&aDizzy" lore "&7Nausea for fifteen seconds":
            apply nausea 2 to {_target} for 15 seconds
        slot 16 is "feather" named "&fFloat" lore "&7Up they go, for five seconds":
            apply levitation 2 to {_target} for 5 seconds
        slot 17 is "creeper_head" named "&2Creeper behind you" lore "&7Only the sound":
            play sound "entity.creeper.primed" for {_target}
        slot 20 is "name_tag" named "&eFake operator" lore "&7Tells them they were made an operator":
            send "&7&o[Server: Made %{_target}% a server operator]" to {_target}
        slot 21 is "soul_sand" named "&7Slow" lore "&7Slowness for fifteen seconds":
            apply slowness 4 to {_target} for 15 seconds
        slot 22 is "piston" named "&cShove" lore "&7Backwards":
            push {_target} backward with force 2
        slot 23 is "oak_door" named "&7Back":
            admin_player({_target})

# ---- announcements -----------------------------------------------

local function admin_announce():
    open gui with title "&8Announce" with 3 rows for player:
        border with "black_stained_glass_pane"
        slot 11 is "paper" named "&fChat message" lore "&7To everybody, in chat":
            ask player "Chat message" with anvil into {_words}
            if {_words} is not set or {_words} is "":
                stop
            broadcast "&8[&6Announcement&8] &f%{_words}%"
            play sound "block.note_block.pling" for all players
        slot 13 is "oak_sign" named "&6Title" lore "&7Large, in the middle of the screen|&7Asks for a title, then for a line under it":
            ask player "Title" with anvil into {_title}
            if {_title} is not set or {_title} is "":
                stop
            ask player "Line under it (or -)" with anvil into {_under}
            if {_under} is not set or {_under} is "-":
                set {_under} to ""
            send title "&6%{_title}%" with subtitle "&f%{_under}%" to all players
            play sound "entity.player.levelup" for all players
            send "{@prefix}&7Title sent."
        slot 15 is "name_tag" named "&eAction bar" lore "&7Small, above the hotbar":
            ask player "Action bar" with anvil into {_words}
            if {_words} is not set or {_words} is "":
                stop
            send action bar "&e%{_words}%" to all players
            send "{@prefix}&7Action bar sent."
        slot 17 is "dragon_head" named "&dBoss bar" lore "&7Across the top, for thirty seconds":
            ask player "Boss bar" with anvil into {_words}
            if {_words} is not set or {_words} is "":
                stop
            create bossbar "admin" titled "&d%{_words}%" with color purple with progress 100 for all players for 30 seconds
            send "{@prefix}&7Boss bar shown for thirty seconds."
        slot 23 is "oak_door" named "&7Back":
            admin_main()

# ---- the server --------------------------------------------------

local function admin_server():
    open gui with title "&8Server" with 3 rows for player:
        border with "black_stained_glass_pane"
        slot 11 is "sunflower" named "&eDay":
            set time in world "%player.world%" to 1000
            send "{@prefix}&7It is day."
        slot 12 is "black_bed" named "&9Night":
            set time in world "%player.world%" to 13000
            send "{@prefix}&7It is night."
        slot 13 is "glass" named "&bClear weather":
            set weather in world "%player.world%" to clear
            send "{@prefix}&7The sky is clear."
        slot 14 is "water_bucket" named "&3Rain":
            set weather in world "%player.world%" to rain
            send "{@prefix}&7It rains."
        slot 15 is "golden_apple" named "&dHeal and feed everybody":
            loop all players:
                heal loop-player
                feed loop-player
            broadcast "{@prefix}&dEverybody was healed."
        slot 16 is "white_wool" named "&fClear the chat":
            loop 100 times:
                broadcast " "
            broadcast "{@prefix}&7The chat was cleared by &f%player.name%&7."
        slot 17 is "cobweb" named "&7Slow mode" lore "&7Five seconds between messages|&7Click again to end it":
            if {adminpanel.slow} is true:
                set chat slow mode off
                set {adminpanel.slow} to false
                broadcast "{@prefix}&7Slow mode is off."
            else:
                set chat slow mode to 5 seconds
                set {adminpanel.slow} to true
                broadcast "{@prefix}&7Slow mode is on: one message every five seconds."
        slot 23 is "oak_door" named "&7Back":
            admin_main()

command /admin:
    description: Open the admin panel
    permission: "{@permission}"
    players only:
    trigger:
        admin_main()