skript-yaml icon indicating copy to clipboard operation
skript-yaml copied to clipboard

Always convert strings containing & to §

Open qsef1256 opened this issue 3 years ago • 2 comments

Description:

  1. In Skript, the arguments of the command are converted to uncolored strings. (&atest)
  2. In skript-yaml, colorless string containing & are converted to uncolored string with "" ("&atest")
  3. When loading yaml value, skript-yaml always converts & to §. (§atest)
  4. This is usually not a problem when sending values to chat, but it causes problems in the following cases.

Code:

options:
	debug: &r[&bDebug&r]
	file: "plugins/Skript/scripts/test.yml"

command /yaml [<text>] [<text>]:
	trigger:
		set {_uuid} to uuid of player
		if arg 1 is "addparty":
			arg 2 is set
			load yaml {@file} as {@file}
			set {_party} to arg 2
			set yaml value "user.%{_uuid}%" from {@file} to {_party}
			add {_uuid} to yaml list "data.%{_party}%.user" from {@file}
			send "{@debug} Add Party %{_party}%"
			save yaml {@file}
			stop
		if arg 1 is "removeparty":
			arg 2 is set
			load yaml {@file} as {@file}
			set {_party} to arg 2
			clear yaml value "user.%{_uuid}%" from {@file}
			clear yaml list "data.%{_party}%.user" from {@file}
			send "{@debug} Remove Party %{_party}%"
			save yaml {@file}
			stop
		if arg 1 is "addplayer":
			yamlAddPlayer(player)
			stop
		if arg 1 is "removeplayer":
			yamlRemovePlayer(player)
			stop

function yamlAddPlayer(name: player):
	load yaml {@file} as {@file}
	set {_uuid} to uuid of {_name}
	set {_party} to yaml value "user.%{_uuid}%" from {@file} # Automatic detect player's party and problem is here
	send "{@debug} Add your UUID to %{_party}%" to {_name}
	add {_uuid} to yaml list "data.%{_party}%.chat" from {@file}
	save yaml {@file}

function yamlRemovePlayer(name: player):
	load yaml {@file} as {@file}
	set {_uuid} to uuid of {_name}
	set {_party} to yaml value "user.%{_uuid}%" from {@file}
	send "{@debug} Remove your UUID from %{_party}%" to {_name}
	remove {_uuid} from yaml list "data.%{_party}%.chat" from {@file}
	save yaml {@file}

Reproduce:

  1. /yaml addparty &atest
  2. /yaml addplayer

Expecting Result: Player's uuid will be added to yaml list "data.&atest.chat", not "data.§atest.chat".

Result:

user:
    d87af76e-09b8-4a0b-925b-d6dcc753a89a: "&atest"

data:
    "&atest":
        user:
        - d87af76e-09b8-4a0b-925b-d6dcc753a89a
    §atest:
        chat:
        - d87af76e-09b8-4a0b-925b-d6dcc753a89a

Versions: Server Version: 3243-Spigot-6c1c1b2-d3cc412 (MC: 1.17.1) Skript Version: 2.6-beta3

Installed Skript Addons: skript-yaml v1.4.1

Of course, in this case, I has registered a uncolored string with &, so it can be said that it is the my fault in some way. But in this situation, uncolored string(with &) should not be converted to colored(with §), because it was registered as a uncolored string.

Receiving the command argument as colored can solve this problem. so I rewritten my scripts with colored command arguments. Now it seems to be working fine.

I couldn't find exactly where in my script was causing the problem because of #35, but now I think I finally found it. Thank you for your help. :D

qsef1256 avatar Oct 08 '21 06:10 qsef1256

It might make sense to always convert & to §, as it is now. But I think there should be a warning to avoid confusion.

qsef1256 avatar Oct 08 '21 13:10 qsef1256

Thats fair, i'll add one!

Sashie avatar Apr 07 '22 02:04 Sashie