File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
plugin/src/shared/sc/plugin2021/xstream Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,16 @@ import com.thoughtworks.xstream.converters.MarshallingContext
55import com.thoughtworks.xstream.converters.UnmarshallingContext
66import com.thoughtworks.xstream.io.HierarchicalStreamReader
77import com.thoughtworks.xstream.io.HierarchicalStreamWriter
8+ import org.slf4j.LoggerFactory
89import sc.plugin2021.util.Constants
910import sc.plugin2021.Board
1011import sc.plugin2021.FieldContent
1112
1213class BoardConverter : Converter {
14+ companion object {
15+ val logger = LoggerFactory .getLogger(BoardConverter ::class .java)
16+ }
17+
1318 override fun canConvert (type : Class <* >? ): Boolean {
1419 return type == Board ::class .java
1520 }
@@ -36,10 +41,14 @@ class BoardConverter: Converter {
3641
3742 while (reader.hasMoreChildren()) {
3843 reader.moveDown()
39- val x = reader.getAttribute(" x" ).toInt()
40- val y = reader.getAttribute(" y" ).toInt()
41- val content = FieldContent .valueOf(reader.getAttribute(" content" ))
42- field[y][x] = content
44+ try {
45+ val x = reader.getAttribute(" x" ).toInt()
46+ val y = reader.getAttribute(" y" ).toInt()
47+ val content = FieldContent .valueOf(reader.getAttribute(" content" ))
48+ field[y][x] = content
49+ } catch (e: NullPointerException ) {
50+ logger.warn(" Failed to read field" )
51+ }
4352 reader.moveUp()
4453 }
4554
You can’t perform that action at this time.
0 commit comments