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

Concurrent variables issue #3853

Closed
TheLimeGlass opened this issue Mar 25, 2021 · 6 comments
Closed

Concurrent variables issue #3853

TheLimeGlass opened this issue Mar 25, 2021 · 6 comments
Labels
duplicate For bugs or requests that have already been made and are currently open.

Comments

@TheLimeGlass
Copy link
Collaborator

[17:03:24 ERROR]: #!#! Stack trace:
[17:03:24 ERROR]: #!#! java.util.ConcurrentModificationException
[17:03:24 ERROR]: #!#!     at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
[17:03:24 ERROR]: #!#!     at java.util.LinkedList$ListItr.next(Unknown Source)
[17:03:24 ERROR]: #!#!     at ch.njol.skript.log.SkriptLogger.log(SkriptLogger.java:172)
[17:03:24 ERROR]: #!#!     at ch.njol.skript.log.SkriptLogger.log(SkriptLogger.java:164)
[17:03:24 ERROR]: #!#!     at ch.njol.skript.Skript.warning(Skript.java:1427)
[17:03:24 ERROR]: #!#!     at ch.njol.skript.variables.VariablesStorage.save(VariablesStorage.java:248)
[17:03:24 ERROR]: #!#!     at ch.njol.skript.variables.Variables$2.run(Variables.java:550)
[17:03:24 ERROR]: #!#!     at java.lang.Thread.run(Unknown Source)
[17:03:24 ERROR]: #!#!
[17:03:24 ERROR]: #!#! Version Information:
[17:03:24 ERROR]: #!#!   Skript: 2.5-alpha6(rev1) (OUTDATED)
[17:03:24 ERROR]: #!#!     Flavor: skriptlang-github
[17:03:24 ERROR]: #!#!     Date: 2020-07-21
[17:03:24 ERROR]: #!#!   Bukkit: 1.16.5-R0.1-SNAPSHOT
[17:03:24 ERROR]: #!#!   Minecraft: 1.16.5
[17:03:24 ERROR]: #!#!   Java: 1.8.0_161 (Java HotSpot(TM) 64-Bit Server VM 25.161-b12)
[17:03:24 ERROR]: #!#!   OS: Windows 10 amd64 10.0
[17:03:24 ERROR]: #!#!
[17:03:24 ERROR]: #!#! Server platform: Paper
[17:03:24 ERROR]: #!#!
[17:03:24 ERROR]: #!#! Current node: null
[17:03:24 ERROR]: #!#! Current item: null
[17:03:24 ERROR]: #!#!
[17:03:24 ERROR]: #!#! Thread: Skript variable save thread
[17:03:24 ERROR]: #!#!
[17:03:24 ERROR]: #!#! Language: english
[17:03:24 ERROR]: #!#! Link parse mode: DISABLED
[17:03:24 ERROR]: #!#!
[17:03:24 ERROR]: #!#! End of Error.
[17:03:24 ERROR]: #!#!

on script unload:
	delete {skript-edit::temp::*}

function setBlock(player: player, location: location, text: text):
	if {_text} doesn't contain ";":
		if {_text} doesn't contain "%%":
			set {_item} to {_text} parsed as item
			if {_item} is not set:
				if parse error is set:
					message "&c%{_text}% is not a valid item. Error: %last parse error%" to {_player}
				else:
					message "&c%{_text}% is not a valid item." to {_player}
				stop
			set block at {_location} to {_text} parsed as item
		else:
			set {_item} to {_text} parsed as item
			if {_item} is not set:
				if parse error is set:
					message "&c%{_text}% is not a valid item. Error: %last parse error%" to {_player}
				else:
					message "&c%{_text}% is not a valid item." to {_player}
				stop
			set {_values::*} to {_text} split at "%%"
			set {_chance} to {_values::1} parsed as number
			if {_chance} is not set:
				if parse error is set:
					message "&c%{_values::1}% is not a valid number. Error: %last parse error%" to {_player}
				else:
					message "&c%{_values::1}% is not a valid number." to {_player}
				stop
			set {_item} to {_values::2} parsed as item
			if {_item} is not set:
				if parse error is set:
					message "&c%{_values::2}% is not a valid item. Error: %last parse error%" to {_player}
				else:
					message "&c%{_values::2}% is not a valid item." to {_player}
				stop
			chance of {_chance}%:
				set block at {_location} to {_item}
	else:
		loop {_text} split at ";":
			clear {_values::*}, {_chance} and {_item}
			set {_values::*} to loop-value split at "%%"
			set {_chance} to {_values::1} parsed as number
			if {_chance} is not set:
				if parse error is set:
					message "&c%{_values::1}% is not a valid number. Error: %last parse error%" to {_player}
				else:
					message "&c%{_values::1}% is not a valid number." to {_player}
				stop
			set {_item} to {_values::2} parsed as item
			if {_item} is not set:
				if parse error is set:
					message "&c%{_values::2}% is not a valid item. Error: %last parse error%" to {_player}
				else:
					message "&c%{_values::2}% is not a valid item." to {_player}
				stop
			loop {_chance} times:
				add {_item} to {_list::*}
		set block at {_location} to random item out of {_list::*}
	set {skript-edit::temp::player::%{_player}%::complete} to now

command //pos1:
	permission: skript-edit.position
	aliases: //position1
	trigger:
		set {skript-edit::temp::player::%player%::pos1} to location of block at player
		message "&eYou have set position 1 to %{skript-edit::temp::player::%player%::pos1}%"

command //pos2:
	permission: skript-edit.position
	aliases: //position2
	trigger:
		set {skript-edit::temp::player::%player%::pos2} to location of block at player
		message "&eYou have set position 2 to %{skript-edit::temp::player::%player%::pos2}%"

command //set <text>:
	permission: skript-edit.set
	trigger:
		if {skript-edit::temp::player::%player%::pos1} is not set:
			message "&cYou don't have position 1 set."
			stop
		if {skript-edit::temp::player::%player%::pos2} is not set:
			message "&cYou don't have position 2 set."
			stop
		set {_blocks::*} to blocks within {skript-edit::temp::player::%player%::pos1} to {skript-edit::temp::player::%player%::pos2}
		if {skript-edit::temp::player::%player%::mask} is set:
			set {_blocks::*} to blocks within {skript-edit::temp::player::%player%::pos1} to {skript-edit::temp::player::%player%::pos2} where [{skript-edit::temp::player::%player%::mask}]
		set {_time} and {_timeout} to now
		loop {_blocks::*}:
			clear {skript-edit::temp::player::%player%::complete}
			setBlock(player, location of loop-value, argument)
			if {skript-edit::temp::player::%player%::complete} is not set:
				stop
			add 1 to {_count}
			if difference between {_timeout} and now is greater than 15 seconds:
				wait a tick
				set {_timeout} to now
		message "&6%{_count}% &eblocks have been changed in %difference between {_time} and now%"

command //replace <item> <item>:
	permission: skript-edit.replace
	trigger:
		if {skript-edit::temp::player::%player%::pos1} is not set:
			message "&cYou don't have position 1 set."
			stop
		if {skript-edit::temp::player::%player%::pos2} is not set:
			message "&cYou don't have position 2 set."
			stop
		set {skript-edit::temp::player::%player%::mask} to "block input is %argument-1%"
		execute player command "//set %argument-2%"

command //mask <text>:
	permission: skript-edit.mask
	trigger:
		set {skript-edit::temp::player::%player%::mask} to argument
		message "&eYou have set the mask to [%{skript-edit::temp::player::%player%::mask}%&e]"

@TheLimeGlass
Copy link
Collaborator Author

Present in 2.5.3

@Romitou
Copy link
Member

Romitou commented Mar 25, 2021

i tried your script by replacing these lines:

within {skript-edit::temp::player::%player%::pos1} and {skript-edit::temp::player::%player%::pos2}
where [{skript-edit::temp::player::%player%::mask} is set]

by testing all the functions and commands, but i was unable to reproduce your issue with skript 2.5.3 only

@TheDGOfficial
Copy link
Contributor

TheDGOfficial commented Mar 25, 2021

From the stack trace, it looks like it has nothing to do with variables, but log handlers. See #3800

@Romitou
Copy link
Member

Romitou commented Mar 25, 2021

i think it's also maybe related to #3817 🙂

@TheLimeGlass
Copy link
Collaborator Author

Note: It's using functions which means it's on another thread from the script.

@TPGamesNL
Copy link
Member

Duplicate of #3453 / #3064.
The two threads at play here are the main server thread and the variable save thread, same as #3064.

@TPGamesNL TPGamesNL added the duplicate For bugs or requests that have already been made and are currently open. label Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate For bugs or requests that have already been made and are currently open.
Projects
None yet
Development

No branches or pull requests

4 participants