SetupServer.hs
/setupserver install the scripts chosen below and give them your server's name and address /updateserver fetch the newest version of every script the setup installed
by HyperScript TeamHyperScript 1.7.38+2 commands221 linessetupinstallserver templateadmin
Put the file in plugins/HyperScript/scripts and it is live. Or type /hyperscript install setupserver on your server.
# ==============================================================
# SetupServer.hs - sets a new server up with one command
# ==============================================================
#
# Requires: 1.7.38
# Author: HyperScript Team
# Tags: setup, install, server template, admin
#
# /setupserver install the scripts chosen below and give
# them your server's name and address
# /updateserver fetch the newest version of every script the
# setup installed
#
# Run it once on a new server. It asks whether the scripts that
# are there should go first, fetches the ones chosen below from
# the HyperScript website into a folder of their own,
# scripts/ServerSetup, asks you in chat what your server is
# called and what its address is, and writes both into the
# options of what it installed. On the way it asks whether you
# want the extras as well: quests with a /quests menu.
#
# Notes
# - What is installed is chosen in "options:" below. Put false
# after one to leave it out.
# - It always asks first whether every other script should be
# taken out. Say n and nothing is taken out: the new scripts
# are installed beside what you have. Scripts that are taken
# out are not destroyed: they are moved to plugins/
# HyperScript/removed-scripts, from where they can be put
# back.
# - Extras are not installed unless you say y when it asks:
# Quests.hs, eleven quests and a /quests menu. Anything but
# y leaves it out, and it can be added later by running
# /setupserver again or with /hs install Quests. It needs
# HyperScript 1.7.64 or newer. Put false after "AskQuests"
# and the question is not asked at all.
# - The answers you type are not shown to other players.
# - /setupserver is for server operators only, and the server
# needs to reach the HyperScript website.
# - It can be run again: a script that is installed already is
# left as it is and only given the new name and address.
# - /updateserver looks at every script in the setup's folder
# and fetches the ones the website has a newer text of. What
# you set in their "options:" stays as you set it. Anything
# else you changed in a file is not carried over: the file as
# it was is kept beside the new one, as <name>.hs.old.
# - The scripts go into scripts/ServerSetup, so they stay apart
# from your own. "folder" below names it. One of them that
# is in the scripts folder itself from an earlier setup is
# taken out, so that it does not run twice.
options:
# The folder inside the scripts folder that the scripts are put in.
folder: "ServerSetup"
InstallSidebar: true # The sidebar that shows people stats about the server on the right of the screen
InstallTablist: true # A header, a footer and ranks for the list players see when they hold Tab
InstallRanks: true # Ranks you give with /rank set, which the sidebar, the tab list and chat all show
InstallChatPrefixes: true # Everybody's rank in front of what they say in chat
InstallJoinMessages: true # Random join and leave messages, and a welcome for whoever joins
InstallDeathMessages: true # Death messages that do not take it seriously, a different one each time
InstallWorldsManager: true # /world to make, visit and remove worlds
# Extras: /setupserver asks about each of these before it installs anything. false never asks.
AskQuests: true # Eleven quests and a /quests menu that shows how far everybody is
command /setupserver:
description: Set this server up with a sidebar, a tab list, ranks, chat prefixes, join and death messages, /world, and quests if you want them
permission: op
players only: true
trigger:
send "&3[Setup] &2Setting up the server..."
# What can be installed: what /hs install is told, and the file it becomes.
set {_ids} to []
set {_wanted} to []
set {_plain} to []
if {@InstallSidebar} is true:
append "Sidebar" to {_ids}
append "{@folder}/Sidebar.hs" to {_wanted}
append "Sidebar.hs" to {_plain}
if {@InstallTablist} is true:
append "TabList" to {_ids}
append "{@folder}/TabList.hs" to {_wanted}
append "TabList.hs" to {_plain}
if {@InstallRanks} is true:
append "Ranks" to {_ids}
append "{@folder}/Ranks.hs" to {_wanted}
append "Ranks.hs" to {_plain}
if {@InstallChatPrefixes} is true:
append "ChatPrefixes" to {_ids}
append "{@folder}/ChatPrefixes.hs" to {_wanted}
append "ChatPrefixes.hs" to {_plain}
if {@InstallJoinMessages} is true:
append "JoinMessages" to {_ids}
append "{@folder}/JoinMessages.hs" to {_wanted}
append "JoinMessages.hs" to {_plain}
if {@InstallDeathMessages} is true:
append "DeathMessages" to {_ids}
append "{@folder}/DeathMessages.hs" to {_wanted}
append "DeathMessages.hs" to {_plain}
if {@InstallWorldsManager} is true:
append "WorldsManager" to {_ids}
append "{@folder}/WorldsManager.hs" to {_wanted}
append "WorldsManager.hs" to {_plain}
set {_needed} to size of {_ids}
set {_done} to 0
ask player "&3[Setup] &2Should all other scripts be taken out first? &7(y/n, n keeps them)" into {_confirmation} for at most 60 seconds
if {_confirmation} is not set:
send "&3[Setup] &cTimed out: the time to reply ran out."
stop
if {_confirmation} == "y":
send "&3[Setup] &2Yes selected. Taking out the other scripts..."
set {_removed} to 0
for each {_script} in all scripts:
if {_script} is not this script:
delete script {_script}
add 1 to {_removed}
send "&3[Setup] &2Took out %{_removed}% scripts. &7They are kept in plugins/HyperScript/removed-scripts."
else if {_confirmation} == "n":
send "&3[Setup] &2No selected. Your scripts stay; the new ones are installed beside them."
else:
send "&3[Setup] &cThat was neither: say y or n."
stop
# The extras: asked about one by one, and left out unless the answer is y.
set {_quests} to false
if {@AskQuests} is true:
ask player "&3[Setup] &2Install the extra &fQuests&2 as well? &7(y/n: eleven quests and a /quests menu)" into {_answer} for at most 60 seconds
if {_answer} == "y":
set {_quests} to true
append "Quests" to {_ids}
append "{@folder}/Quests.hs" to {_wanted}
append "Quests.hs" to {_plain}
send "&3[Setup] &2Yes selected. Quests will be installed."
else if {_answer} is not set:
send "&3[Setup] &7No answer, so Quests is left out."
else:
send "&3[Setup] &2Quests is left out. &7/hs install Quests adds it later."
set {_needed} to size of {_ids}
if {_needed} == 0:
send "&3[Setup] &cNothing is chosen in the options of this script, so there is nothing to install."
stop
# One that an earlier setup left in the scripts folder itself would run beside the new one.
for each {_file} in {_plain}:
if script {_file} exists:
delete script {_file}
send "&3[Setup] &7%{_file}% was in the scripts folder itself and was taken out; it now lives in {@folder}."
send "&3[Setup] &2Fetching %{_needed}% scripts into scripts/{@folder}..."
# All of them are asked for at once; this waits until they are there, ten seconds at most.
for each {_id} in {_ids}:
execute console command "hs install %{_id}% {@folder}"
loop 20 times:
set {_done} to 0
for each {_file} in {_wanted}:
if script {_file} exists:
add 1 to {_done}
if {_done} >= {_needed}:
break
wait 10 ticks
send "&3[Setup] &2Fetched %{_done}%/%{_needed}%. Reloading..."
execute console command "hs reload"
wait 1 second
# Which of them are there now: one that could not be fetched is said so, not passed over.
set {_installed} to []
for each {_file} in {_wanted}:
if script {_file} exists:
append {_file} to {_installed}
else:
send "&3[Setup] &c%{_file}% is not there. &7Is the website reachable? Try /hs install again later."
if size of {_installed} == 0:
send "&3[Setup] &cNothing was installed, so there is nothing to set up."
stop
ask player "&3[Setup] &2What is your server called?" into {_servername} for at most 60 seconds
if {_servername} is not set:
send "&3[Setup] &cTimed out. &7The scripts are installed; run /setupserver again to name the server."
stop
ask player "&3[Setup] &2What is its address? &7(say none if it has none yet)" into {_address} for at most 60 seconds
if {_address} is not set:
set {_address} to "none"
# Every script that was installed and has a name or an address among its options gets yours.
for each {_file} in {_installed}:
if option "name" of script {_file} is set:
set option "name" of script {_file} to {_servername}
if {_address} is not "none":
if option "address" of script {_file} is set:
set option "address" of script {_file} to {_address}
execute console command "hs reload"
send "&3[Setup] &2Setup finished! &7%size of {_installed}% scripts are running for &f%{_servername}%&7."
if {@InstallRanks} is true:
send "&3[Setup] &7Give yourself a rank with &f/rank set %player.name% owner&7."
if {_quests} is true:
if script "{@folder}/Quests.hs" exists:
send "&3[Setup] &7Players take quests from the menu of &f/quests&7."
command /updateserver:
description: Fetch the newest version of every script the setup installed
permission: op
trigger:
# Everything the setup can install; the ones that are in its folder are the ones to update.
set {_ids} to []
for each {_id} in ["Sidebar", "TabList", "Ranks", "ChatPrefixes", "JoinMessages", "DeathMessages", "WorldsManager", "Quests"]:
if script "{@folder}/%{_id}%.hs" exists:
append {_id} to {_ids}
set {_needed} to size of {_ids}
if {_needed} == 0:
send "&3[Setup] &cThere is nothing in scripts/{@folder} to update. &7Run /setupserver first."
stop
send "&3[Setup] &2Asking the website about %{_needed}% scripts..."
# Installing a script that is there fetches a newer one, and keeps what its options are set to.
for each {_id} in {_ids}:
execute console command "hs install %{_id}% {@folder}"
wait 5 seconds
execute console command "hs reload"
send "&3[Setup] &2Done. &7The console says which scripts were newer. Your options were kept, and the files as they were are beside the new ones as <name>.hs.old."