11package sc.plugin2021
22
3+ import com.thoughtworks.xstream.XStream
34import sc.api.plugins.IGameInstance
45import sc.api.plugins.IGamePlugin
6+ import sc.helpers.xStream
57import sc.plugin2021.xstream.BoardConverter
68import sc.plugins.PluginDescriptor
79import sc.protocol.helpers.LobbyProtocol
810import sc.shared.ScoreAggregation
911import sc.shared.ScoreDefinition
1012import sc.shared.ScoreFragment
11- import sc.helpers.xStream as xstream
13+ import java.util.concurrent.atomic.AtomicBoolean
1214
1315@PluginDescriptor(name = " Blokus" , uuid = " swc_2021_blokus" )
1416class GamePlugin : IGamePlugin {
1517
1618 companion object {
1719 val PLUGIN_UUID = " swc_2021_blokus"
20+ val loaded = AtomicBoolean (false )
1821
1922 val SCORE_DEFINITION = ScoreDefinition (arrayOf(
2023 ScoreFragment (" Gewinner" ),
@@ -28,15 +31,16 @@ class GamePlugin: IGamePlugin {
2831 Color ::class .java, Team ::class .java)
2932
3033 fun registerXStream () {
31- LobbyProtocol .registerAdditionalMessages(xstream, classesToRegister)
32-
33- xstream.registerConverter(BoardConverter ())
34+ if (loaded.compareAndSet(false , true )) {
35+ LobbyProtocol .registerAdditionalMessages(xStream, classesToRegister)
36+ xStream.registerConverter(BoardConverter ())
37+ }
3438 }
35-
39+
3640 @JvmStatic
37- val xStream by lazy {
41+ fun loadXStream (): XStream {
3842 registerXStream()
39- xstream
43+ return xStream
4044 }
4145 }
4246
0 commit comments