Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always convert strings containing & to § #36

Open
qsef1256 opened this issue Oct 8, 2021 · 2 comments
Open

Always convert strings containing & to § #36

qsef1256 opened this issue Oct 8, 2021 · 2 comments

Comments

@qsef1256
Copy link

qsef1256 commented Oct 8, 2021

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 qsef1256 changed the title Color conversion for string can cause yaml path conflict Always convert strings containing & to § Oct 8, 2021
@qsef1256
Copy link
Author

qsef1256 commented Oct 8, 2021

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

@Sashie
Copy link
Owner

Sashie commented Apr 7, 2022

Thats fair, i'll add one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants