Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options:
- command: display # What do you want the command to be. (/display this is the command guys)
- prefix: &b%player%'s &8» # The prefix of the display. (Test's Item Display: stone (1x) » yay) (":" comes up with an error, I've used "›")
- perm: display.use # The permission required to use the command.
- permmsg: &cYou do not have access to this command. # If you dont have the required permission.
- cooldown: 10 seconds # The cooldown that players need to wait till they can use it again.
- noitem: &cYou are not holding an item. # The message recieved if youre holding air.
- namecolour: &7 # The default name colour of the item. If the item is named, the name will override the colour.
- amountcolour: &7 # The colour that "(1x)" will be displayed as.
- split: &3&l» # The split between "stone (1x)" and the message.
- chatcolour: &f # The colour of the message displayed given in the command. (/display this is the text here)
- command /{@command} [<text>]:
- permission: {@perm}
- permission message: {@permmsg}
- trigger:
- set {_wait} to difference between now and {display.%player's uuid%}
- if {_wait} is less than {@cooldown}:
- send "&cPlease wait %difference between {@cooldown} and {_wait}%."
- stop
- set {display.%player's uuid%} to now
- if player's held item is air:
- send "{@noitem}"
- stop
- if arg-1 is not set:
- set {_text} to "&7"
- if arg-1 is set:
- set {_text} to arg-1
- set {_name} to held item's name
- if {_name} is not set:
- set {_name} to "{@namecolour}%player's tool's type%"
- set {_amount} to amount of player's held item in player's inventory
- set {_protection} to "%level of protection of player's tool%" parsed as a number
- if {_protection} is greater than or equal to 1:
- set {_enchants} to "&7Protection %{_protection}%"
- set {_fprotection} to "%level of fire protection of player's tool%" parsed as a number
- if {_fprotection} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Fire Protection %{_fprotection}%"
- else:
- set {_enchants} to "&7Fire Protection %{_fprotection}%"
- set {_featherfalling} to "%level of feather falling of player's tool%" parsed as a number
- if {_featherfalling} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Feather Falling %{_featherfalling}%"
- else:
- set {_enchants} to "&7Feather Falling %{_featherfalling}%"
- set {_bprotection} to "%level of blast protection of player's tool%" parsed as a number
- if {_bprotection} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Blast Protection %{_bprotection}%"
- else:
- set {_enchants} to "&7Blast Protection %{_bprotection}%"
- set {_pprotection} to "%level of projectile protection of player's tool%" parsed as a number
- if {_pprotection} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Projectile Protection %{_pprotection}%"
- else:
- set {_enchants} to "&7Projectile Protection %{_pprotection}%"
- set {_respiration} to "%level of respiration of player's tool%" parsed as a number
- if {_respiration} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Respiration %{_respiration}%"
- else:
- set {_enchants} to "&7Respiration %{_respiration}%"
- set {_aquaaffinity} to "%level of aqua affinity of player's tool%" parsed as a number
- if {_aquaaffinity} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Aqua Affinity %{_aquaaffinity}%"
- else:
- set {_enchants} to "&7Aqua Affinity %{_aquaaffinity}%"
- set {_thorns} to "%level of thorns of player's tool%" parsed as a number
- if {_thorns} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Thorns %{_thorns}%"
- else:
- set {_enchants} to "&7Thorns %{_thorns}%"
- set {_depthstrider} to "%level of depth strider of player's tool%" parsed as a number
- if {_depthstrider} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Depth Strider %{_depthstrider}%"
- else:
- set {_enchants} to "&7Depth Strider %{_depthstrider}%"
- set {_frostwalker} to "%level of frost walker of player's tool%" parsed as a number
- if {_frostwalker} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Frost Walker %{_frostwalker}%"
- else:
- set {_enchants} to "&7Frost Walker %{_frostwalker}%"
- set {_sharpness} to "%level of sharpness of player's tool%" parsed as a number
- if {_sharpness} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Sharpness %{_sharpness}%"
- else:
- set {_enchants} to "&7Sharpness %{_sharpness}%"
- set {_smite} to "%level of smite of player's tool%" parsed as a number
- if {_smite} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Smite %{_smite}%"
- else:
- set {_enchants} to "&7Smite %{_smite}%"
- set {_boa} to "%level of bane of arthropods of player's tool%" parsed as a number
- if {_boa} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Bane Oof Arthropods %{_boa}%"
- else:
- set {_enchants} to "&7Bane of Arthropods %{_bca}%"
- set {_knockback} to "%level of knockback of player's tool%" parsed as a number
- if {_knockback} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Knockback %{_knockback}%"
- else:
- set {_enchants} to "&7Knockback %{_knockback}%"
- set {_fireaspect} to "%level of fire aspect of player's tool%" parsed as a number
- if {_fireaspect} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Fire Aspect %{_fireaspect}%"
- else:
- set {_enchants} to "&7Fire Aspect %{_fireaspect}%"
- set {_looting} to "%level of looting of player's tool%" parsed as a number
- if {_looting} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Looting %{_looting}%"
- else:
- set {_enchants} to "&7Looting %{_looting}%"
- set {_se} to "%level of sweeping edge of player's tool%" parsed as a number
- if {_se} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Sweeping Edge %{_se}%"
- else:
- set {_enchants} to "&7Sweeping Edge %{_se}%"
- set {_unbreaking} to "%level of unbreaking of player's tool%" parsed as a number
- if {_unbreaking} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Unbreaking %{_unbreaking}%"
- else:
- set {_enchants} to "&7Unbreaking %{_unbreaking}%"
- set {_power} to "%level of power of player's tool%" parsed as a number
- if {_power} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Power %{_power}%"
- else:
- set {_enchants} to "&7Power %{_power}%"
- set {_punch} to "%level of punch of player's tool%" parsed as a number
- if {_punch} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Punch %{_punch}%"
- else:
- set {_enchants} to "&7Punch %{_punch}%"
- set {_flame} to "%level of flame of player's tool%" parsed as a number
- if {_flame} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Flame %{_flame}%"
- else:
- set {_enchants} to "&7Flame %{_flame}%"
- set {_infinity} to "%level of infinity of player's tool%" parsed as a number
- if {_infinity} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Infinty %{_infinity}%"
- else:
- set {_enchants} to "&7Infinity %{_infinity}%"
- set {_mending} to "%level of mending of player's tool%" parsed as a number
- if {_mending} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Mending %{_mending}%"
- else:
- set {_enchants} to "&7Mending %{_mending}%"
- set {_efficiency} to "%level of efficiency of player's tool%" parsed as a number
- if {_efficiency} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Efficiency %{_efficiency}%"
- else:
- set {_enchants} to "&7Efficiency %{_efficiency}%"
- set {_silktouch} to "%level of silk touch of player's tool%" parsed as a number
- if {_silktouch} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Silk Touch %{_silktouch}%"
- else:
- set {_enchants} to "&7Silk Touch %{_silktouch}%"
- set {_fortune} to "%level of fortune of player's tool%" parsed as a number
- if {_fortune} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Fortune %{_fortune}%"
- else:
- set {_enchants} to "&7Fortune %{_fortune}%"
- set {_lots} to "%level of luck of the sea of player's tool%" parsed as a number
- if {_lots} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Lust of the Sea %{_lots}%"
- else:
- set {_enchants} to "&7Luck of the Sea %{_lots}%"
- set {_lure} to "%level of lure of player's tool%" parsed as a number
- if {_lure} is greater than or equal to 1:
- if {_enchants} is set:
- set {_enchants} to "%{_enchants}%%new line%&7Lure %{_lure}%"
- else:
- set {_enchants} to "&7Lure %{_lure}%"
- set {_lore1} to line 1 of lore of player's tool
- if {_lore1} is set:
- set {_lore2} to line 2 of lore of player's tool
- set {_lore} to "%{_lore1}%"
- if {_lore2} is set:
- set {_lore3} to line 3 of lore of player's tool
- set {_lore} to "%{_lore}%%newline%%{_lore2}%"
- if {_lore3} is set:
- set {_lore4} to line 4 of lore of player's tool
- set {_lore} to "%{_lore}%%newline%%{_lore3}%"
- if {_lore4} is set:
- set {_lore5} to line 5 of lore of player's tool
- set {_lore} to "%{_lore}%%newline%%{_lore4}%"
- if {_lore5} is set:
- set {_lore6} to line 6 of lore of player's tool
- set {_lore} to "%{_lore}%%newline%%{_lore5}%"
- if {_lore6} is set:
- set {_lore7} to line 7 of lore of player's tool
- set {_lore} to "%{_lore}%%newline%%{_lore6}%"
- if {_lore7} is set:
- set {_lore8} to line 8 of lore of player's tool
- set {_lore} to "%{_lore}%%newline%%{_lore7}%"
- if {_lore8} is set:
- set {_lore} to "%{_lore}%%newline%%{_lore8}%"
- if {_enchants} is set:
- json("@a", "{@prefix} &7%{_name}%{@amountcolour} (%{_amount}%x) {@split} {@chatcolour}%{_text}%||ttp:&7%{_name}%%newline%&7%{_enchants}%%newline%%{_lore}%%newline%&8%player's tool's type%")
- stop
- else:
- json("@a", "{@prefix} &7%{_name}%{@amountcolour} (%{_amount}%x) {@split} {@chatcolour}%{_text}%||ttp:&7%{_name}%%newline%%{_lore}%%newline%&8%player's tool's type%")
- stop
- # json.sk by RezzedUp
- # ---
- # Version: 2.3
- # Requires: Skript 2.2
- # ---
- # Contributors:
- # - RezzedUp
- # - JKGamerxD
- #
- # General usage:
- #
- # ==> json(<recipient>, <text in json.sk format>, <OPTIONAL: whether or not to convert color codes>) :: returns nothing
- #
- # This function handles everything you could ever need regarding json.
- # Everything is automatic with it, you just need to provide the proper json.sk notatation and someone to recieve the message!
- #
- # --> example #1:
- # set {_to} to "@a"
- # set {_msg} to "&6Hello, this is a &ejson message&6!||ttp:&b&oSuper duper cool!||cmd:/msg RezzedUp You rock!!!!"
- # json({_to}, {_msg})
- #
- # --> example #2: v [NEW]
- # json("%player%", "&6:D||&5Neat", false)
- # ^
- # json.sk won't convert color codes if set to false.
- # If no value is set, it will convert color codes by default.
- #
- # ==> jsonFormat(<text in json.sk format>) :: returns text
- #
- # The purpose of this function is to return the formatted peice of json for your own use.
- # You can set up your own /tellraw with it
- #
- # --> example:
- # set {_toBeJson} to "I will return a json!||ttp:It's true!"
- # set {_jsonText} to jsonFormat({_toBeJson})
- # execute console command "/tellraw myUserName %{_jsonText}%"
- #
- #
- # JSON.SK NOTATION:
- # --> How to create json's!
- #
- # <always start with normal text>||<3 letter tag>:<text>||<regular text, new json cluster>
- # ^
- # "||" separates each segment.
- #
- # json.sk notation follows these rules:
- # 1. A cluster of json is formed at each regular text segment.
- # 2. There may be only one hoverable and one clickable event per cluster, otherwise things could get messy.
- # 3. Json effects are defined by a 3 letter tag at the very start of a segment, followed directly by a colon.
- # 4. "||" should only ever be used to separate each json segment.
- #
- # Json Effect Tags:
- # ttp:
- # --> Tooltip, hover event
- # cmd:
- # --> Run command, click event
- # sgt:
- # --> Suggest command, click event
- # url:
- # --> Open url, click event
- # ins:
- # --> Adds an "insertion", shift + click event
- # | For more information about the "insertion" attribute, visit
- # | http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/351959#insertion
- #
- # Example json.sk notation:
- #
- #
- # "Hello, this is a sample json.||ttp:&bI'm a tooltip for the first cluster.||There's no tag, so I've started a new cluster.||cmd:/ping"
- # |_______________________________________________________________________| |_______________________________________________________|
- # | |
- # JSON Cluster #1 JSON Cluster #2
- #
- #
- # The above json.sk notation purely as their segment types:
- #
- # "< regular text >||<ttp: tooltip >||< regular text, starting a new cluster >||<cmd:/command>"
- options:
- debug: false
- codes: 0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|k|l|m|n|o|r
- #
- # FUNCTION: Remove all `&` color codes.
- # -> Usage:
- # Geneal purpose function to remove color codes.
- # This function will not remove color codes already converted.
- #
- function removeColor(msg: text) :: text:
- set {_m::*} to {_msg} split at ""
- set {_color-codes} to "{@codes}"
- set {_colors::*} to {_color-codes} split at "|"
- set {_new} to ""
- loop {_m::*}:
- set {_char} to loop-value
- set {_prev} to the last character of {_new}
- if {_prev} is "&":
- loop {_colors::*}:
- if loop-value-2 is {_char}:
- set {_skip} to true
- if {_skip} is set:
- delete {_skip}
- else:
- set {_new} to "%{_new}%%{_char}%"
- return {_new}
- #
- # FUNCTION: Replace all `&` color codes with valid JSON color codes.
- # -> Usage:
- # Used by json functions to convert color codes.
- #
- function jsonColorize(msg: text, default-color: text = "&r") :: text:
- set {_m::*} to {_msg} split at ""
- set {_color-codes} to "{@codes}"
- set {_colors::*} to {_color-codes} split at "|"
- set {_color} to colored {_default-color}
- set {_code} to the first character of {_color}
- set {_new} to ""
- set {_skip} to 0
- loop amount of {_m::*} times:
- if {_skip} is more than or equal to 1:
- subtract 1 from {_skip}
- else:
- set {_char} to {_m::%loop-number%}
- set {_next} to {_m::%loop-number + 1%}
- if {@debug} is true:
- broadcast "&a[Character Check] &r%loop-number%: &7%{_char}% &r&onext: &8%{_next}% &r[%{_color}%color&r]"
- if {_char} is "&" or {_code}:
- if {@debug} is true:
- broadcast "&a[Color Check] &rFOUND: &o%{_char}%%{_next}% &7&m<--&7&o is it valid?"
- loop {_colors::*}:
- if loop-value-2 is {_next}:
- set {_color} to "%{_color}%%{_code}%%{_next}%"
- if {_next} is "r":
- set {_color} to {_default-color}
- set {_new} to "%{_new}%%{_color}%"
- set {_skip} to 1
- if {_skip} is less than or equal to 0:
- set {_new} to "%{_new}%%{_char}%"
- else if {_char} is " ":
- set {_new} to "%{_new}% %{_color}%"
- else:
- set {_new} to "%{_new}%%{_char}%"
- return {_new}
- #
- # FUNCTION: Replace all json-breaking characters.
- # -> Usage:
- # Used by json functions to avoid errors.
- # Allows usage of quotes and back-slashes in your json.
- #
- function jsonSanitize(msg: text) :: text:
- if {@debug} is true:
- broadcast "&a[Sanitize] &7&oSanitizing input..."
- set {_m::*} to {_msg} split at ""
- loop {_m::*}:
- if loop-value is """":
- set {_m::%loop-index%} to "\""" # """
- else if loop-value is "\":
- set {_m::%loop-index%} to "\\"
- set {_new} to join {_m::*} with ""
- return {_new}
- #
- # FUNCTION: Generate a new /tellraw json object from a json.sk-notation string.
- # -> Usage:
- # See the top of this skript, listed under general usage.
- #
- function jsonFormat(msg: text, color: boolean = true) :: text:
- set {_m::*} to {_msg} split at "||"
- set {_current} to 1
- loop {_m::*}:
- if {_clusters::%{_current}%} is not set:
- set {_clusters::%{_current}%} to ""
- if {_clusters::%{_current}%::text} is not set:
- set {_clusters::%{_current}%::text} to jsonSanitize(loop-value)
- else:
- set {_tag} to the first 4 characters of loop-value
- set {_value} to subtext of loop-value from characters 5 to the length of loop-value
- if {_tag} is "ttp:":
- set {_clusters::%{_current}%::tooltip} to jsonSanitize({_value})
- else if {_tag} is "cmd:":
- set {_clusters::%{_current}%::command} to jsonSanitize({_value})
- else if {_tag} is "sgt:":
- set {_clusters::%{_current}%::suggest} to jsonSanitize({_value})
- else if {_tag} is "url:":
- if {_value} doesn't contain "http://" or "https://":
- set {_value} to "http://%{_value}%"
- set {_clusters::%{_current}%::url} to jsonSanitize({_value})
- else if {_tag} is "ins:":
- set {_clusters::%{_current}%::insertion} to jsonSanitize({_value})
- else:
- add 1 to {_current}
- set {_clusters::%{_current}%::text} to jsonSanitize(loop-value)
- set {_clusters::%{_current}%} to ""
- if {@debug} is true:
- broadcast "&a[Tag Check] &3cluster:&b%{_current}% &8(&f&o%{_tag}%&8)"
- loop {_clusters::*}:
- if {@debug} is true:
- broadcast "&a[Cluster Check] &7&oCluster ##%loop-index% exists."
- set {_i} to loop-index
- set {_text} to {_clusters::%{_i}%::text}
- if {_color} is true:
- set {_text} to jsonColorize({_text})
- if {_json} is not set:
- set {_json} to "{""text"":""%{_text}%"""
- else:
- set {_json} to "%{_json}%,{""text"":""%{_text}%"""
- if {_clusters::%{_i}%::tooltip} is set:
- if {_color} is true:
- set {_tooltip} to jsonColorize({_clusters::%{_i}%::tooltip})
- else:
- set {_tooltip} to {_clusters::%{_i}%::tooltip}
- set {_json} to "%{_json}%,""hoverEvent"":{""action"": ""show_text"",""value"": ""%{_tooltip}%""}"
- if {_clusters::%{_i}%::insertion} is set:
- set {_json} to "%{_json}%,""insertion"":""%{_clusters::%{_i}%::insertion}%"",""obfuscated"":false"
- if {_clusters::%{_i}%::command} is set:
- set {_clickable} to "%{_json}%,""clickEvent"":{""action"":""run_command"",""value"":""%{_clusters::%{_i}%::command}%""}"
- if {_clusters::%{_i}%::suggest} is set:
- set {_clickable} to "%{_json}%,""clickEvent"":{""action"": ""suggest_command"",""value"": ""%{_clusters::%{_i}%::suggest}%""}"
- if {_clusters::%{_i}%::url} is set:
- set {_clickable} to "%{_json}%,""clickEvent"":{""action"": ""open_url"",""value"": ""%{_clusters::%{_i}%::url}%""}"
- if {_clickable} is set:
- set {_json} to "%{_clickable}%}"
- delete {_clickable}
- else:
- set {_json} to "%{_json}%}"
- return "{""text"":"""", ""extra"":[%{_json}%]}"
- #
- # FUNCTION: Send a json message with json.sk-notation.
- # -> Usage:
- # See the top of this skript, listed under general usage.
- #
- function json(to: text, msg: text, color: boolean = true):
- set {_msg} to jsonFormat({_msg}, {_color})
- execute console command "/tellraw %{_to}% %{_msg}%"
- if {@debug} is true:
- set {_player} to {_to} parsed as offline player
- if {_player} is online:
- send uncolored {_msg} to {_player}
- #
- # FUNCTION: Broadcast a json message with json.sk-notation.
- #
- function jsonBroadcast(msg: text, color: boolean = true):
- json("@a", {_msg}, {_color})
- #
- # COMMAND: A command to show that these json functions really work!
- # -> Usage:
- # /json recipient <text in json.sk notation>
- # It's just a test command, not in best practice to use this instead of the json function.
- #
- command /json [<text>] [<text>]:
- permission: "is.op"
- trigger:
- set {_to} to arg 1
- set {_msg} to arg 2
- if arg 1 is not set:
- set {_to} to "%player%"
- if arg 2 is not set:
- set {_msg} to "This is a json message! &c&oClick here for no reason!||ttp:&lReally, click your mouse!||cmd:/json @a %{_to}% clicked their mouse on json..."
- json({_to}, {_msg})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement