Skript: Suggestion: UUID Subset expression: <UIDMost | UUIDLeast> of %entity%

Created on 11 Aug 2018  路  7Comments  路  Source: SkriptLang/Skript

I have ran into some issues i have not been able to find a work around for yet. When manipulating entity data tags they always store the UUID in 2 halves but skript only gives access to the full UUID without the ability to split it back into those halves easily. I tried to make a converter that would take the UUID skript will give us in HEX and convert it into DEC like its stored in data tags but the value becomes too high and skript starts round off least significant digits and doesn't preserve the accurate value needed. I also attempted using addons that have HEX->DEC converters but they give internal error when converting a 16 digit hex to dec. I dont need to be able to modify these halves in anyway so a text output would be fine which is what the current UUID is I think. Main reason is i want to be able to use /summon command to apply ownership to entities or projectiles but need the owner's UUID to be in the Most and Least halves. If there is another way to accomplish this with a 32digit hex uuid please let me know

enhancement won't fix

Most helpful comment

I would have to ask: is this really needed in vanilla Skript? You have to take into account these are not used anywhere besides NBT which isn't supported by Skript nor Spigot itself.

That said, unless you show me a valid usage within Skript, I'd say this feature belongs to an addon (perhaps skUtilities) rather than Skript itself.

Side note: here is a custom syntax version of the above functions since we're using skript-mirror:

import:

  java.util.UUID


strings property uuid (most|1娄least):
  get:
    set {_uuid} to UUID.fromString(expression-1)
    return {_uuid}.getLeastSignificantBits() if parser mark is 1, else {_uuid}.getMostSignificantBits()


expression [a] [new] uuid from %number% (and|to) %number%:
  get:
    return new UUID(expression-1, expression-2).toString()

Syntaxes:

[the] uuid (most|least) of %strings%
%strings%'[s] uuid (most|least)
# the strings being the uuids

[a] [new] uuid from %number% (and|to) %number%
# the first number is the UUIDLeast and the other one the UUIDMost

All 7 comments

Are you using SkStuff or skript-mirror by any chance?

/edit:
Nevermind the skript-mirror part. I was looking through the spigot API, but unfortunately couldn't find a method to grab either the Most or Least parts of the UUID.

You obviously seem to know what you're doing, but i still wanted to suggest, in case you're using SkStuff, the extract the information you need using tag "UUIDLeast" of entity's nbt

Hold the phone i got this https://snag.gy/zRBUYW.jpg

done! https://snag.gy/Xlf2qa.jpg

Here you go @JeepSmash :
(requires skript-mirror!)

command /test:
    trigger:
        set {_most} to getUUIDMost(command sender)
        set {_least} to getUUIDLeast(command sender)
        set {_uuid} to constructUUID({_most}, {_least})
        send "most: %{_most}%"
        send "least: %{_least}%"
        send "uuid: %{_uuid}%"
import:
    java.util.UUID

function getUUIDMost(entity: entity) :: integer:
    set {_uuid} to {_entity}.getUniqueId()
    return UUID.getMostSignificantBits({_uuid})

function getUUIDLeast(entity: entity) :: integer:
    set {_uuid} to {_entity}.getUniqueId()
    return UUID.getLeastSignificantBits({_uuid})

function constructUUID(most: integer, least: integer) :: text:
    return "%new UUID({_most}, {_least})%"

To the developers:
In case you guys decide this is useful to be added to Skript: all it needs is the usage of java.util.UUID. Can be found here: https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html

I would have to ask: is this really needed in vanilla Skript? You have to take into account these are not used anywhere besides NBT which isn't supported by Skript nor Spigot itself.

That said, unless you show me a valid usage within Skript, I'd say this feature belongs to an addon (perhaps skUtilities) rather than Skript itself.

Side note: here is a custom syntax version of the above functions since we're using skript-mirror:

import:

  java.util.UUID


strings property uuid (most|1娄least):
  get:
    set {_uuid} to UUID.fromString(expression-1)
    return {_uuid}.getLeastSignificantBits() if parser mark is 1, else {_uuid}.getMostSignificantBits()


expression [a] [new] uuid from %number% (and|to) %number%:
  get:
    return new UUID(expression-1, expression-2).toString()

Syntaxes:

[the] uuid (most|least) of %strings%
%strings%'[s] uuid (most|least)
# the strings being the uuids

[a] [new] uuid from %number% (and|to) %number%
# the first number is the UUIDLeast and the other one the UUIDMost

skript can set the shooter of a projectile already

Until this eventually is or isn't added to Skript, UUID related stuff is available in ExpressionsPlus: https://forums.skunity.com/resources/expressionsplus.638/

I believe it was decided this should not be in Skript, so I'll close it, then

Was this page helpful?
0 / 5 - 0 ratings