Hi
I wouldn't expect much here (mostly because I'll forget to update it), but I have a few useful snippets on my server that I use for tons of stuff and I figured you guys might find some use with these, especially cause I haven't contributed a ton content-wise since the new forums have been launched.
Name History Command
Requires: skUtilities
Description: A simple command to check the name change history of the given player. Works for both offline and online people, should work regardless of server version and such. Sorry if there's a better way to do this using skUtilities' JSON stuff, but it was my first time utilizing its URL functionality at all and I'm more comfortable parsing out stuff from strings (and it works the same and just as well regardless).
makeLook Function (force entity to look somewhere)
Requires: SkStuff
Description: Makes the given entity look at the given location (which of course can be another entity or a block or whatever you want). Works as you'd expect. And before you ask, yes, I tried removing the SkStuff dependency by just generating a location with the new yaw and pitch and teleporting the entity to it, but it doesn't work (don't ask me why). Also, if it "doesn't work sometimes", it's more likely that the entity just happened to decide to look somewhere else randomly right as/after the function ran, which is uncontrollable unless you use SkStuff to remove the 'look around randomly' pathfinder goal.
setCooldown Function (sets a visual cooldown on an item for a player)
Requires: MundoSK (you NEED the latest beta from GitHub for it to work)
Description: Sends a visual cooldown to the given player for a certain item type. This is displayed as an overlay that covers up all instances of the item type in the player's inventory, which slides downwards over the duration. Note that this does NOT actually do anything on its own or stop the client from using items -- it's just a visual thing that's useful for properly displaying item cooldowns to players. Nice for activated abilities.
Will add more as I decide they're appropriate or remember to.
I wouldn't expect much here (mostly because I'll forget to update it), but I have a few useful snippets on my server that I use for tons of stuff and I figured you guys might find some use with these, especially cause I haven't contributed a ton content-wise since the new forums have been launched.
Name History Command
Requires: skUtilities
Description: A simple command to check the name change history of the given player. Works for both offline and online people, should work regardless of server version and such. Sorry if there's a better way to do this using skUtilities' JSON stuff, but it was my first time utilizing its URL functionality at all and I'm more comfortable parsing out stuff from strings (and it works the same and just as well regardless).
code_language.skript:
command /whowas <offline player>:
aliases: namehistory
trigger:
set {_uuid} to "%offline player-argument's UUID%"
replace all "-" in {_uuid} with ""
set {_results::*} to contents from url "https://api.mojang.com/user/profiles/%{_uuid}%/names"
replace all """" in {_results::1} with ""
set {_results::*} to {_results::1} split at "},{"
send "" to the command sender
send "&6&l%offline player-argument%'s Name History:" to the command sender
loop {_results::*}:
# Ensure this value even contains the 'name' tag, otherwise it's just junk left over from the split
"%loop-value%" contains "name"
# If there's no 'changedToAt' in the looped value, it's the original name, so we don't need to parse out the time change
if "%loop-value%" doesn't contain "changedToAt":
set {_val} to loop-value
replace all "[{name:" and "}]" in {_val} with ""
send "&8[&7%loop-index%&8] &6%{_val}% &c(Original)" to the command sender
# Otherwise they changed FROM another name TO this one at some point, so we have to parse out the time
else:
set {_parsedResult::*} to loop-value split at ",changedToAt:"
replace all "name:" in {_parsedResult::1} with ""
replace all "}]" in {_parsedResult::2} with ""
set {_changeTime} to convert unix ("%{_parsedResult::2}%" parsed as number) to date
send "&8[&7%loop-index%&8] &6%{_parsedResult::1}% &c(%{_changeTime}%)" to the command sender
delete {_changeTime}
delete {_parsedResult::*}
send "" to the command sender
makeLook Function (force entity to look somewhere)
Requires: SkStuff
Description: Makes the given entity look at the given location (which of course can be another entity or a block or whatever you want). Works as you'd expect. And before you ask, yes, I tried removing the SkStuff dependency by just generating a location with the new yaw and pitch and teleporting the entity to it, but it doesn't work (don't ask me why). Also, if it "doesn't work sometimes", it's more likely that the entity just happened to decide to look somewhere else randomly right as/after the function ran, which is uncontrollable unless you use SkStuff to remove the 'look around randomly' pathfinder goal.
code_language.skript:
function makeLook(e: living entity, loc: location):
set {_xD} to {_loc}'s x location - {_e}'s x location
set {_yD} to {_loc}'s y location - {_e}'s y location
set {_zD} to {_loc}'s z location - {_e}'s z location
set {_yaw} to atan2({_xD}, {_zD}) - 90
set {_adj2} to ({_xD}*{_xD}) + ({_zD}*{_zD})
set {_parallel} to sqrt({_adj2})
set {_pitch} to atan2({_yD}, {_parallel}) - 90
add "{Rotation:[%{_yaw}%f, %{_pitch}%f]}" to NBT of {_e}
setCooldown Function (sets a visual cooldown on an item for a player)
Requires: MundoSK (you NEED the latest beta from GitHub for it to work)
Description: Sends a visual cooldown to the given player for a certain item type. This is displayed as an overlay that covers up all instances of the item type in the player's inventory, which slides downwards over the duration. Note that this does NOT actually do anything on its own or stop the client from using items -- it's just a visual thing that's useful for properly displaying item cooldowns to players. Nice for activated abilities.
code_language.skript:
function setCooldown(p: player, itemType: item, durationInTicks: integer):
set {_packet} to new play_server_set_cooldown packet
set "item" pinfo 0 of {_packet} to {_itemType}
set int pnum 0 of {_packet} to {_durationInTicks}
send packet {_packet} to {_p}
Will add more as I decide they're appropriate or remember to.